]> git.sur5r.net Git - bacula/bacula/commitdiff
Add buttons and local timer configuration to storage window.
authorDirk H Bartley <dbartley@schupan.com>
Tue, 18 Mar 2008 02:10:22 +0000 (02:10 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Tue, 18 Mar 2008 02:10:22 +0000 (02:10 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6623 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/status/storstat.cpp
bacula/src/qt-console/status/storstat.h
bacula/src/qt-console/status/storstat.ui

index f228ab1b3ad27afef0276e6b147e559eb23bba45..bad5b47f2c71f38ed06c34f060ba19fbe27dbcb7 100644 (file)
@@ -35,6 +35,7 @@
 #include <QTableWidgetItem>
 #include "bat.h"
 #include "storstat.h"
+#include "mount/mount.h"
 
 /*
 .status storage=<storage-name> <keyword>
@@ -64,11 +65,10 @@ StorStat::StorStat(QString &storage, QTreeWidgetItem *parentTreeWidgetItem)
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/status.png")));
    m_cursor = new QTextCursor(textEditHeader->document());
 
+   m_timer = new QTimer(this);
    readSettings();
    dockPage();
-   m_timer = new QTimer(this);
    QWidget::connect(m_timer, SIGNAL(timeout()), this, SLOT(timerTriggered()));
-   m_timer->start(mainWin->m_refreshStatusDirInterval*1000);
 
    createConnections();
    setCurrent();
@@ -105,7 +105,6 @@ void StorStat::populateAll()
    if (!m_console->preventInUseConnect())
        return;
    populateTerminated();
-   populateRunning();
    populateCurrentTab(tabWidget->currentIndex());
 }
 
@@ -115,7 +114,7 @@ void StorStat::populateAll()
 void StorStat::timerTriggered()
 {
    bool iscurrent = mainWin->stackedWidget->currentIndex() == mainWin->stackedWidget->indexOf(this);
-   if (((isDocked() && iscurrent) || (!isDocked())) && mainWin->m_refreshStatusDir) {
+   if (((isDocked() && iscurrent) || (!isDocked())) && (checkBox->checkState() == Qt::Checked)) {
       if (m_console->is_ready())
          populateAll();
    }
@@ -204,6 +203,22 @@ void StorStat::populateSpooling()
    }
 }
 
+void StorStat::populateRunning()
+{
+   QString command = QString(".status storage=\"" + m_storage + "\" running");
+   if (mainWin->m_commandDebug)
+      Pmsg1(000, "sending command : %s\n",command.toUtf8().data());
+   QStringList results;
+   textEditRunning->clear();
+
+   if (m_console->dir_cmd(command, results)) {
+      foreach (QString line, results) {
+         line += "\n";
+         textEditRunning->insertPlainText(line);
+      }
+   }
+}
+
 /*
  * Populate teminated table
  */
@@ -260,50 +275,6 @@ void StorStat::populateTerminated()
    terminatedTable->verticalHeader()->hide();
 }
 
-/*
- * Populate running table
- */
-void StorStat::populateRunning()
-{
-   QString command = QString(".status storage=\"" + m_storage + "\" running");
-   if (mainWin->m_commandDebug)
-      Pmsg1(000, "sending command : %s\n",command.toUtf8().data());
-   QStringList results;
-   QBrush blackBrush(Qt::black);
-
-   runningTable->clear();
-   QStringList headerlist = (QStringList()
-      << tr("Job Id") << tr("Job Level") << tr("Job Data") << tr("Job Info"));
-
-   runningTable->setColumnCount(headerlist.size());
-   runningTable->setHorizontalHeaderLabels(headerlist);
-
-   if (m_console->dir_cmd(command, results)) {
-      int row = 0;
-      QTableWidgetItem* p_tableitem;
-      runningTable->setRowCount(results.size());
-      foreach (QString line, results) {
-         /* Iterate through the record returned from the query */
-         QStringList fieldlist = line.split("\t");
-         int column = 0;
-         QString statusCode("");
-         /* Iterate through fields in the record */
-         foreach (QString field, fieldlist) {
-            field = field.trimmed();  /* strip leading & trailing spaces */
-            p_tableitem = new QTableWidgetItem(field, 1);
-            p_tableitem->setForeground(blackBrush);
-            p_tableitem->setFlags(0);
-            runningTable->setItem(row, column, p_tableitem);
-            column += 1;
-         }
-         row += 1;
-      }
-   }
-   runningTable->resizeColumnsToContents();
-   runningTable->resizeRowsToContents();
-   runningTable->verticalHeader()->hide();
-}
-
 /*
  * When the treeWidgetItem in the page selector tree is singleclicked, Make sure
  * The tree has been populated.
@@ -336,15 +307,14 @@ void StorStat::createConnections()
 {
    connect(actionRefresh, SIGNAL(triggered()), this,
                    SLOT(populateAll()));
-   connect(actionCancelRunning, SIGNAL(triggered()), this,
-                   SLOT(consoleCancelJob()));
    connect(tabWidget, SIGNAL(currentChanged(int)), this,
                    SLOT(populateCurrentTab(int)));
+   connect(spinBox, SIGNAL(valueChanged(int)), this,
+                   SLOT(spinBoxValueChanged(int)));
+   connect(mountButton, SIGNAL(pressed()), this, SLOT(mountButtonPushed()));
+   connect(umountButton, SIGNAL(pressed()), this, SLOT(umountButtonPushed()));
    terminatedTable->setContextMenuPolicy(Qt::ActionsContextMenu);
    terminatedTable->addAction(actionRefresh);
-   runningTable->setContextMenuPolicy(Qt::ActionsContextMenu);
-   runningTable->addAction(actionRefresh);
-   runningTable->addAction(actionCancelRunning);
 }
 
 /*
@@ -355,6 +325,8 @@ void StorStat::writeSettings()
    QSettings settings(m_console->m_dir->name(), "bat");
    settings.beginGroup(m_groupText);
    settings.setValue(m_splitText, splitter->saveState());
+   settings.setValue("refreshInterval", spinBox->value());
+   settings.setValue("refreshCheck", checkBox->checkState());
    settings.endGroup();
 }
 
@@ -368,22 +340,11 @@ void StorStat::readSettings()
    QSettings settings(m_console->m_dir->name(), "bat");
    settings.beginGroup(m_groupText);
    splitter->restoreState(settings.value(m_splitText).toByteArray());
+   spinBox->setValue(settings.value("refreshInterval", 28).toInt());
+   checkBox->setCheckState((Qt::CheckState)settings.value("refreshCheck", Qt::Checked).toInt());
    settings.endGroup();
-}
 
-/*
- * Cancel a running job
- */
-void StorStat::consoleCancelJob()
-{
-   int currentrow = runningTable->currentRow();
-   QTableWidgetItem *item = runningTable->item(currentrow, 0);
-   if (item) {
-      QString text = item->text();
-      QString cmd("cancel jobid=");
-      cmd += text;
-      consoleCommand(cmd);
-   }
+   m_timer->start(spinBox->value()*1000);
 }
 
 /*
@@ -401,4 +362,72 @@ void StorStat::populateCurrentTab(int index)
       populateVolumes();
    if (index == 4)
       populateSpooling();
+   if (index == 5)
+      populateRunning();
+}
+
+/*
+ * Set the timer when changed
+ */
+void StorStat::spinBoxValueChanged(int newval)
+{
+   m_timer->setInterval(newval*1000);
+}
+
+/*
+ * execute mount in console
+ */
+void StorStat::mountButtonPushed()
+{
+   int haschanger = 3;
+
+   /* Set up query QString and header QStringList */
+   QString query("SELECT AutoChanger AS Changer"
+            " FROM Storage WHERE Name='" + m_storage + "'"
+            " ORDER BY Name" );
+
+   QStringList results;
+   /* This could be a log item */
+   if (mainWin->m_sqlDebug) {
+      Pmsg1(000, "Storage query cmd : %s\n",query.toUtf8().data());
+   }
+   if (m_console->sql_cmd(query, results)) {
+      int resultCount = results.count();
+      if (resultCount == 1){
+         QString resultline;
+         QString field;
+         QStringList fieldlist;
+         /* there will only be one of these */
+         foreach (resultline, results) {
+            fieldlist = resultline.split("\t");
+            int index = 0;
+            /* Iterate through fields in the record */
+            foreach (field, fieldlist) {
+               field = field.trimmed();  /* strip leading & trailing spaces */
+               haschanger = field.toInt();
+               index++;
+            }
+         }
+      }
+   }
+
+   Pmsg1(000, "haschanger is : %i\n", haschanger);
+   if (haschanger == 0){
+      /* no autochanger, just execute the command in the console */
+      QString cmd("mount storage=" + m_storage);
+      consoleCommand(cmd);
+   } else if (haschanger != 3) {
+      setConsoleCurrent();
+      /* if this storage is an autochanger, lets ask for the slot */
+      new mountDialog(m_console, m_storage);
+   }
+}
+
+/*
+ * execute umount in console
+ */
+void StorStat::umountButtonPushed()
+{
+   QString cmd("umount storage=" + m_storage);
+   consoleCommand(cmd);
 }
index dd1b41e01b22434e76c8c56ea208fa9642195eea..6577a9526eae96c0e373b191487c3cda332475fb 100644 (file)
@@ -60,8 +60,10 @@ public slots:
 
 private slots:
    void timerTriggered();
-   void consoleCancelJob();
+   void spinBoxValueChanged(int);
    void populateCurrentTab(int);
+   void mountButtonPushed();
+   void umountButtonPushed();
 
 private:
    void createConnections();
index b72635453df2d640ae7310f2b3eb68e228b434f0..fd1960e20c8679df4ce6c73ca5a791f75fe755b9 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>502</width>
-    <height>466</height>
+    <width>367</width>
+    <height>310</height>
    </rect>
   </property>
   <property name="windowTitle" >
         </item>
        </layout>
       </widget>
-     </widget>
-     <widget class="QWidget" name="layoutWidget" >
-      <layout class="QVBoxLayout" >
-       <item>
-        <widget class="QLabel" name="runningLabel" >
-         <property name="layoutDirection" >
-          <enum>Qt::LeftToRight</enum>
+      <widget class="QWidget" name="runningTab" >
+       <attribute name="title" >
+        <string>Running</string>
+       </attribute>
+       <layout class="QGridLayout" >
+        <item row="0" column="0" >
+         <widget class="QTextEdit" name="textEditRunning" />
+        </item>
+       </layout>
+      </widget>
+      <widget class="QWidget" name="tab" >
+       <attribute name="title" >
+        <string>Misc</string>
+       </attribute>
+       <widget class="QPushButton" name="mountButton" >
+        <property name="geometry" >
+         <rect>
+          <x>170</x>
+          <y>40</y>
+          <width>80</width>
+          <height>24</height>
+         </rect>
+        </property>
+        <property name="text" >
+         <string>Mount</string>
+        </property>
+       </widget>
+       <widget class="QPushButton" name="umountButton" >
+        <property name="geometry" >
+         <rect>
+          <x>170</x>
+          <y>70</y>
+          <width>80</width>
+          <height>24</height>
+         </rect>
+        </property>
+        <property name="text" >
+         <string>UMount</string>
+        </property>
+       </widget>
+       <widget class="QGroupBox" name="groupBox" >
+        <property name="geometry" >
+         <rect>
+          <x>10</x>
+          <y>10</y>
+          <width>151</width>
+          <height>91</height>
+         </rect>
+        </property>
+        <property name="title" >
+         <string>Refresh Timer Top</string>
+        </property>
+        <widget class="QSpinBox" name="spinBox" >
+         <property name="geometry" >
+          <rect>
+           <x>20</x>
+           <y>50</y>
+           <width>111</width>
+           <height>24</height>
+          </rect>
          </property>
-         <property name="text" >
-          <string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
-p, li { white-space: pre-wrap; }
-&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:13pt; font-weight:600;">Running Jobs&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
+         <property name="minimum" >
+          <number>5</number>
          </property>
-         <property name="alignment" >
-          <set>Qt::AlignCenter</set>
+         <property name="maximum" >
+          <number>999</number>
          </property>
         </widget>
-       </item>
-       <item>
-        <widget class="QTableWidget" name="runningTable" />
-       </item>
-      </layout>
+        <widget class="QCheckBox" name="checkBox" >
+         <property name="geometry" >
+          <rect>
+           <x>20</x>
+           <y>20</y>
+           <width>101</width>
+           <height>20</height>
+          </rect>
+         </property>
+         <property name="text" >
+          <string>Do Refresh</string>
+         </property>
+        </widget>
+       </widget>
+      </widget>
      </widget>
      <widget class="QWidget" name="layoutWidget" >
       <layout class="QVBoxLayout" >