From c6422af3e3fac7d229a39d357c86dbd066e81a7e Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 12 Aug 2009 10:21:31 +0200 Subject: [PATCH] bat: Put the content panel as a child of the Storage item bat: use slot selection in update slots command and in label command --- bacula/src/qt-console/storage/content.cpp | 60 ++++++++++++++++++++--- bacula/src/qt-console/storage/content.h | 2 +- bacula/src/qt-console/storage/storage.cpp | 3 +- bacula/src/qt-console/storage/storage.h | 2 + 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/bacula/src/qt-console/storage/content.cpp b/bacula/src/qt-console/storage/content.cpp index 63c063ab65..a8b6a120a4 100644 --- a/bacula/src/qt-console/storage/content.cpp +++ b/bacula/src/qt-console/storage/content.cpp @@ -41,10 +41,10 @@ // use user selection to add slot= argument // -Content::Content(QString storage) +Content::Content(QString storage, QTreeWidgetItem *parentWidget) { setupUi(this); - pgInitialize(tr("Storage Content")); + pgInitialize(storage, parentWidget); QTreeWidgetItem* thisitem = mainWin->getFromHash(this); thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/package-x-generic.png"))); @@ -76,10 +76,49 @@ Content::Content(QString storage) setCurrent(); } +void table_get_selection(QTableWidget *table, QString &sel) +{ + QTableWidgetItem *item; + int current; + + /* The QT selection returns each cell, so you + * have x times the same row number... + * We take only one instance + */ + int s = table->rowCount(); + bool *tab = (bool *)malloc(s * sizeof(bool)); + memset(tab, 0, s); + + foreach (item, table->selectedItems()) { + current = item->row(); + tab[current]=true; + } + + sel += "="; + + for(int i=0; iitem(i, 0)->text(); + sel += ","; + } + } + sel.chop(1); // remove trailing , or useless = + free(tab); +} + /* Label Media populating current storage by default */ void Content::consoleLabelStorage() { - new labelPage(m_currentStorage); + QString sel; + table_get_selection(tableContent, sel); + if (sel == "") { + new labelPage(m_currentStorage); + } else { + QString cmd = "label barcodes slots"; + cmd += sel; + cmd += " storage=" + m_currentStorage; + consoleCommand(cmd); + } } /* Mount currently selected storage */ @@ -230,10 +269,19 @@ void Content::treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *) /* Update Slots */ void Content::consoleUpdateSlots() { - // TODO: get selected slots - QString cmd("update slots storage="); - cmd += m_currentStorage; + QString sel = ""; + table_get_selection(tableContent, sel); + + QString cmd("update slots"); + if (sel != "") { + cmd += sel; + } + cmd += " storage=" + m_currentStorage; + + Pmsg1(0, "cmd=%s\n", cmd.toUtf8().data()); + consoleCommand(cmd); + populateContent(); } /* Release a tape in the drive */ diff --git a/bacula/src/qt-console/storage/content.h b/bacula/src/qt-console/storage/content.h index b4cf68bc75..94eb35ed08 100644 --- a/bacula/src/qt-console/storage/content.h +++ b/bacula/src/qt-console/storage/content.h @@ -38,7 +38,7 @@ class Content : public Pages, public Ui::ContentForm Q_OBJECT public: - Content(QString storage); + Content(QString storage, QTreeWidgetItem *parentWidget); // virtual void PgSeltreeWidgetClicked(); virtual void currentStackItem(); diff --git a/bacula/src/qt-console/storage/storage.cpp b/bacula/src/qt-console/storage/storage.cpp index 1e5cd6e8a3..2f26b550fd 100644 --- a/bacula/src/qt-console/storage/storage.cpp +++ b/bacula/src/qt-console/storage/storage.cpp @@ -335,7 +335,8 @@ void Storage::createContextMenu() void Storage::contentWindow() { if (m_currentStorage != "" && m_currentAutoChanger) { - new Content(m_currentStorage); + QTreeWidgetItem *parentItem = mainWin->getFromHash(this); + new Content(m_currentStorage, parentItem); } } diff --git a/bacula/src/qt-console/storage/storage.h b/bacula/src/qt-console/storage/storage.h index 7facc1ad3e..e08e229ce0 100644 --- a/bacula/src/qt-console/storage/storage.h +++ b/bacula/src/qt-console/storage/storage.h @@ -76,4 +76,6 @@ private: QTreeWidgetItem *m_topItem; }; +void table_get_selection(QTableWidget *table, QString &sel); + #endif /* _STORAGE_H_ */ -- 2.39.5