]> git.sur5r.net Git - bacula/bacula/commitdiff
Changes to add a status dir page. Still need to add some context sensitive
authorDirk H Bartley <dbartley@schupan.com>
Mon, 11 Feb 2008 03:13:02 +0000 (03:13 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Mon, 11 Feb 2008 03:13:02 +0000 (03:13 +0000)
commands.  Should add a pref for how often to re-populate the tables.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6400 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/bat.pro.in
bacula/src/qt-console/console/console.h
bacula/src/qt-console/main.ui
bacula/src/qt-console/mainwin.cpp
bacula/src/qt-console/mainwin.h
bacula/src/qt-console/pages.h
bacula/src/qt-console/prefs.ui
bacula/src/qt-console/status/dirstat.cpp [new file with mode: 0644]
bacula/src/qt-console/status/dirstat.h [new file with mode: 0644]
bacula/src/qt-console/status/dirstat.ui [new file with mode: 0644]

index acb80cf356047608d7b9c887d9bb306f66dc9cbe..801169a2880d64be3c959c9041f98f981c694f00 100644 (file)
@@ -43,6 +43,7 @@ FORMS += clients/clients.ui storage/storage.ui fileset/fileset.ui
 FORMS += joblog/joblog.ui jobs/jobs.ui
 FORMS += help/help.ui
 FORMS += jobgraphs/jobplotcontrols.ui
 FORMS += joblog/joblog.ui jobs/jobs.ui
 FORMS += help/help.ui
 FORMS += jobgraphs/jobplotcontrols.ui
+FORMS += status/dirstat.ui
 
 # Main directory
 HEADERS += mainwin.h bat.h bat_conf.h qstd.h pages.h
 
 # Main directory
 HEADERS += mainwin.h bat.h bat_conf.h qstd.h pages.h
@@ -124,6 +125,10 @@ SOURCES += jobgraphs/jobplot.cpp
 HEADERS += help/help.h
 SOURCES += help/help.cpp
 
 HEADERS += help/help.h
 SOURCES += help/help.cpp
 
+## Status Dir
+HEADERS += status/dirstat.h
+SOURCES += status/dirstat.cpp
+
 INSTALLS += bins
 INSTALLS += confs
 
 INSTALLS += bins
 INSTALLS += confs
 
index 9c7ca74680679c3aa4d119786099f24623f27b57..a2107dac04abb5223c2c65d2e0118ceef91620d0 100644 (file)
@@ -83,6 +83,7 @@ public:
    bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons, 
           char *buf, int buflen);
    bool is_connected() { return m_sock != NULL; };
    bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons, 
           char *buf, int buflen);
    bool is_connected() { return m_sock != NULL; };
+   bool is_ready() { return is_connected() && m_at_prompt && m_at_main_prompt; };
    bool is_connectedGui();
    bool preventInUseConnect();
    const QFont get_font();
    bool is_connectedGui();
    bool preventInUseConnect();
    const QFont get_font();
index 9688b8ba258b0bfcdbd8193996a3afb6e2da4911..8a127bf6104c8f62ad8ea7db4d91a435fde172b3 100644 (file)
@@ -71,7 +71,7 @@
      <x>0</x>
      <y>0</y>
      <width>882</width>
      <x>0</x>
      <y>0</y>
      <width>882</width>
-     <height>26</height>
+     <height>28</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuEdit" >
     </rect>
    </property>
    <widget class="QMenu" name="menuEdit" >
    </attribute>
    <addaction name="actionConnect" />
    <addaction name="actionStatusDir" />
    </attribute>
    <addaction name="actionConnect" />
    <addaction name="actionStatusDir" />
+   <addaction name="actionStatusDirPage" />
    <addaction name="actionMessages" />
    <addaction name="actionLabel" />
    <addaction name="actionRestore" />
    <addaction name="actionMessages" />
    <addaction name="actionLabel" />
    <addaction name="actionRestore" />
     <string>Status Dir</string>
    </property>
    <property name="toolTip" >
     <string>Status Dir</string>
    </property>
    <property name="toolTip" >
