From e8a79e58127ba2ac6e75267e08d88fa708c697c3 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sat, 28 Apr 2007 13:30:02 +0000 Subject: [PATCH] Add context sensitive options in storage for label, mount and umount. Modify label class to have an overoaded constructor so as to have the ablility to get the storage to default to a specific storage. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4645 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/label/label.cpp | 23 ++++++++ bacula/src/qt-console/label/label.h | 2 + bacula/src/qt-console/pages.cpp | 4 +- bacula/src/qt-console/storage/storage.cpp | 66 +++++++++++++++++------ bacula/src/qt-console/storage/storage.h | 5 +- bacula/src/qt-console/storage/storage.ui | 28 +++++++++- 6 files changed, 107 insertions(+), 21 deletions(-) diff --git a/bacula/src/qt-console/label/label.cpp b/bacula/src/qt-console/label/label.cpp index 5109ed2ae9..f9566f7e73 100644 --- a/bacula/src/qt-console/label/label.cpp +++ b/bacula/src/qt-console/label/label.cpp @@ -38,15 +38,38 @@ #include labelDialog::labelDialog(Console *console) +{ + QString deflt(""); + showDialog(console, deflt); +} + +/* + * An overload of the constructor to have a default storage show in the + * combobox on start. Used from context sensitive in storage class. + */ +labelDialog::labelDialog(Console *console, QString &defString) +{ + showDialog(console, defString); +} + +/* + * moved the constructor code here for the overload. + */ +void labelDialog::showDialog(Console *console, QString &defString) { m_console = console; m_console->notify(false); setupUi(this); storageCombo->addItems(console->storage_list); + int index = storageCombo->findText(defString, Qt::MatchExactly); + if (index != -1) { + storageCombo->setCurrentIndex(index); + } poolCombo->addItems(console->pool_list); this->show(); } + void labelDialog::accept() { QString scmd; diff --git a/bacula/src/qt-console/label/label.h b/bacula/src/qt-console/label/label.h index d5acfd82de..533d109a69 100644 --- a/bacula/src/qt-console/label/label.h +++ b/bacula/src/qt-console/label/label.h @@ -42,6 +42,8 @@ class labelDialog : public QDialog, public Ui::labelForm public: labelDialog(Console *console); + labelDialog(Console *console, QString &defString); + void showDialog(Console *console, QString &defString); private slots: void accept(); diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 801200f611..4076171dea 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -215,14 +215,14 @@ void Pages::consoleCommand(QString &command) { if (!m_console->is_connectedGui()) return; + /* Bring this directors console to the front of the stack */ + mainWin->treeWidget->setCurrentItem(mainWin->getFromHash(m_console)); m_console->display_text("Context sensitive command :\n\n"); m_console->display_text("**** "); m_console->display_text(command + " ****\n"); m_console->display_text("Director Response :\n\n"); m_console->write_dir(command.toUtf8().data()); m_console->displayToPrompt(); - /* Bring this directors console to the front of the stack */ - mainWin->treeWidget->setCurrentItem(mainWin->getFromHash(m_console)); } /* diff --git a/bacula/src/qt-console/storage/storage.cpp b/bacula/src/qt-console/storage/storage.cpp index f3a46edf46..bab484261a 100644 --- a/bacula/src/qt-console/storage/storage.cpp +++ b/bacula/src/qt-console/storage/storage.cpp @@ -50,6 +50,7 @@ Storage::Storage() m_populated = false; m_checkcurwidget = true; m_closeable = false; + m_currentStorage = ""; setTitle(); } @@ -154,6 +155,9 @@ void Storage::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt(); if (treedepth == 1){ mp_treeWidget->removeAction(actionStatusStorageInConsole); + mp_treeWidget->removeAction(actionLabelStorage); + mp_treeWidget->removeAction(actionMountStorage); + mp_treeWidget->removeAction(actionUnMountStorage); } } @@ -161,8 +165,20 @@ void Storage::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte if (treedepth == 1){ /* set a hold variable to the storage name in case the context sensitive * menu is used */ - m_currentlyselected=currentwidgetitem->text(0); + m_currentStorage=currentwidgetitem->text(0); mp_treeWidget->addAction(actionStatusStorageInConsole); + mp_treeWidget->addAction(actionLabelStorage); + mp_treeWidget->addAction(actionMountStorage); + mp_treeWidget->addAction(actionUnMountStorage); + QString text; + text = "Status Storage " + m_currentStorage; + actionStatusStorageInConsole->setText(text); + text = "Label media in Storage " + m_currentStorage; + actionLabelStorage->setText(text); + text = "Mount media in Storage " + m_currentStorage; + actionMountStorage->setText(text); + text = "\"UN\" Mount media in Storage " + m_currentStorage; + actionUnMountStorage->setText(text); } } } @@ -184,21 +200,12 @@ void Storage::createContextMenu() SLOT(populateTree())); connect(actionStatusStorageInConsole, SIGNAL(triggered()), this, SLOT(consoleStatusStorage())); -} - -/* - * Function responding to actionListJobsofStorage which calls mainwin function - * to create a window of a list of jobs of this storage. - */ -void Storage::consoleStatusStorage() -{ - QString cmd("status storage="); - cmd += m_currentlyselected; - consoleCommand(cmd); -// m_console->write_dir(cmd.toUtf8().data()); -// m_console->displayToPrompt(); - /* Bring this directors console to the front of the stack */ -// mainWin->treeWidget->setCurrentItem(mainWin->getFromHash(m_console)); + connect(actionLabelStorage, SIGNAL(triggered()), this, + SLOT(consoleLabelStorage())); + connect(actionMountStorage, SIGNAL(triggered()), this, + SLOT(consoleMountStorage())); + connect(actionUnMountStorage, SIGNAL(triggered()), this, + SLOT(consoleUnMountStorage())); } /* @@ -217,3 +224,30 @@ void Storage::currentStackItem() m_populated=true; } } + +/* + * Functions to respond to local context sensitive menu sending console commands + * If I could figure out how to make these one function passing a string, Yaaaaaa + */ +void Storage::consoleStatusStorage() +{ + QString cmd("status storage="); + cmd += m_currentStorage; + consoleCommand(cmd); +} +void Storage::consoleLabelStorage() +{ + new labelDialog(m_console, m_currentStorage); +} +void Storage::consoleMountStorage() +{ + QString cmd("mount storage="); + cmd += m_currentStorage; + consoleCommand(cmd); +} +void Storage::consoleUnMountStorage() +{ + QString cmd("umount storage="); + cmd += m_currentStorage; + consoleCommand(cmd); +} diff --git a/bacula/src/qt-console/storage/storage.h b/bacula/src/qt-console/storage/storage.h index 5ba03d834e..2079a9b109 100644 --- a/bacula/src/qt-console/storage/storage.h +++ b/bacula/src/qt-console/storage/storage.h @@ -55,10 +55,13 @@ private slots: void populateTree(); // void showJobs(); void consoleStatusStorage(); + void consoleLabelStorage(); + void consoleMountStorage(); + void consoleUnMountStorage(); private: void createContextMenu(); - QString m_currentlyselected; + QString m_currentStorage; bool m_populated; bool m_checkcurwidget; }; diff --git a/bacula/src/qt-console/storage/storage.ui b/bacula/src/qt-console/storage/storage.ui index 1c1d1eb683..f359e634e7 100644 --- a/bacula/src/qt-console/storage/storage.ui +++ b/bacula/src/qt-console/storage/storage.ui @@ -5,8 +5,8 @@ 0 0 - 763 - 650 + 791 + 644 @@ -42,6 +42,30 @@ Status Storage In Console + + + ../images/unmark.png + + + Label Storage + + + + + ../images/unmark.png + + + MountStorage + + + + + ../images/unmark.png + + + UnMount Storage + + -- 2.39.5