[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bacula-devel] patch: more formatting for bat


Hello,
this patch contains the following changes:

- fileset, clients and jobs pages reformatted to use the new field type
and enable column sorting
- job type and job level fields now use job_type_to_str() and
job_level_to_str() to convert single char codes to readable strings.
- several changes to ease translation
- other changes to improve consistency

BTW, job_level_to_str() is missing a break after the L_BASE entry
(lib/util.c line 341). Is something done because base jobs aren't really
implemented ?

Greetings,
Riccardo

Index: bacula/src/qt-console/pages.cpp
===================================================================
--- bacula/src/qt-console/pages.cpp	(revision 6999)
+++ bacula/src/qt-console/pages.cpp	(working copy)
@@ -258,11 +258,10 @@
  */
 void Pages::setTitle()
 {
-   QString title, director;
-   treeWidgetName(title);
+   QString wdgname, director;
+   treeWidgetName(wdgname);
    m_console->getDirResName(director);
-   title += tr(" of Director ");
-   title += director;
+   QString title = tr("%1 of Director %2").arg(wdgname).arg(director);
    setWindowTitle(title);
 }
 
@@ -289,13 +288,12 @@
 void Pages::setContextMenuDockText()
 {
    QTreeWidgetItem *item = mainWin->getFromHash(this);
-   QString docktext("");
+   QString docktext;
    if (isDocked()) {
-       docktext += tr("UnDock ");
+      docktext = tr("UnDock %1 Window").arg(item->text(0));
    } else {
-       docktext += tr("ReDock ");
+      docktext = tr("ReDock %1 Window").arg(item->text(0));
    }
-   docktext += item->text(0) += tr(" Window");
       
    mainWin->actionToggleDock->setText(docktext);
    setTreeWidgetItemDockColor();
@@ -309,7 +307,7 @@
 {
    QTreeWidgetItem* item = mainWin->getFromHash(this);
    if (item) {
-      if (item->text(0) != "Console") {
+      if (item->text(0) != tr("Console")) {
          if (isDocked()) {
          /* Set the brush to blue if undocked */
             QBrush blackBrush(Qt::black);
Index: bacula/src/qt-console/prefs.ui
===================================================================
--- bacula/src/qt-console/prefs.ui	(revision 6999)
+++ bacula/src/qt-console/prefs.ui	(working copy)
@@ -10,9 +10,7 @@
    </rect>
   </property>
   <property name="sizePolicy" >
-   <sizepolicy>
-    <hsizetype>0</hsizetype>
-    <vsizetype>0</vsizetype>
+   <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
     <horstretch>0</horstretch>
     <verstretch>0</verstretch>
    </sizepolicy>
@@ -24,16 +22,28 @@
    <iconset>images/bat.png</iconset>
   </property>
   <layout class="QGridLayout" >
-   <property name="margin" >
+   <property name="leftMargin" >
     <number>9</number>
    </property>
-   <property name="spacing" >
+   <property name="topMargin" >
+    <number>9</number>
+   </property>
+   <property name="rightMargin" >
+    <number>9</number>
+   </property>
+   <property name="bottomMargin" >
+    <number>9</number>
+   </property>
+   <property name="horizontalSpacing" >
     <number>6</number>
    </property>
+   <property name="verticalSpacing" >
+    <number>6</number>
+   </property>
    <item row="1" column="0" >
     <widget class="QTabWidget" name="tabWidget" >
      <property name="currentIndex" >
-      <number>0</number>
+      <number>2</number>
      </property>
      <widget class="QWidget" name="tab" >
       <attribute name="title" >
@@ -49,9 +59,7 @@
         </rect>
        </property>
        <property name="sizePolicy" >
-        <sizepolicy>
-         <hsizetype>0</hsizetype>
-         <vsizetype>0</vsizetype>
+        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
@@ -109,9 +117,7 @@
         </rect>
        </property>
        <property name="sizePolicy" >
-        <sizepolicy>
-         <hsizetype>0</hsizetype>
-         <vsizetype>0</vsizetype>
+        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
@@ -154,12 +160,12 @@
           <height>24</height>
          </rect>
         </property>
+        <property name="minimum" >
+         <number>15</number>
+        </property>
         <property name="maximum" >
          <number>3600</number>
         </property>
-        <property name="minimum" >
-         <number>15</number>
-        </property>
        </widget>
       </widget>
      </widget>
@@ -168,18 +174,28 @@
        <string>Joblist</string>
       </attribute>
       <layout class="QGridLayout" >
-       <property name="margin" >
+       <property name="leftMargin" >
         <number>9</number>
        </property>
-       <property name="spacing" >
+       <property name="topMargin" >
+        <number>9</number>
+       </property>
+       <property name="rightMargin" >
+        <number>9</number>
+       </property>
+       <property name="bottomMargin" >
+        <number>9</number>
+       </property>
+       <property name="horizontalSpacing" >
         <number>6</number>
        </property>
+       <property name="verticalSpacing" >
+        <number>6</number>
+       </property>
        <item row="0" column="0" >
         <widget class="QGroupBox" name="groupBox_2" >
          <property name="sizePolicy" >
-          <sizepolicy>
-           <hsizetype>0</hsizetype>
-           <vsizetype>0</vsizetype>
+          <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
@@ -188,20 +204,44 @@
           <string>Jolist Limit Options</string>
          </property>
          <layout class="QGridLayout" >
-          <property name="margin" >
+          <property name="leftMargin" >
            <number>9</number>
           </property>
-          <property name="spacing" >
+          <property name="topMargin" >
+           <number>9</number>
+          </property>
+          <property name="rightMargin" >
+           <number>9</number>
+          </property>
+          <property name="bottomMargin" >
+           <number>9</number>
+          </property>
+          <property name="horizontalSpacing" >
            <number>6</number>
           </property>
+          <property name="verticalSpacing" >
+           <number>6</number>
+          </property>
           <item row="0" column="0" >
            <layout class="QGridLayout" >
-            <property name="margin" >
+            <property name="leftMargin" >
              <number>0</number>
             </property>
-            <property name="spacing" >
+            <property name="topMargin" >
+             <number>0</number>
+            </property>
+            <property name="rightMargin" >
+             <number>0</number>
+            </property>
+            <property name="bottomMargin" >
+             <number>0</number>
+            </property>
+            <property name="horizontalSpacing" >
              <number>6</number>
             </property>
+            <property name="verticalSpacing" >
+             <number>6</number>
+            </property>
             <item row="2" column="0" >
              <widget class="QCheckBox" name="daysLimit" >
               <property name="text" >
@@ -211,12 +251,12 @@
             </item>
             <item row="3" column="0" >
              <widget class="QSpinBox" name="daysSpinBox" >
+              <property name="minimum" >
+               <number>1</number>
+              </property>
               <property name="maximum" >
                <number>10000</number>
               </property>
-              <property name="minimum" >
-               <number>1</number>
-              </property>
               <property name="singleStep" >
                <number>7</number>
               </property>
@@ -224,12 +264,12 @@
             </item>
             <item row="1" column="0" >
              <widget class="QSpinBox" name="recordSpinBox" >
+              <property name="minimum" >
+               <number>1</number>
+              </property>
               <property name="maximum" >
                <number>10000</number>
               </property>
-              <property name="minimum" >
-               <number>1</number>
-              </property>
               <property name="singleStep" >
                <number>25</number>
               </property>
@@ -288,7 +328,7 @@
          </rect>
         </property>
         <property name="text" >
-         <string>Convert Bytes with IEC 1000B = KB</string>
+         <string>Display Bytes using IEC units (1024B = 1 KiB)</string>
         </property>
        </widget>
        <widget class="QRadioButton" name="radioConvertStandard" >
@@ -301,7 +341,7 @@
          </rect>
         </property>
         <property name="text" >
-         <string>Convert Bytes with 1024B = KB</string>
+         <string>Display Bytes using SI units (1000B = 1KB)</string>
         </property>
        </widget>
       </widget>
@@ -318,12 +358,24 @@
         <string>Context Sensitive List Commands</string>
        </property>
        <layout class="QGridLayout" >
-        <property name="margin" >
+        <property name="leftMargin" >
          <number>9</number>
         </property>
-        <property name="spacing" >
+        <property name="topMargin" >
+         <number>9</number>
+        </property>
+        <property name="rightMargin" >
+         <number>9</number>
+        </property>
+        <property name="bottomMargin" >
+         <number>9</number>
+        </property>
+        <property name="horizontalSpacing" >
          <number>6</number>
         </property>
+        <property name="verticalSpacing" >
+         <number>6</number>
+        </property>
         <item row="0" column="0" >
          <widget class="QCheckBox" name="executeLongCheckBox" >
           <property name="text" >
@@ -391,18 +443,28 @@
        <string>Debug</string>
       </attribute>
       <layout class="QGridLayout" >
-       <property name="margin" >
+       <property name="leftMargin" >
         <number>9</number>
        </property>
-       <property name="spacing" >
+       <property name="topMargin" >
+        <number>9</number>
+       </property>
+       <property name="rightMargin" >
+        <number>9</number>
+       </property>
+       <property name="bottomMargin" >
+        <number>9</number>
+       </property>
+       <property name="horizontalSpacing" >
         <number>6</number>
        </property>
+       <property name="verticalSpacing" >
+        <number>6</number>
+       </property>
        <item row="0" column="0" >
         <widget class="QGroupBox" name="groupBox_3" >
          <property name="sizePolicy" >
-          <sizepolicy>
-           <hsizetype>0</hsizetype>
-           <vsizetype>0</vsizetype>
+          <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
@@ -411,20 +473,44 @@
           <string>Debugging Options</string>
          </property>
          <layout class="QGridLayout" >
-          <property name="margin" >
+          <property name="leftMargin" >
            <number>9</number>
           </property>
-          <property name="spacing" >
+          <property name="topMargin" >
+           <number>9</number>
+          </property>
+          <property name="rightMargin" >
+           <number>9</number>
+          </property>
+          <property name="bottomMargin" >
+           <number>9</number>
+          </property>
+          <property name="horizontalSpacing" >
            <number>6</number>
           </property>
+          <property name="verticalSpacing" >
+           <number>6</number>
+          </property>
           <item row="0" column="0" >
            <layout class="QGridLayout" >
-            <property name="margin" >
+            <property name="leftMargin" >
              <number>0</number>
             </property>
-            <property name="spacing" >
+            <property name="topMargin" >
+             <number>0</number>
+            </property>
+            <property name="rightMargin" >
+             <number>0</number>
+            </property>
+            <property name="bottomMargin" >
+             <number>0</number>
+            </property>
+            <property name="horizontalSpacing" >
              <number>6</number>
             </property>
+            <property name="verticalSpacing" >
+             <number>6</number>
+            </property>
             <item row="0" column="0" >
              <widget class="QCheckBox" name="commDebug" >
               <property name="text" >
@@ -472,18 +558,28 @@
        <string>RestoreTree</string>
       </attribute>
       <layout class="QGridLayout" >
-       <property name="margin" >
+       <property name="leftMargin" >
         <number>9</number>
        </property>
-       <property name="spacing" >
+       <property name="topMargin" >
+        <number>9</number>
+       </property>
+       <property name="rightMargin" >
+        <number>9</number>
+       </property>
+       <property name="bottomMargin" >
+        <number>9</number>
+       </property>
+       <property name="horizontalSpacing" >
         <number>6</number>
        </property>
+       <property name="verticalSpacing" >
+        <number>6</number>
+       </property>
        <item row="0" column="0" >
         <widget class="QGroupBox" name="groupBox_5" >
          <property name="sizePolicy" >
-          <sizepolicy>
-           <hsizetype>0</hsizetype>
-           <vsizetype>0</vsizetype>
+          <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
@@ -492,20 +588,44 @@
           <string>Debugging Options</string>
          </property>
          <layout class="QGridLayout" >
-          <property name="margin" >
+          <property name="leftMargin" >
            <number>9</number>
           </property>
-          <property name="spacing" >
+          <property name="topMargin" >
+           <number>9</number>
+          </property>
+          <property name="rightMargin" >
+           <number>9</number>
+          </property>
+          <property name="bottomMargin" >
+           <number>9</number>
+          </property>
+          <property name="horizontalSpacing" >
            <number>6</number>
           </property>
+          <property name="verticalSpacing" >
+           <number>6</number>
+          </property>
           <item row="0" column="0" >
            <layout class="QGridLayout" >
-            <property name="margin" >
+            <property name="leftMargin" >
              <number>0</number>
             </property>
-            <property name="spacing" >
+            <property name="topMargin" >
+             <number>0</number>
+            </property>
+            <property name="rightMargin" >
+             <number>0</number>
+            </property>
+            <property name="bottomMargin" >
+             <number>0</number>
+            </property>
+            <property name="horizontalSpacing" >
              <number>6</number>
             </property>
+            <property name="verticalSpacing" >
+             <number>6</number>
+            </property>
             <item row="10" column="0" >
              <widget class="QCheckBox" name="rtRestore2CheckBox" >
               <property name="text" >
@@ -611,12 +731,21 @@
    </item>
    <item row="0" column="0" >
     <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
-     </property>
      <property name="spacing" >
       <number>6</number>
      </property>
+     <property name="leftMargin" >
+      <number>0</number>
+     </property>
+     <property name="topMargin" >
+      <number>0</number>
+     </property>
+     <property name="rightMargin" >
+      <number>0</number>
+     </property>
+     <property name="bottomMargin" >
+      <number>0</number>
+     </property>
      <item>
       <spacer>
        <property name="orientation" >
@@ -633,9 +762,7 @@
      <item>
       <widget class="QLabel" name="headingLabel" >
        <property name="sizePolicy" >
-        <sizepolicy>
-         <hsizetype>0</hsizetype>
-         <vsizetype>0</vsizetype>
+        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
Index: bacula/src/qt-console/fileset/fileset.cpp
===================================================================
--- bacula/src/qt-console/fileset/fileset.cpp	(revision 6999)
+++ bacula/src/qt-console/fileset/fileset.cpp	(working copy)
@@ -39,6 +39,7 @@
 #include <QMenu>
 #include "bat.h"
 #include "fileset/fileset.h"
+#include "util/fmtwidgetitem.h"
 
 FileSet::FileSet()
 {
@@ -70,7 +71,6 @@
  */
 void FileSet::populateTable()
 {
-   QTableWidgetItem *tableItem;
    QBrush blackBrush(Qt::black);
 
    if (!m_console->preventInUseConnect())
@@ -85,8 +85,12 @@
 
    tableWidget->setColumnCount(headerlist.count());
    tableWidget->setHorizontalHeaderLabels(headerlist);
+   tableWidget->horizontalHeader()->setHighlightSections(false);
    tableWidget->setRowCount(m_console->fileset_list.count());
    tableWidget->verticalHeader()->hide();
+   tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
+   tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+   tableWidget->setSortingEnabled(false); /* rows move on insert if sorting enabled */
    int row = 0;
 
    foreach(QString filesetName, m_console->fileset_list) {
@@ -106,31 +110,36 @@
       if (m_console->sql_cmd(query, results)) {
          int resultCount = results.count();
          if (resultCount) {
-            QString resultline;
-            QString field;
-            QStringList fieldlist;
             /* only use the last one */
-            resultline = results[resultCount - 1];
-            fieldlist = resultline.split("\t");
-            int column = 0;
-            /* Iterate through fields in the record */
-            foreach (field, fieldlist) {
-               field = field.trimmed();  /* strip leading & trailing spaces */
-               tableItem = new QTableWidgetItem(field, 1);
-               tableItem->setFlags(Qt::ItemIsSelectable);
-               tableItem->setForeground(blackBrush);
-               tableItem->setData(Qt::UserRole, 1);
-               tableWidget->setItem(row, column, tableItem);
-               column++;
-            }
+            QString resultline = results[resultCount - 1];
+            QStringList fieldlist = resultline.split("\t");
+
+	    TableItemFormatter item(*tableWidget, row);
+  
+	    /* Iterate through fields in the record */
+	    QStringListIterator fld(fieldlist);
+	    int col = 0;
+
+	    /* name */
+	    item.setTextFld(col++, fld.next());
+
+	    /* id */
+	    item.setNumericFld(col++, fld.next());
+
+	    /* creation time */
+	    item.setTextFld(col++, fld.next());
+
          }
       }
       row++;
    }
-   /* Resize the columns */
-   for (int cnter=0; cnter<headerlist.size(); cnter++) {
-      tableWidget->resizeColumnToContents(cnter);
-   }
+   /* set default sorting */
+   tableWidget->sortByColumn(headerlist.indexOf(tr("Create Time")), Qt::DescendingOrder);
+   tableWidget->setSortingEnabled(true);
+   
+   /* Resize rows and columns */
+   tableWidget->resizeColumnsToContents();
+   tableWidget->resizeRowsToContents();
 }
 
 /*
Index: bacula/src/qt-console/clients/clients.cpp
===================================================================
--- bacula/src/qt-console/clients/clients.cpp	(revision 6999)
+++ bacula/src/qt-console/clients/clients.cpp	(working copy)
@@ -41,6 +41,7 @@
 #include "clients/clients.h"
 #include "run/run.h"
 #include "status/clientstat.h"
+#include "util/fmtwidgetitem.h"
 
 Clients::Clients()
 {
@@ -71,22 +72,33 @@
  */
 void Clients::populateTable()
 {
-   QTableWidgetItem *tableItem;
    QBrush blackBrush(Qt::black);
 
    if (!m_console->preventInUseConnect())
       return;
+
+   QStringList headerlist = (QStringList() << tr("Client Name") << tr("File Retention")
+       << tr("Job Retention") << tr("AutoPrune") << tr("ClientId") << tr("Uname") );
+
+   int sortcol = headerlist.indexOf(tr("Client Name"));
+   Qt::SortOrder sortord = Qt::AscendingOrder;
+   if (tableWidget->rowCount()) {
+      sortcol = tableWidget->horizontalHeader()->sortIndicatorSection();
+      sortord = tableWidget->horizontalHeader()->sortIndicatorOrder();
+   }
+
    m_checkcurwidget = false;
    tableWidget->clear();
    m_checkcurwidget = true;
 
-   QStringList headerlist = (QStringList() << tr("Client Name") << tr("File Retention")
-       << tr("Job Retention") << tr("AutoPrune") << tr("ClientId") << tr("Uname") );
-
    tableWidget->setColumnCount(headerlist.count());
    tableWidget->setHorizontalHeaderLabels(headerlist);
+   tableWidget->horizontalHeader()->setHighlightSections(false);
    tableWidget->setRowCount(m_console->client_list.count());
    tableWidget->verticalHeader()->hide();
+   tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
+   tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+   tableWidget->setSortingEnabled(false); /* rows move on insert if sorting enabled */
    int row = 0;
 
    foreach (QString clientName, m_console->client_list){
@@ -106,31 +118,45 @@
       if (m_console->sql_cmd(query, results)) {
          int resultCount = results.count();
          if (resultCount){
-            QString resultline;
-            QString field;
-            QStringList fieldlist;
-            resultline = results[resultCount - 1];
-            fieldlist = resultline.split("\t");
+            /* only use the last one */
+            QString resultline = results[resultCount - 1];
+            QStringList fieldlist = resultline.split("\t");
 
-            int column = 0;
-            /* Iterate through fields in the record */
-            foreach (field, fieldlist) {
-               field = field.trimmed();  /* strip leading & trailing spaces */
-               tableItem = new QTableWidgetItem(field, 1);
-               tableItem->setFlags(Qt::ItemIsSelectable);
-               tableItem->setForeground(blackBrush);
-               tableItem->setData(Qt::UserRole, 1);
-               tableWidget->setItem(row, column, tableItem);
-               column++;
-            }
+	    TableItemFormatter item(*tableWidget, row);
+
+	    /* Iterate through fields in the record */
+	    QStringListIterator fld(fieldlist);
+	    int col = 0;
+
+	    /* name */
+	    item.setTextFld(col++, fld.next());
+
+	    /* file retention */
+	    item.setDurationFld(col++, fld.next());
+
+	    /* job retention */
+	    item.setDurationFld(col++, fld.next());
+
+	    /* autoprune */
+	    item.setBoolFld(col++, fld.next());
+
+	    /* client id */
+	    item.setNumericFld(col++, fld.next());
+
+	    /* uname */
+	    item.setTextFld(col++, fld.next());
+
          }
       }
       row ++;
    }
-   /* Resize the columns */
-   for(int cnter=0; cnter<headerlist.size(); cnter++) {
-      tableWidget->resizeColumnToContents(cnter);
-   }
+   /* set default sorting */
+   tableWidget->sortByColumn(sortcol, sortord);
+   tableWidget->setSortingEnabled(true);
+   
+   /* Resize rows and columns */
+   tableWidget->resizeColumnsToContents();
+   tableWidget->resizeRowsToContents();
 }
 
 /*
@@ -246,7 +272,7 @@
 void Clients::consolePurgeJobs()
 {
    if (QMessageBox::warning(this, "Bat",
-      tr("Are you sure you want to purge ??  !!!.\n"
+      tr("Are you sure you want to purge all jobs of client \"%1\" ?\n"
 "The Purge command will delete associated Catalog database records from Jobs and"
 " Volumes without considering the retention period. Purge  works only on the"
 " Catalog database and does not affect data written to Volumes. This command can"
@@ -255,8 +281,9 @@
 " you are doing.\n\n"
 " Is there any way I can get you to click Cancel here?  You really don't want to do"
 " this\n\n"
-      "Press OK to proceed with the purge operation?"),
-      QMessageBox::Ok | QMessageBox::Cancel)
+	 "Press OK to proceed with the purge operation?").arg(m_currentlyselected),
+	 QMessageBox::Ok | QMessageBox::Cancel,
+	 QMessageBox::Cancel)
       == QMessageBox::Cancel) { return; }
 
    QString cmd("purge jobs client=");
@@ -280,3 +307,4 @@
    QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
    new ClientStat(m_currentlyselected, parentItem);
 }
+
Index: bacula/src/qt-console/mainwin.cpp
===================================================================
--- bacula/src/qt-console/mainwin.cpp	(revision 6999)
+++ bacula/src/qt-console/mainwin.cpp	(working copy)
@@ -74,7 +74,7 @@
    readPreferences();
    treeWidget->clear();
    treeWidget->setColumnCount(1);
-   treeWidget->setHeaderLabel("Select Page");
+   treeWidget->setHeaderLabel( tr("Select Page") );
    treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
 
    createPages();
@@ -125,7 +125,7 @@
 
       /* Create Tree Widget Item */
       item = new QTreeWidgetItem(topItem);
-      item->setText(0, "Console");
+      item->setText(0, tr("Console"));
       if (!m_firstItem){ m_firstItem = item; }
       item->setIcon(0,QIcon(QString::fromUtf8(":images/utilities-terminal.png")));
 
@@ -453,7 +453,7 @@
    bool found = false;
    foreach(Pages *page, m_pagehash) {
       if (m_currentConsole == page->console()) {
-         if (page->name() == "Director Status") {
+ 	 if (page->name() == tr("Director Status")) {
             found = true;
             page->setCurrent();
          }
@@ -500,10 +500,10 @@
 void MainWin::about()
 {
    QMessageBox::about(this, tr("About bat"),
-      tr("<br><h2>bat " VERSION "(" BDATE "), by Dirk H Bartley and Kern Sibbald</h2>"
-         "<p>Copyright &copy; 2007-" BYEAR " Free Software Foundation Europe e.V."
+      tr("<br><h2>bat %1 (%2), by Dirk H Bartley and Kern Sibbald</h2>"
+         "<p>Copyright &copy; 2007-%3 Free Software Foundation Europe e.V."
          "<p>The <b>bat</b> is an administrative console"
-         " interface to the Director."));
+         " interface to the Director.").arg(VERSION).arg(BDATE).arg(BYEAR));
 }
 
 void MainWin::help()
Index: bacula/src/qt-console/jobs/jobs.cpp
===================================================================
--- bacula/src/qt-console/jobs/jobs.cpp	(revision 6999)
+++ bacula/src/qt-console/jobs/jobs.cpp	(working copy)
@@ -38,6 +38,7 @@
 #include "bat.h"
 #include "jobs/jobs.h"
 #include "run/run.h"
+#include "util/fmtwidgetitem.h"
 
 Jobs::Jobs()
 {
@@ -68,7 +69,6 @@
  */
 void Jobs::populateTable()
 {
-   QTableWidgetItem *tableItem;
    QBrush blackBrush(Qt::black);
 
    if (!m_console->preventInUseConnect())
@@ -86,56 +86,42 @@
 
    tableWidget->setColumnCount(headerlist.count());
    tableWidget->setHorizontalHeaderLabels(headerlist);
+   tableWidget->horizontalHeader()->setHighlightSections(false);
    tableWidget->setRowCount(m_console->job_list.count());
    tableWidget->verticalHeader()->hide();
-   int row = 0;
+   tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
+   tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+   tableWidget->setSortingEnabled(false); /* rows move on insert if sorting enabled */
 
-
+   int row = 0;
    foreach (QString jobName, m_console->job_list){
       job_defaults job_defs;
       job_defs.job_name = jobName;
       if (m_console->get_job_defaults(job_defs)) {
+	 int col = 0;
+	 TableItemFormatter jobsItem(*tableWidget, row);
+	 jobsItem.setTextFld(col++, jobName); 
+	 jobsItem.setTextFld(col++, job_defs.pool_name);
+	 jobsItem.setTextFld(col++, job_defs.messages_name);
+	 jobsItem.setTextFld(col++, job_defs.client_name);
+	 jobsItem.setTextFld(col++, job_defs.store_name);
+	 jobsItem.setTextFld(col++, job_defs.level);
+	 jobsItem.setTextFld(col++, job_defs.type);
+	 jobsItem.setTextFld(col++, job_defs.fileset_name);
+	 jobsItem.setTextFld(col++, job_defs.catalog_name);
+	 jobsItem.setBoolFld(col++, job_defs.enabled);
+	 jobsItem.setTextFld(col++, job_defs.where);
 
-        for (int column=0; column<headerlist.count(); column++) {
-            tableItem = new QTableWidgetItem(1);
-            if (column == 0) 
-               tableItem->setText(job_defs.job_name);
-            if (column == 1) 
-               tableItem->setText(job_defs.pool_name);
-            if (column == 2) 
-               tableItem->setText(job_defs.messages_name);
-            if (column == 3) 
-               tableItem->setText(job_defs.client_name);
-            if (column == 4) 
-               tableItem->setText(job_defs.store_name);
-            if (column == 5) 
-               tableItem->setText(job_defs.level);
-            if (column == 6) 
-               tableItem->setText(job_defs.type);
-            if (column == 7) 
-               tableItem->setText(job_defs.fileset_name);
-            if (column == 8) 
-               tableItem->setText(job_defs.catalog_name);
-            if (column == 9) {
-               if (job_defs.enabled)
-                  tableItem->setText("Yes");
-               else
-                  tableItem->setText("No");
-            }
-            if (column == 10) 
-               tableItem->setText(job_defs.where);
-
-            /* tableItem->setFlags(Qt::ItemIsSelectable); */
-            tableItem->setForeground(blackBrush);
-            tableWidget->setItem(row, column, tableItem);
-         }
       }
       row++;
    }
-   /* Resize the columns */
-   for(int cnter=0; cnter<headerlist.size(); cnter++) {
-      tableWidget->resizeColumnToContents(cnter);
-   }
+   /* set default sorting */
+   tableWidget->sortByColumn(headerlist.indexOf(tr("Job Name")), Qt::AscendingOrder);
+   tableWidget->setSortingEnabled(true);
+   
+   /* Resize rows and columns */
+   tableWidget->resizeColumnsToContents();
+   tableWidget->resizeRowsToContents();
 }
 
 /*
@@ -180,8 +166,7 @@
          tableWidget->addAction(actionConsoleDisableJob);
          tableWidget->addAction(actionConsoleCancel);
          tableWidget->addAction(actionJobListQuery);
-         if (type == tr("Backup"))
-            tableWidget->addAction(actionRunJob);
+         tableWidget->addAction(actionRunJob);
       }
    }
 }
@@ -274,7 +259,7 @@
 }
 
 /*
- * Open a new job run page with the currentley selected "Backup" job 
+ * Open a new job run page with the currently selected job 
  * defaulted In
  */
 void Jobs::runJob()
Index: bacula/src/qt-console/run/run.cpp
===================================================================
--- bacula/src/qt-console/run/run.cpp	(revision 6999)
+++ bacula/src/qt-console/run/run.cpp	(working copy)
@@ -133,6 +133,7 @@
    (void)index;
    job_defs.job_name = jobCombo->currentText();
    if (m_console->get_job_defaults(job_defs)) {
+      typeLabel->setText("<H3>"+job_defs.type+"</H3>");
       filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
       levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, Qt::MatchExactly));
       clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
Index: bacula/src/qt-console/joblist/joblist.cpp
===================================================================
--- bacula/src/qt-console/joblist/joblist.cpp	(revision 6999)
+++ bacula/src/qt-console/joblist/joblist.cpp	(working copy)
@@ -137,6 +137,7 @@
    m_checkCurrentWidget = true;
    mp_tableWidget->setColumnCount(headerlist.size());
    mp_tableWidget->setHorizontalHeaderLabels(headerlist);
+   mp_tableWidget->horizontalHeader()->setHighlightSections(false);
    mp_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    mp_tableWidget->setSortingEnabled(false); /* rows move on insert if sorting enabled */
 
@@ -195,10 +196,7 @@
          jobitem.setJobStatusFld(col++, shortstatus, longstatus);
 
 	 /* purged */
-         if (fld.next().toInt())
-	    jobitem.setTextFld(col++, tr("IS"), true);
-	 else
-	    jobitem.setTextFld(col++, tr("NOT"), true);
+	 jobitem.setBoolFld(col++, fld.next());
 
 	 /* fileset */
          jobitem.setTextFld(col++, fld.next());
@@ -246,10 +244,23 @@
       if (jobIndex != -1) {
          jobComboBox->setCurrentIndex(jobIndex);
       }
+
       levelComboBox->addItem(tr("Any"));
-      levelComboBox->addItems( QStringList() << "F" << "D" << "I");
-      purgedComboBox->addItem(tr("Any"));
-      purgedComboBox->addItems( QStringList() << "0" << "1");
+      levelComboBox->addItem(job_level_to_str(L_FULL), L_FULL);
+      levelComboBox->addItem(job_level_to_str(L_INCREMENTAL), L_INCREMENTAL);
+      levelComboBox->addItem(job_level_to_str(L_DIFFERENTIAL), L_DIFFERENTIAL);
+      levelComboBox->addItem(job_level_to_str(L_SINCE), L_SINCE);
+      levelComboBox->addItem(job_level_to_str(L_VERIFY_CATALOG), L_VERIFY_CATALOG);
+      levelComboBox->addItem(job_level_to_str(L_VERIFY_INIT), L_VERIFY_INIT);
+      levelComboBox->addItem(job_level_to_str(L_VERIFY_VOLUME_TO_CATALOG), L_VERIFY_VOLUME_TO_CATALOG);
+      levelComboBox->addItem(job_level_to_str(L_VERIFY_DISK_TO_CATALOG), L_VERIFY_DISK_TO_CATALOG);
+      levelComboBox->addItem(job_level_to_str(L_VERIFY_DATA), L_VERIFY_DATA);
+      /* levelComboBox->addItem(job_level_to_str(L_BASE), L_BASE);  base jobs ignored */ 
+
+      purgedComboBox->addItem(tr("Any"), -1);
+      purgedComboBox->addItem(tr("No"), 0);
+      purgedComboBox->addItem(tr("Yes"), 1);
+
       fileSetComboBox->addItem(tr("Any"));
       fileSetComboBox->addItems(m_console->fileset_list);
       int filesetIndex = fileSetComboBox->findText(m_filesetName, Qt::MatchExactly);
@@ -302,15 +313,15 @@
    }
    int levelIndex = levelComboBox->currentIndex();
    if ((levelIndex != -1) && (levelComboBox->itemText(levelIndex) != tr("Any"))) {
-      conditions.append("Job.Level='" + levelComboBox->itemText(levelIndex) + "'");
+      conditions.append( QString("Job.Level='%1'").arg(levelComboBox->itemData(levelIndex).toChar()) );
    }
    int statusIndex = statusComboBox->currentIndex();
    if ((statusIndex != -1) && (statusComboBox->itemText(statusIndex) != tr("Any"))) {
       conditions.append("Status.JobStatusLong='" + statusComboBox->itemText(statusIndex) + "'");
    }
    int purgedIndex = purgedComboBox->currentIndex();
-   if ((purgedIndex != -1) && (purgedComboBox->itemText(purgedIndex) != tr("Any"))) {
-      conditions.append("Job.PurgedFiles='" + purgedComboBox->itemText(purgedIndex) + "'");
+   if (purgedIndex != -1 && purgedComboBox->itemData(purgedIndex).toInt() >= 0 ) {
+      conditions.append("Job.PurgedFiles='" + purgedComboBox->itemData(purgedIndex).toString() + "'");
    }
    int fileSetIndex = fileSetComboBox->currentIndex();
    if (fileSetIndex != -1)
@@ -372,22 +383,16 @@
  */
 void JobList::treeWidgetName(QString &desc)
 {
-   if ((m_mediaName == "") && (m_clientName == "") && (m_jobName == "") && (m_filesetName == "")) {
-      desc = "JobList";
+   if (m_mediaName != "" ) {
+     desc = tr("JobList of Volume %1").arg(m_mediaName);
+   } else if (m_clientName != "" ) {
+     desc = tr("JobList of Client %1").arg(m_clientName);
+   } else if (m_jobName != "" ) {
+     desc = tr("JobList of Job %1").arg(m_jobName);
+   } else if (m_filesetName != "" ) {
+     desc = tr("JobList of fileset %1").arg(m_filesetName);
    } else {
-      desc = "JobList ";
-      if (m_mediaName != "" ) {
-         desc += "of Volume " + m_mediaName;
-      }
-      if (m_clientName != "" ) {
-         desc += "of Client " + m_clientName;
-      }
-      if (m_jobName != "" ) {
-         desc += "of Job " + m_jobName;
-      }
-      if (m_filesetName != "" ) {
-         desc += "of fileset " + m_filesetName;
-      }
+     desc = tr("JobList");
    }
 }
 
@@ -406,7 +411,7 @@
       jobitem = mp_tableWidget->item(row, m_purgedIndex);
       QString purged = jobitem->text();
       mp_tableWidget->removeAction(actionPurgeFiles);
-      if (purged == "NOT") {
+      if (purged == tr("No") ) {
          mp_tableWidget->addAction(actionPurgeFiles);
       }
       /* include restore from time and job action or not */
@@ -414,7 +419,7 @@
       QString type = jobitem->text();
       mp_tableWidget->removeAction(actionRestoreFromJob);
       mp_tableWidget->removeAction(actionRestoreFromTime);
-      if (type == "Backup") {
+      if (type == tr("Backup")) {
          mp_tableWidget->addAction(actionRestoreFromJob);
          mp_tableWidget->addAction(actionRestoreFromTime);
       }
@@ -422,7 +427,7 @@
       jobitem = mp_tableWidget->item(row, m_statusIndex);
       QString status = jobitem->text();
       mp_tableWidget->removeAction(actionCancelJob);
-      if (status == "Running") {
+      if (status == tr("Running")) {
          mp_tableWidget->addAction(actionCancelJob);
       }
    }
@@ -681,9 +686,9 @@
    }
    m_selectedJobsCount = rowList.count();
    if (m_selectedJobsCount > 1) {
-      QString text = QString("Delete list of %1 Jobs").arg(m_selectedJobsCount);
-      actionDeleteJob->setText(text);
+     QString text = QString( tr("Delete list of %1 Jobs")).arg(m_selectedJobsCount);
+       actionDeleteJob->setText(text);
    } else {
-      actionDeleteJob->setText("Delete Single Job");
+     actionDeleteJob->setText(tr("Delete Single Job"));
    }
 }
Index: bacula/src/qt-console/util/fmtwidgetitem.cpp
===================================================================
--- bacula/src/qt-console/util/fmtwidgetitem.cpp	(revision 6999)
+++ bacula/src/qt-console/util/fmtwidgetitem.cpp	(working copy)
@@ -42,6 +42,7 @@
 #include <QString>
 #include <QStringList>
 #include <math.h>
+#include "bacula.h"
 #include "fmtwidgetitem.h"
 
 /***********************************************
@@ -295,29 +296,22 @@
 
 void ItemFormatterBase::setJobTypeFld(int index, const QString &fld, bool center)
 {
-   static QHash<QString, QString> jobt;
-   if (jobt.isEmpty()) {
-      jobt.insert("B", QObject::tr("Backup"));
-      jobt.insert("R", QObject::tr("Restore"));
-      jobt.insert("V", QObject::tr("Verify"));
-      jobt.insert("A", QObject::tr("Admin"));
+   QByteArray jtype(fld.trimmed().toAscii());
+   if (jtype.size()) {
+      setTextFld(index, job_type_to_str(jtype[0]), center);
+   } else {
+      setTextFld(index, "", center);
    }
-
-   setTextFld(index, jobt.value(fld.trimmed(), fld.trimmed()), center);
 }
 
 void ItemFormatterBase::setJobLevelFld(int index, const QString &fld, bool center)
 {
-   static QHash<QString, QString> jobt;
-   if (jobt.isEmpty()) {
-      jobt.insert("F", QObject::tr("Full"));
-      jobt.insert("D", QObject::tr("Differential"));
-      jobt.insert("I", QObject::tr("Incremental"));
-      jobt.insert("C", QObject::tr("Catalog"));
-      jobt.insert("O", QObject::tr("VolToCatalog"));
+   QByteArray lvl(fld.trimmed().toAscii());
+   if (lvl.size()) {
+      setTextFld(index, job_level_to_str(lvl[0]), center);
+   } else {
+      setTextFld(index, "", center);
    }
-
-   setTextFld(index, jobt.value(fld.trimmed(), fld.trimmed()), center);
 }
 
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bacula-devel mailing list
Bacula-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bacula-devel


This mailing list archive is a service of Copilotco.