-    <string>Query status of director</string>
+    <string>Query status of director in console</string>
    </property>
    <property name="statusTip" >
    </property>
    <property name="statusTip" >
-    <string>Query status of director</string>
+    <string>Query status of director in console</string>
    </property>
    <property name="autoRepeat" >
     <bool>true</bool>
    </property>
    <property name="autoRepeat" >
     <bool>true</bool>
     <string>Plot Job Files and Bytes</string>
    </property>
   </action>
     <string>Plot Job Files and Bytes</string>
    </property>
   </action>
+  <action name="actionStatusDirPage" >
+   <property name="icon" >
+    <iconset>images/joblog.svg</iconset>
+   </property>
+   <property name="text" >
+    <string>Status Dir Page</string>
+   </property>
+   <property name="toolTip" >
+    <string>Director Status Page</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="main.qrc" />
  </widget>
  <resources>
   <include location="main.qrc" />
index 7add181b43dce2de8752a13800993be5a7350514..c81f286e505cae359c4d501def3911ff68b17fe9 100644 (file)
@@ -50,6 +50,7 @@
 #include "help/help.h"
 #include "jobs/jobs.h"
 #include "jobgraphs/jobplot.h"
 #include "help/help.h"
 #include "jobs/jobs.h"
 #include "jobgraphs/jobplot.h"
+#include "status/dirstat.h"
 
 /* 
  * Daemon message callback
 
 /* 
  * Daemon message callback
@@ -145,10 +146,14 @@ void MainWin::createPages()
       createPageJobList("", "", "", "", NULL);
       JobPlotPass pass;
       pass.use = false;
       createPageJobList("", "", "", "", NULL);
       JobPlotPass pass;
       pass.use = false;
-      new JobPlot(NULL, pass);
+      if (m_openPlot)
+         new JobPlot(NULL, pass);
       new MediaList();
       new Storage();
       new MediaList();
       new Storage();
-      new restoreTree();
+      if (m_openBrowser)
+         new restoreTree();
+      if (m_openDirStat)
+         new DirStat();
 
       treeWidget->expandItem(topItem);
       stackedWidget->setCurrentWidget(m_currentConsole);
 
       treeWidget->expandItem(topItem);
       stackedWidget->setCurrentWidget(m_currentConsole);
@@ -232,6 +237,7 @@ void MainWin::createConnections()
    connect(actionRun, SIGNAL(triggered()), this,  SLOT(runButtonClicked()));
    connect(actionEstimate, SIGNAL(triggered()), this,  SLOT(estimateButtonClicked()));
    connect(actionBrowse, SIGNAL(triggered()), this,  SLOT(browseButtonClicked()));
    connect(actionRun, SIGNAL(triggered()), this,  SLOT(runButtonClicked()));
    connect(actionEstimate, SIGNAL(triggered()), this,  SLOT(estimateButtonClicked()));
    connect(actionBrowse, SIGNAL(triggered()), this,  SLOT(browseButtonClicked()));
+   connect(actionStatusDirPage, SIGNAL(triggered()), this,  SLOT(statusPageButtonClicked()));
    connect(actionJobPlot, SIGNAL(triggered()), this,  SLOT(jobPlotButtonClicked()));
    connect(actionRestore, SIGNAL(triggered()), this,  SLOT(restoreButtonClicked()));
    connect(actionUndock, SIGNAL(triggered()), this,  SLOT(undockWindowButton()));
    connect(actionJobPlot, SIGNAL(triggered()), this,  SLOT(jobPlotButtonClicked()));
    connect(actionRestore, SIGNAL(triggered()), this,  SLOT(restoreButtonClicked()));
    connect(actionUndock, SIGNAL(triggered()), this,  SLOT(undockWindowButton()));
@@ -429,6 +435,22 @@ void MainWin::browseButtonClicked()
    new restoreTree();
 }
 
    new restoreTree();
 }
 
+void MainWin::statusPageButtonClicked()
+{
+   /* if one exists, then just set it current */
+   bool found = false;
+   foreach(Pages *page, m_pagehash) {
+      if (m_currentConsole == page->console()) {
+         if (page->name() == "Director Status") {
+            found = true;
+            page->setCurrent();
+         }
+      }
+   }
+   if (!found)
+      new DirStat();
+}
+
 void MainWin::restoreButtonClicked() 
 {
    new prerestorePage();
 void MainWin::restoreButtonClicked() 
 {
    new prerestorePage();
@@ -640,6 +662,9 @@ void MainWin::setPreferences()
       m_radioConvert = 2;
       prefs.radioConvertStandard->setChecked(Qt::Checked);
    }
       m_radioConvert = 2;
       prefs.radioConvertStandard->setChecked(Qt::Checked);
    }
