]> git.sur5r.net Git - bacula/bacula/commitdiff
Add context sensitive options in storage for label, mount and umount.
authorDirk H Bartley <dbartley@schupan.com>
Sat, 28 Apr 2007 13:30:02 +0000 (13:30 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Sat, 28 Apr 2007 13:30:02 +0000 (13:30 +0000)
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
bacula/src/qt-console/label/label.h
bacula/src/qt-console/pages.cpp
bacula/src/qt-console/storage/storage.cpp
bacula/src/qt-console/storage/storage.h
bacula/src/qt-console/storage/storage.ui

index 5109ed2ae957aa471dfd8842bf919619bcf8966e..f9566f7e73ff14351ebf3748611472f29815b370 100644 (file)
 #include <QMessageBox>
 
 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;
index d5acfd82de96166e810305e053a310733feed60d..533d109a6952576a04840bbea8ac2245385621c6 100644 (file)
@@ -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();
index 801200f6116f0c39f43de3234dd918f8a6ec0130..4076171dea28000d40a234182f6aa3117f9ef5e7 100644 (file)
@@ -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));
 }
 
 /*
index f3a46edf462eefc7bcdc8e9e1e7123a88c75bdbd..bab484261a09b596db03f72f233f165011514918 100644 (file)
@@ -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);
+}
index 5ba03d834e72f2fdb73cc325f73c152e4e431a8f..2079a9b1098934d92402c53b34846bb69a8e5d98 100644 (file)
@@ -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;
 };
index 1c1d1eb6831e19523d3c9e33a1430c60025f1b15..f359e634e7e1af3d321c59a3b41682cd894075e3 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>763</width>
-    <height>650</height>
+    <width>791</width>
+    <height>644</height>
    </rect>
   </property>
   <property name="windowTitle" >
     <string>Status Storage In Console</string>
    </property>
   </action>
+  <action name="actionLabelStorage" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>Label Storage</string>
+   </property>
+  </action>
+  <action name="actionMountStorage" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>MountStorage</string>
+   </property>
+  </action>
+  <action name="actionUnMountStorage" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>UnMount Storage</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections/>