+   prefs.openPlotCheckBox->setCheckState(m_openPlot ? Qt::Checked : Qt::Unchecked);
+   prefs.openBrowserCheckBox->setCheckState(m_openBrowser ? Qt::Checked : Qt::Unchecked);
+   prefs.openDirStatCheckBox->setCheckState(m_openDirStat ? Qt::Checked : Qt::Unchecked);
    prefs.exec();
 }
 
    prefs.exec();
 }
 
@@ -684,6 +709,9 @@ void prefsDialog::accept()
    } else {
       mainWin->m_radioConvert = 2;
    }
    } else {
       mainWin->m_radioConvert = 2;
    }
+   mainWin->m_openPlot = this->openPlotCheckBox->checkState() == Qt::Checked;
+   mainWin->m_openBrowser = this->openBrowserCheckBox->checkState() == Qt::Checked;
+   mainWin->m_openDirStat = this->openDirStatCheckBox->checkState() == Qt::Checked;
 
    QSettings settings("www.bacula.org", "bat");
    settings.beginGroup("Debug");
 
    QSettings settings("www.bacula.org", "bat");
    settings.beginGroup("Debug");
@@ -706,6 +734,9 @@ void prefsDialog::accept()
    settings.beginGroup("Misc");
    settings.setValue("longList", mainWin->m_longList);
    settings.setValue("byteConvert", mainWin->m_radioConvert);
    settings.beginGroup("Misc");
    settings.setValue("longList", mainWin->m_longList);
    settings.setValue("byteConvert", mainWin->m_radioConvert);
+   settings.setValue("openplot", mainWin->m_openPlot);
+   settings.setValue("openbrowser", mainWin->m_openBrowser);
+   settings.setValue("opendirstat", mainWin->m_openDirStat);
    settings.endGroup();
    settings.beginGroup("RestoreTree");
    settings.setValue("rtPopDirDebug", mainWin->m_rtPopDirDebug);
    settings.endGroup();
    settings.beginGroup("RestoreTree");
    settings.setValue("rtPopDirDebug", mainWin->m_rtPopDirDebug);
@@ -756,6 +787,9 @@ void MainWin::readPreferences()
    settings.beginGroup("Misc");
    m_longList = settings.value("longList", false).toBool();
    m_radioConvert = settings.value("byteConvert", false).toInt();
    settings.beginGroup("Misc");
    m_longList = settings.value("longList", false).toBool();
    m_radioConvert = settings.value("byteConvert", false).toInt();
+   m_openPlot = settings.value("openplot", false).toBool();
+   m_openBrowser = settings.value("openbrowser", false).toBool();
+   m_openDirStat = settings.value("opendirstat", false).toBool();
    settings.endGroup();
    settings.beginGroup("RestoreTree");
    m_rtPopDirDebug = settings.value("rtPopDirDebug", false).toBool();
    settings.endGroup();
    settings.beginGroup("RestoreTree");
    m_rtPopDirDebug = settings.value("rtPopDirDebug", false).toBool();
index 84fc76b5f48b2bcc3fceb8461f1efbf093f73a11..2959afa15f6df27161e947084091307793b000ab 100644 (file)
@@ -99,6 +99,9 @@ public:
    bool m_rtRestore2Debug;
    bool m_rtRestore3Debug;
    int m_radioConvert;
    bool m_rtRestore2Debug;
    bool m_rtRestore3Debug;
    int m_radioConvert;
+   bool m_openBrowser;
+   bool m_openPlot;
+   bool m_openDirStat;
 
 public slots:
    void input_line();
 
 public slots:
    void input_line();
@@ -109,6 +112,7 @@ public slots:
    void runButtonClicked();
    void estimateButtonClicked();
    void browseButtonClicked();
    void runButtonClicked();
    void estimateButtonClicked();
    void browseButtonClicked();
+   void statusPageButtonClicked();
    void jobPlotButtonClicked();
    void restoreButtonClicked();
    void undockWindowButton();
    void jobPlotButtonClicked();
    void restoreButtonClicked();
    void undockWindowButton();
index 49d7ca7494ad70aef7f5d9fe268a97c0035d9ede..f472c0383d32d9d4afee56722dae0351623a3a4a 100644 (file)
@@ -71,6 +71,7 @@ public:
    void setTreeWidgetItemDockColor();
    void consoleCommand(QString &);
    void consoleInput(QString &);
    void setTreeWidgetItemDockColor();
    void consoleCommand(QString &);
    void consoleInput(QString &);
+   QString &name() { return m_name; };
 
 public slots:
    /* closeEvent is a virtual function inherited from QWidget */
 
 public slots:
    /* closeEvent is a virtual function inherited from QWidget */
index cc4d8fb3612a3c0c4330c7843946a15519225b8d..0079fd3e97d7eaebe03044c1abd0551aa6a72c2f 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>361</width>
-    <height>452</height>
+    <width>360</width>
+    <height>485</height>
    </rect>
   </property>
   <property name="sizePolicy" >
    </rect>
   </property>
   <property name="sizePolicy" >
       <attribute name="title" >
        <string>Misc</string>
       </attribute>
       <attribute name="title" >
        <string>Misc</string>
       </attribute>
+      <widget class="QGroupBox" name="groupBox_6" >
+       <property name="geometry" >
+        <rect>
+         <x>30</x>
+         <y>220</y>
+         <width>271</width>
+         <height>111</height>
+        </rect>
+       </property>
+       <property name="title" >
+        <string>Convert</string>
+       </property>
+       <widget class="QRadioButton" name="radioConvertOff" >
+        <property name="geometry" >
+         <rect>
+          <x>20</x>
+          <y>20</y>
+          <width>231</width>
+          <height>22</height>
+         </rect>
+        </property>
+        <property name="text" >
+         <string>Convert Off</string>
+        </property>
+       </widget>
+       <widget class="QRadioButton" name="radioConvertIEC" >
+        <property name="geometry" >
+         <rect>
+          <x>20</x>
+          <y>50</y>
+          <width>231</width>
+          <height>22</height>
+         </rect>
+        </property>
+        <property name="text" >
+         <string>Convert Bytes with IEC 1000B = KB</string>
+        </property>
+       </widget>
+       <widget class="QRadioButton" name="radioConvertStandard" >
+        <property name="geometry" >
+         <rect>
+          <x>20</x>
+          <y>80</y>
+          <width>231</width>
+          <height>22</height>
+         </rect>
+        </property>
+        <property name="text" >
+         <string>Convert Bytes with 1024B = KB</string>
+        </property>
+       </widget>
+      </widget>
       <widget class="QGroupBox" name="groupBox_4" >
        <property name="geometry" >
         <rect>
       <widget class="QGroupBox" name="groupBox_4" >
        <property name="geometry" >
         <rect>
-         <x>40</x>
-         <y>40</y>
+         <x>30</x>
+         <y>10</y>
          <width>190</width>
          <height>55</height>
         </rect>
          <width>190</width>
          <height>55</height>
         </rect>
         </item>
        </layout>
       </widget>
         </item>
        </layout>
       </widget>
-      <widget class="QGroupBox" name="groupBox_6" >
+      <widget class="QGroupBox" name="groupBox_7" >
        <property name="geometry" >
         <rect>
        <property name="geometry" >
         <rect>
-         <x>40</x>
-         <y>160</y>
-         <width>261</width>
-         <height>131</height>
+         <x>30</x>
+         <y>80</y>
+         <width>271</width>
+         <height>121</height>
         </rect>
        </property>
        <property name="title" >
         </rect>
        </property>
        <property name="title" >
-        <string>Convert</string>
+        <string>GroupBox</string>
        </property>
        </property>
-       <widget class="QRadioButton" name="radioConvertOff" >
+       <widget class="QCheckBox" name="openPlotCheckBox" >
         <property name="geometry" >
          <rect>
         <property name="geometry" >
          <rect>
-          <x>20</x>
-          <y>20</y>
-          <width>231</width>
-          <height>22</height>
+          <x>10</x>
+          <y>30</y>
+          <width>241</width>
+          <height>20</height>
          </rect>
         </property>
         <property name="text" >
          </rect>
         </property>
         <property name="text" >
-         <string>Convert Off</string>
+         <string>Open Plot page on startup</string>
         </property>
        </widget>
         </property>
        </widget>
-       <widget class="QRadioButton" name="radioConvertIEC" >
+       <widget class="QCheckBox" name="openBrowserCheckBox" >
         <property name="geometry" >
          <rect>
         <property name="geometry" >
          <rect>
-          <x>20</x>
+          <x>10</x>
           <y>60</y>
           <y>60</y>
-          <width>231</width>
-          <height>22</height>
+          <width>241</width>
+          <height>20</height>
          </rect>
         </property>
         <property name="text" >
          </rect>
         </property>
         <property name="text" >
-         <string>Convert Bytes with IEC 1000B = KB</string>
+         <string>Open Browser page on startup</string>
         </property>
        </widget>
         </property>
        </widget>
-       <widget class="QRadioButton" name="radioConvertStandard" >
+       <widget class="QCheckBox" name="openDirStatCheckBox" >
         <property name="geometry" >
          <rect>
         <property name="geometry" >
          <rect>
-          <x>20</x>
-          <y>100</y>
-          <width>231</width>
-          <height>22</height>
+          <x>10</x>
+          <y>90</y>
+          <width>241</width>
+          <height>20</height>
          </rect>
         </property>
         <property name="text" >
          </rect>
         </property>
         <property name="text" >
-         <string>Convert Bytes with 1024B = KB</string>
+         <string>Open Director Status page on startup</string>
         </property>
        </widget>
       </widget>
         </property>
        </widget>
       </widget>
diff --git a/bacula/src/qt-console/status/dirstat.cpp b/bacula/src/qt-console/status/dirstat.cpp
new file mode 100644 (file)
index 0000000..beac7fe
--- /dev/null
@@ -0,0 +1,318 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
+
+   The main author of Bacula is Kern Sibbald, with contributions from
+   many others, a complete list can be found in the file AUTHORS.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
+/*
+ *   Version $Id: dirstat.cpp 5880 2007-11-09 01:20:40Z bartleyd2 $
+ *
+ *   Dirk Bartley, March 2007
+ */
+#include <QAbstractEventDispatcher>
+#include <QTableWidgetItem>
+#include "bat.h"
+#include "dirstat.h"
+
+/*
+ * Constructor for the class
+ */
+DirStat::DirStat()
+{
+   setupUi(this);
+   m_name = "Director Status";
+   m_closeable = true;
+   pgInitialize();
+   QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
+   thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/joblog.png")));
+   m_cursor = new QTextCursor(textEdit->document());
+
+   readSettings();
+   dockPage();
+   m_timer = new QTimer(this);
+   QWidget::connect(m_timer, SIGNAL(timeout()), this, SLOT(timerTriggered()));
+   //m_timer->start(mainWin->m_checkMessagesInterval*1000);
+   m_timer->start(10*1000);
+}
+
+void DirStat::getFont()
+{
+   QFont font = textEdit->font();
+
+   QString dirname;
+   m_console->getDirResName(dirname);
+   QSettings settings(dirname, "bat");
+   settings.beginGroup("Console");
+   font.setFamily(settings.value("consoleFont", "Courier").value<QString>());
+   font.setPointSize(settings.value("consolePointSize", 10).toInt());
+   font.setFixedPitch(settings.value("consoleFixedPitch", true).toBool());
+   settings.endGroup();
+   textEdit->setFont(font);
+}
+
+/*
+ * Write the m_splitter settings in the destructor
+ */
+DirStat::~DirStat()
+{
+   writeSettings();
+}
+
+/*
+ * Populate all tables and header widgets
+ */
+void DirStat::populateAll()
+{
+   if (!m_console->preventInUseConnect())
+       return;
+   populateHeader();
+   populateTerminated();
+   populateScheduled();
+   populateRunning();
+}
+
+/*
+ *  Timer is triggered, see if is current and repopulate.
+ */
+void DirStat::timerTriggered()
+{
+   bool iscurrent = mainWin->stackedWidget->currentIndex() == mainWin->stackedWidget->indexOf(this);
+   if ((isDocked() && iscurrent) || (!isDocked())) {
+      if (m_console->is_ready())
+         populateAll();
+   }
+}
+
+/*
+ * Populate header text widget
+ */
+void DirStat::populateHeader()
+{
+   QString command = QString(".status dir header");
+   QStringList results;
+   textEdit->clear();
+
+   if (m_console->dir_cmd(command, results)) {
+      foreach (QString line, results) {
+         line += "\n";
+         textEdit->insertPlainText(line);
+      }
+   }
+}
+
+/*
+ * Populate teminated table
+ */
+void DirStat::populateTerminated()
+{
+   QString command = QString(".status dir terminated");
+   QStringList results;
+   QBrush blackBrush(Qt::black);
+
+   terminatedTable->clear();
+   QStringList headerlist = (QStringList()
+      << "Job Id" << "Job Level" << "Job Files" << "Job Bytes" << "Job Status"
+      << "Job Time" << "Job Name");
+   QStringList flaglist = (QStringList()
+      << "R" << "L" << "R" << "R" << "LC" 
+      << "L" << "L");
+
+   terminatedTable->setColumnCount(headerlist.size());
+   terminatedTable->setHorizontalHeaderLabels(headerlist);
+
+   if (m_console->dir_cmd(command, results)) {
+      int row = 0;
+      QTableWidgetItem* p_tableitem;
+      terminatedTable->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);
+            if (flaglist[column].contains("R"))
+               p_tableitem->setTextAlignment(Qt::AlignRight);
+            if (flaglist[column].contains("C"))
+               if (field == "OK")
+                  p_tableitem->setBackground(Qt::green);
+               else
+                  p_tableitem->setBackground(Qt::red);
+            terminatedTable->setItem(row, column, p_tableitem);
+            column += 1;
+         }
+         row += 1;
+      }
+   }
+   terminatedTable->resizeColumnsToContents();
+   terminatedTable->resizeRowsToContents();
+   terminatedTable->verticalHeader()->hide();
+}
+
+/*
+ * Populate scheduled table
+ */
+void DirStat::populateScheduled()
+{
+   QString command = QString(".status dir scheduled");
+   QStringList results;
+   QBrush blackBrush(Qt::black);
+
+   scheduledTable->clear();
+   QStringList headerlist = (QStringList()
+      << "Job Level" << "Job Type" << "Priority" << "Job Time" << "Job Name" << "Volume");
+   QStringList flaglist = (QStringList()
+      << "L" << "L" << "R" << "L" << "L" << "L");
+
+   scheduledTable->setColumnCount(headerlist.size());
+   scheduledTable->setHorizontalHeaderLabels(headerlist);
+
+   if (m_console->dir_cmd(command, results)) {
+      int row = 0;
+      QTableWidgetItem* p_tableitem;
+      scheduledTable->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);
+            scheduledTable->setItem(row, column, p_tableitem);
+            column += 1;
+         }
+         row += 1;
+      }
+   }
+   scheduledTable->resizeColumnsToContents();
+   scheduledTable->resizeRowsToContents();
+   scheduledTable->verticalHeader()->hide();
+}
+
+/*
+ * Populate running table
+ */
+void DirStat::populateRunning()
+{
+   QString command = QString(".status dir running");
+   QStringList results;
+   QBrush blackBrush(Qt::black);
+
+   runningTable->clear();
+   QStringList headerlist = (QStringList()
+      << "Job Id" << "Job Level" << "Job Data" << "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.
+ */
+void DirStat::PgSeltreeWidgetClicked()
+{
+   if (!m_populated) {
+      populateAll();
+      m_populated=true;
+   }
+}
+
+/*
+ *  Virtual function override of pages function which is called when this page
+ *  is visible on the stack
+ */
+void DirStat::currentStackItem()
+{
+   populateAll();
+   if (!m_populated) {
+      m_populated=true;
+   }
+}
+
+/*
+ * Function to create connections for context sensitive menu for this and
+ * the page selector
+ */
+void DirStat::createConnections()
+{
+}
+
+/*
+ * Save user settings associated with this page
+ */
+void DirStat::writeSettings()
+{
+   QSettings settings(m_console->m_dir->name(), "bat");
+   settings.beginGroup(m_groupText);
+   settings.setValue(m_splitText, splitter->saveState());
+   settings.endGroup();
+}
+
+/*
+ * Read and restore user settings associated with this page
+ */
+void DirStat::readSettings()
+{
+   m_groupText = "DirStatPage";
+   m_splitText = "splitterSizes_0";
+   QSettings settings(m_console->m_dir->name(), "bat");
+   settings.beginGroup(m_groupText);
+   splitter->restoreState(settings.value(m_splitText).toByteArray());
+   settings.endGroup();
+}
diff --git a/bacula/src/qt-console/status/dirstat.h b/bacula/src/qt-console/status/dirstat.h
new file mode 100644 (file)
index 0000000..cb4c235
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef _DIRSTAT_H_
+#define _DIRSTAT_H_
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
+
+   The main author of Bacula is Kern Sibbald, with contributions from
+   many others, a complete list can be found in the file AUTHORS.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
+/*
+ *   Version $Id: dirstat.h 5372 2007-08-17 12:17:04Z kerns $
+ *
+ *   Dirk Bartley, March 2007
+ */
+
+#include <QtGui>
+#include "ui_dirstat.h"
+#include "console.h"
+#include "pages.h"
+
+class DirStat : public Pages, public Ui::DirStatForm
+{
+   Q_OBJECT 
+
+public:
+   DirStat();
+   ~DirStat();
+   virtual void PgSeltreeWidgetClicked();
+   virtual void currentStackItem();
+
+public slots:
+   void populateHeader();
+   void populateTerminated();
+   void populateScheduled();
+   void populateRunning();
+//   virtual void treeWidgetName(QString &);
+   void populateAll();
+
+private slots:
+   void timerTriggered();
+
+private:
+   void createConnections();
+   void writeSettings();
+   void readSettings();
+   bool m_populated;
+   QTextCursor *m_cursor;
+   void getFont();
+   QString m_groupText, m_splitText;
+   QTimer * m_timer;
+};
+
+#endif /* _DIRSTAT_H_ */
diff --git a/bacula/src/qt-console/status/dirstat.ui b/bacula/src/qt-console/status/dirstat.ui
new file mode 100644 (file)
index 0000000..c172702
--- /dev/null
@@ -0,0 +1,183 @@
+<ui version="4.0" >
+ <class>DirStatForm</class>
+ <widget class="QWidget" name="DirStatForm" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>537</width>
+    <height>458</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item row="0" column="0" >
+    <widget class="QSplitter" name="splitter" >
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <widget class="QTextEdit" name="textEdit" >
+      <property name="sizePolicy" >
+       <sizepolicy>
+        <hsizetype>7</hsizetype>
+        <vsizetype>7</vsizetype>
+        <horstretch>200</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="minimumSize" >
+       <size>
+        <width>0</width>
+        <height>0</height>
+       </size>
+      </property>
+      <property name="maximumSize" >
+       <size>
+        <width>16777215</width>
+        <height>100</height>
+       </size>
+      </property>
+      <property name="sizeIncrement" >
+       <size>
+        <width>1</width>
+        <height>0</height>
+       </size>
+      </property>
+      <property name="focusPolicy" >
+       <enum>Qt::StrongFocus</enum>
+      </property>
+      <property name="acceptDrops" >
+       <bool>false</bool>
+      </property>
+      <property name="toolTip" >
+       <string comment="Joblog Window" />
+      </property>
+      <property name="statusTip" >
+       <string comment="Joblog Window" />
+      </property>
+      <property name="whatsThis" >
+       <string comment="Joblog Window" />
+      </property>
+      <property name="horizontalScrollBarPolicy" >
+       <enum>Qt::ScrollBarAsNeeded</enum>
+      </property>
+      <property name="autoFormatting" >
+       <set>QTextEdit::AutoNone</set>
+      </property>
+      <property name="tabChangesFocus" >
+       <bool>false</bool>
+      </property>
+      <property name="documentTitle" >
+       <string comment="Joblog Window" />
+      </property>
+      <property name="lineWrapMode" >
+       <enum>QTextEdit::NoWrap</enum>
+      </property>
+      <property name="readOnly" >
+       <bool>true</bool>
+      </property>
+     </widget>
+     <widget class="QWidget" name="" >
+      <layout class="QVBoxLayout" >
+       <property name="margin" >
+        <number>0</number>
+       </property>
+       <property name="spacing" >
+        <number>6</number>
+       </property>
+       <item>
+        <widget class="QLabel" name="scheduledLabel" >
+         <property name="layoutDirection" >
+          <enum>Qt::LeftToRight</enum>
+         </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;">Scheduled Jobs&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
+         </property>
+         <property name="alignment" >
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QTableWidget" name="scheduledTable" />
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="layoutWidget_2" >
+      <layout class="QVBoxLayout" >
+       <property name="margin" >
+        <number>0</number>
+       </property>
+       <property name="spacing" >
+        <number>6</number>
+       </property>
+       <item>
+        <widget class="QLabel" name="runningLabel" >
+         <property name="layoutDirection" >
+          <enum>Qt::LeftToRight</enum>
+         </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>
+         <property name="alignment" >
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QTableWidget" name="runningTable" />
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="layoutWidget" >
+      <layout class="QVBoxLayout" >
+       <property name="margin" >
+        <number>0</number>
+       </property>
+       <property name="spacing" >
+        <number>6</number>
+       </property>
+       <item>
+        <widget class="QLabel" name="terminatedLabel" >
+         <property name="layoutDirection" >
+          <enum>Qt::LeftToRight</enum>
+         </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;">Terminated Jobs&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
+         </property>
+         <property name="alignment" >
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QTableWidget" name="terminatedTable" />
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources>
+  <include location="../main.qrc" />
+ </resources>
+ <connections/>
+</ui>