]> git.sur5r.net Git - bacula/bacula/commitdiff
Commit of patch by Riccardo.
authorDirk H Bartley <dbartley@schupan.com>
Sat, 21 Jun 2008 14:44:50 +0000 (14:44 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Sat, 21 Jun 2008 14:44:50 +0000 (14:44 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7206 91ce42f0-d328-0410-95d8-f526ca767f89

20 files changed:
bacula/src/lib/protos.h
bacula/src/lib/util.c
bacula/src/qt-console/bcomm/dircomm.cpp
bacula/src/qt-console/console/console.cpp
bacula/src/qt-console/jobgraphs/jobplot.cpp
bacula/src/qt-console/joblist/joblist.cpp
bacula/src/qt-console/joblog/joblog.cpp
bacula/src/qt-console/mediaedit/mediaedit.cpp
bacula/src/qt-console/pages.cpp
bacula/src/qt-console/pages.h
bacula/src/qt-console/restore/restoretree.cpp
bacula/src/qt-console/status/clientstat.cpp
bacula/src/qt-console/status/dirstat.cpp
bacula/src/qt-console/status/storstat.cpp
bacula/src/qt-console/storage/storage.cpp
bacula/src/qt-console/storage/storage.h
bacula/src/qt-console/util/comboutil.cpp
bacula/src/qt-console/util/comboutil.h
bacula/src/qt-console/util/fmtwidgetitem.cpp
bacula/src/qt-console/util/fmtwidgetitem.h

index 4197b31e74b0651a7ddff3ff4e18a4483c83d62c..c5c153bdb67684c46881a9488bdd3f5e857eacaf 100644 (file)
@@ -318,11 +318,13 @@ char *           encode_time             (time_t time, char *buf);
 char *           encode_mode             (mode_t mode, char *buf);
 int              do_shell_expansion      (char *name, int name_len);
 void             jobstatus_to_ascii      (int JobStatus, char *msg, int maxlen);
+void             jobstatus_to_ascii_gui  (int JobStatus, char *msg, int maxlen);
 int              run_program             (char *prog, int wait, POOLMEM *&results);
 int              run_program_full_output (char *prog, int wait, POOLMEM *&results);
 const char *     job_type_to_str         (int type);
 const char *     job_status_to_str       (int stat);
 const char *     job_level_to_str        (int level);
+const char *     volume_status_to_str    (const char *status);
 void             make_session_key        (char *key, char *seed, int mode);
 void             encode_session_key      (char *encode, char *session, char *key, int maxlen);
 void             decode_session_key      (char *decode, char *session, char *key, int maxlen);
index 37bfadfaea3a8f8e0b863d83d69e6a86e6b3e152..2aeb5a6ba36fdda2232306a066205680edf76c90 100644 (file)
@@ -255,6 +255,53 @@ void jobstatus_to_ascii(int JobStatus, char *msg, int maxlen)
    bstrncpy(msg, jobstat, maxlen);
 }
 
+/*
+ * Convert a JobStatus code into a human readable form - gui version
+ */
+void jobstatus_to_ascii_gui(int JobStatus, char *msg, int maxlen)
+{
+   const char *cnv = NULL;
+   switch (JobStatus) {
+   case JS_Terminated:
+      cnv = _("Completed successfully");
+      break;
+   case JS_ErrorTerminated:
+      cnv = _("Terminated with errors");
+      break;
+   case JS_FatalError:
+      cnv = _("Fatal error");
+      break;
+   case JS_Created:
+      cnv = _("Created, not yet running");
+      break;
+   case JS_Canceled:
+      cnv = _("Canceled by user");
+      break;
+   case JS_Differences:
+      cnv = _("Verify found differences");
+      break;
+   case JS_WaitFD:
+      cnv = _("Waiting for File daemon");
+      break;
+   case JS_WaitSD:
+      cnv = _("Waiting for Storage daemon");
+      break;
+   case JS_WaitPriority:
+      cnv = _("Waiting for higher priority jobs");
+      break;
+   case JS_AttrInserting:
+      cnv = _("Batch inserting file records");
+      break;
+   };
+
+   if (cnv) {
+      bstrncpy(msg, cnv, maxlen);
+   } else {
+     jobstatus_to_ascii( JobStatus, msg, maxlen);
+   }
+}
+
+
 /*
  * Convert Job Termination Status into a string
  */
@@ -376,6 +423,32 @@ const char *job_level_to_str(int level)
    return str;
 }
 
+const char *volume_status_to_str(const char *status)
+{
+   int pos;
+   const char *vs[] = {
+      NT_("Append"),    _("Append"),
+      NT_("Archive"),   _("Archive"),
+      NT_("Disabled"),  _("Disabled"),
+      NT_("Full"),      _("Full"),
+      NT_("Used"),      _("Used"),
+      NT_("Cleaning"),  _("Cleaning"),
+      NT_("Recycle"),   _("Recycle"),
+      NT_("Read-Only"), _("Read-Only"),
+      NT_("Error"),     _("Error"),
+      NULL,             NULL};
+
+   if (status) {
+     for (pos = 0 ; vs[pos] ; pos += 2) {
+       if ( !strcmp(vs[pos],status) ) {
+        return vs[pos+1];
+       }
+     }
+   }
+
+   return _("Invalid volume status");
+}
+
 
 /***********************************************************************
  * Encode the mode bits into a 10 character string like LS does
index 88fd594af125bda16d475c5bc37ab9418f066835..ae97f9af3384635d55c367fd3ba4f6523b599cbf 100644 (file)
@@ -337,12 +337,19 @@ void DirComm::beginNewCommand()
 void DirComm::displayToPrompt()
 { 
    int stat = 0;
+   QString buf;
    if (mainWin->m_commDebug) Pmsg0(000, "DisplaytoPrompt\n");
    while (!m_at_prompt) {
       if ((stat=read()) > 0) {
-         m_console->display_text(msg());
+       buf += msg();
+       if (buf.size() >= 8196 || m_messages_pending) {
+          m_console->display_text(buf);
+          buf.clear();
+          m_messages_pending = false;
+       }
       }
    }
+   m_console->display_text(buf);
    if (mainWin->m_commDebug) Pmsg1(000, "endDisplaytoPrompt=%d\n", stat);
 }
 
index 68fce9ffc3141961a02e8110a626551c9685e105..f159083c9e32fbc5cbfbfe55906d2765df0b6bbf 100644 (file)
@@ -590,9 +590,10 @@ void Console::displayToPrompt()
    while (!m_at_prompt) {
       if ((stat=read()) > 0) {
        buf += msg();
-       if (buf.size() >= 8196) {
+       if (buf.size() >= 8196 || m_messages_pending) {
           display_text(buf);
           buf.clear();
+          m_messages_pending = false;
        }
       }
    }
index 5e50a6d3253fd6bec781de8136480279320081aa..d930e072d8be59ce5f7abf2e8e6dedd9d4de5b53 100644 (file)
@@ -77,8 +77,7 @@ JobPlotControls::JobPlotControls()
 JobPlot::JobPlot(QTreeWidgetItem *parentTreeWidgetItem, JobPlotPass &passVals)
 {
    setupUserInterface();
-   m_name = tr("JobPlot");
-   pgInitialize(parentTreeWidgetItem);
+   pgInitialize(tr("JobPlot"), parentTreeWidgetItem);
    readSplitterSettings();
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/applications-graphics.png")));
index 3bb8bfde99f0a6ec806d739c9edd8430825e75c8..3c1707a9c1ab859caa45ad77d7970bbc8c3729fc 100644 (file)
@@ -56,7 +56,7 @@ JobList::JobList(const QString &mediaName, const QString &clientName,
    m_jobName = jobName;
    m_filesetName = filesetName;
    m_filesetName = filesetName;
-   pgInitialize(parentTreeWidgetItem);
+   pgInitialize("", parentTreeWidgetItem);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/emblem-system.png")));
 
@@ -192,9 +192,7 @@ void JobList::populateTable()
          jobitem.setBytesFld(col++, fld.next());
 
         /* job status */
-        QString shortstatus(fld.next());
-        QString longstatus(fld.next());
-         jobitem.setJobStatusFld(col++, shortstatus, longstatus);
+         jobitem.setJobStatusFld(col++, fld.next());
 
         /* purged */
         jobitem.setBoolFld(col++, fld.next());
@@ -247,10 +245,7 @@ void JobList::prepareFilterWidgets()
       fileSetComboBox->addItems(m_console->fileset_list);
       comboSel(fileSetComboBox, m_filesetName);
 
-      QStringList statusLongList;
-      m_console->getStatusList(statusLongList);
-      statusComboBox->addItem(tr("Any"));
-      statusComboBox->addItems(statusLongList);
+      jobStatusComboFill(statusComboBox);
    }
 }
 
@@ -266,12 +261,10 @@ void JobList::fillQueryString(QString &query)
             " Client.Name AS Client,"
             " Job.Starttime AS JobStart, Job.Type AS JobType,"
             " Job.Level AS BackupLevel, Job.Jobfiles AS FileCount,"
-            " Job.JobBytes AS Bytes,"
-            " Job.JobStatus AS Status, Status.JobStatusLong AS StatusLong,"
+            " Job.JobBytes AS Bytes, Job.JobStatus AS Status,"
             " Job.PurgedFiles AS Purged, FileSet.FileSet"
             " FROM Job"
             " JOIN Client ON (Client.ClientId=Job.ClientId)"
-            " JOIN Status ON (Job.JobStatus=Status.JobStatus)"
             " LEFT OUTER JOIN FileSet ON (FileSet.FileSetId=Job.FileSetId) ";
    QStringList conditions;
    if (m_mediaName != tr("Any")) {
@@ -283,7 +276,7 @@ void JobList::fillQueryString(QString &query)
    comboCond(conditions, clientComboBox, "Client.Name");
    comboCond(conditions, jobComboBox, "Job.Name");
    levelComboCond(conditions, levelComboBox, "Job.Level");
-   comboCond(conditions, statusComboBox, "Status.JobStatusLong");
+   jobStatusComboCond(conditions, statusComboBox, "Job.JobStatus");
    boolComboCond(conditions, purgedComboBox, "Job.PurgedFiles");
    comboCond(conditions, fileSetComboBox, "FileSet.FileSet");
 
index 3d9c5f2f01ec0cffb8ca3ab90cc054f64ab8d46d..07e247fae404d57f4b5974b5635c3ba5be96cc8d 100644 (file)
@@ -41,9 +41,8 @@
 JobLog::JobLog(QString &jobId, QTreeWidgetItem *parentTreeWidgetItem)
 {
    setupUi(this);
-   m_name = tr("JobLog");
    m_closeable = true;
-   pgInitialize(parentTreeWidgetItem);
+   pgInitialize(tr("JobLog"), parentTreeWidgetItem);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/joblog.png")));
    m_cursor = new QTextCursor(textEdit->document());
index e2b7d542f7bff4491ee92abfc9f2ba184e87b0e0..892e946a9230b5f9fefef86733d4af40adac158b 100644 (file)
@@ -44,8 +44,7 @@
 MediaEdit::MediaEdit(QTreeWidgetItem *parentWidget, QString &mediaId)
 {
    setupUi(this);
-   m_name = tr("Media Edit");
-   pgInitialize(parentWidget);
+   pgInitialize(tr("Media Edit"), parentWidget);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/cartridge-edit.png")));
    m_closeable = true;
index 173f7fbf3cc9c3094e33470c4e468d5035f9987b..a6f5c654fe8b46a880e7ef66466b7f46f2bc86cf 100644 (file)
@@ -50,7 +50,6 @@ bool isWin32Path(QString &fullPath)
    return toret;
 }
 
-
 /*
  * dockPage
  * This function is intended to be called from within the Pages class to pull
@@ -187,11 +186,19 @@ void Pages::closeStackPage()
  */
 void Pages::pgInitialize()
 {
-   pgInitialize(NULL);
+   pgInitialize(QString(), NULL);
 }
 
-void Pages::pgInitialize(QTreeWidgetItem *parentTreeWidgetItem)
+void Pages::pgInitialize(const QString &name)
 {
+   pgInitialize(name, NULL);
+}
+
+void Pages::pgInitialize(const QString &tname, QTreeWidgetItem *parentTreeWidgetItem)
+{
+   if (tname.size()) {
+      m_name = tname;
+   }
    m_parent = mainWin->stackedWidget;
    m_console = mainWin->currentConsole();
 
index f472c0383d32d9d4afee56722dae0351623a3a4a..c987716e1c6139853ad54700f5f28ff225aea7a4 100644 (file)
@@ -79,7 +79,8 @@ public slots:
 
 protected:
    void pgInitialize();
-   void pgInitialize(QTreeWidgetItem *);
+   void pgInitialize(const QString &);
+   void pgInitialize(const QString &, QTreeWidgetItem *);
    virtual void treeWidgetName(QString &);
    virtual void changeEvent(QEvent *event);
    void setConsoleCurrent();
index 8c37d650b57349d42dd07c31590a4b627e90693b..6aa4b54d03c860479ef4d5cca4f4356e7e431332 100644 (file)
@@ -360,12 +360,13 @@ void restoreTree::parseDirectory(QString &dir_in)
    }
 
    for (int k=0; k<pathAfter.count(); k++) {
-      if (addDirectory(pathAfter[k], dirAfter[k]))
+      if (addDirectory(pathAfter[k], dirAfter[k])) {
          if ((mainWin->m_miscDebug) && (m_debugTrap))
             Pmsg2(000, "Adding After %s %s\n", pathAfter[k].toUtf8().data(), dirAfter[k].toUtf8().data());
-      else
+      } else {
          if ((mainWin->m_miscDebug) && (m_debugTrap))
             Pmsg2(000, "Error Adding %s %s\n", pathAfter[k].toUtf8().data(), dirAfter[k].toUtf8().data());
+      }
    }
 }
 
@@ -1122,7 +1123,7 @@ void restoreTree::versionTableItemChanged(QTableWidgetItem *item)
       m_versionExceptionHash.remove(fullPath);
    } else if (prevState != curState) {
       if (mainWin->m_rtVerTabICDebug) Pmsg2(000, "  THE STATE OF THE version Check has changed, Setting StateList[%i] to %i\n", row, curState);
-      if ((curState == Qt::Checked) || (curState == Qt::PartiallyChecked) && (row != 0)) {
+      if ((curState == Qt::Checked) || (curState == Qt::PartiallyChecked && row != 0)) {
          if (mainWin->m_rtVerTabICDebug) Pmsg2(000, "Inserting into m_versionExceptionHash %s, %i\n", fullPath.toUtf8().data(), thisJobNum);
          m_versionExceptionHash.insert(fullPath, thisJobNum);
          if (fileState != Qt::Checked) {
index 28b7caeb43f3aca6deee9a1a07d2bc2c3fb32578..0ef28f89b3d544eb88cbce31459465c2f1886b87 100644 (file)
@@ -43,9 +43,8 @@ ClientStat::ClientStat(QString &client, QTreeWidgetItem *parentTreeWidgetItem)
 {
    m_client = client;
    setupUi(this);
-   m_name = tr("Client Status %1").arg(m_client);
    m_closeable = true;
-   pgInitialize(parentTreeWidgetItem);
+   pgInitialize(tr("Client Status %1").arg(m_client), parentTreeWidgetItem);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/status.png")));
    m_cursor = new QTextCursor(textEditHeader->document());
@@ -166,11 +165,12 @@ void ClientStat::populateTerminated()
             p_tableitem->setFlags(0);
             if (flaglist[column].contains("R"))
                p_tableitem->setTextAlignment(Qt::AlignRight);
-            if (flaglist[column].contains("C"))
+            if (flaglist[column].contains("C")) {
                if (field == "OK")
                   p_tableitem->setBackground(Qt::green);
                else
-                  p_tableitem->setBackground(Qt::red);
+                p_tableitem->setBackground(Qt::red);
+           }
             terminatedTable->setItem(results.size() - row - 1, column, p_tableitem);
             column += 1;
          }
index a0becc182a8f3c24a5d37d54098ff92fa37fe738..911c1a6c55cb280405d36f742224820b02651cc2 100644 (file)
@@ -166,11 +166,12 @@ void DirStat::populateTerminated()
             p_tableitem->setFlags(0);
             if (flaglist[column].contains("R"))
                p_tableitem->setTextAlignment(Qt::AlignRight);
-            if (flaglist[column].contains("C"))
+            if (flaglist[column].contains("C")) {
                if (field == "OK")
                   p_tableitem->setBackground(Qt::green);
                else
                   p_tableitem->setBackground(Qt::red);
+           }
             terminatedTable->setItem(results.size() - row - 1, column, p_tableitem);
             column += 1;
          }
index d624763359f7545bdda53c0993274a85633642e7..d9dfd9dba9a86280e782cac5f54a928507ed7ba6 100644 (file)
@@ -58,9 +58,8 @@ StorStat::StorStat(QString &storage, QTreeWidgetItem *parentTreeWidgetItem)
 {
    m_storage = storage;
    setupUi(this);
-   m_name = tr("Storage Status %1").arg(m_storage);
    m_closeable = true;
-   pgInitialize(parentTreeWidgetItem);
+   pgInitialize(tr("Storage Status %1").arg(m_storage), parentTreeWidgetItem);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/status.png")));
    m_cursor = new QTextCursor(textEditHeader->document());
@@ -259,11 +258,12 @@ void StorStat::populateTerminated()
             p_tableitem->setFlags(0);
             if (flaglist[column].contains("R"))
                p_tableitem->setTextAlignment(Qt::AlignRight);
-            if (flaglist[column].contains("C"))
+            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;
          }
index 019ad781c8267963b6d86ce3297fb12fa4b28e05..9ba048ab0b9fc9bec89c432793da86d8e4456ff4 100644 (file)
@@ -47,8 +47,7 @@
 Storage::Storage()
 {
    setupUi(this);
-   m_name = tr("Storage");
-   pgInitialize();
+   pgInitialize(tr("Storage"));
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/package-x-generic.png")));
 
@@ -245,7 +244,7 @@ void Storage::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte
          /* set a hold variable to the storage name in case the context sensitive
           * menu is used */
          m_currentStorage = currentwidgetitem->text(0);
-         m_currentAutoChanger = currentwidgetitem->text(2).toInt();
+         m_currentAutoChanger = currentwidgetitem->text(2) == tr("Yes");
          mp_treeWidget->addAction(actionStatusStorageInConsole);
          mp_treeWidget->addAction(actionStatusStorageWindow);
          mp_treeWidget->addAction(actionLabelStorage);
@@ -253,24 +252,23 @@ void Storage::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte
          mp_treeWidget->addAction(actionUnMountStorage);
          mp_treeWidget->addAction(actionRelease);
          QString text;
-         text = "Status Storage \"" + m_currentStorage + "\"";
+         text = tr("Status Storage \"%1\"").arg(m_currentStorage);;
          actionStatusStorageInConsole->setText(text);
-         text = "Status Storage \"" + m_currentStorage + "\" in Window";
+         text = tr("Status Storage \"%1\" in Window").arg(m_currentStorage);;
          actionStatusStorageWindow->setText(text);
-         text = "Label media in Storage \"" + m_currentStorage + "\"";
+         text = tr("Label media in Storage \"%1\"").arg(m_currentStorage);
          actionLabelStorage->setText(text);
-         text = "Mount media in Storage \"" + m_currentStorage + "\"";
+         text = tr("Mount media in Storage \"%1\"").arg(m_currentStorage);
          actionMountStorage->setText(text);
-         text = "\"UN\" Mount media in Storage \"" + m_currentStorage + "\"";
-         actionUnMountStorage->setText(text);
-         text = "Release media in Storage \"" + m_currentStorage + "\"";
+         text = tr("\"UN\" Mount media in Storage \"%1\"").arg(m_currentStorage);
+         text = tr("Release media in Storage \"%1\"").arg(m_currentStorage);
          actionRelease->setText(text);
-         if (m_currentAutoChanger != 0) {
+         if (m_currentAutoChanger) {
             mp_treeWidget->addAction(actionUpdateSlots);
             mp_treeWidget->addAction(actionUpdateSlotsScan);
-            text = "Barcode Scan media in Storage \"" + m_currentStorage + "\"";
+            text = tr("Barcode Scan media in Storage \"%1\"").arg(m_currentStorage);
             actionUpdateSlots->setText(text);
-            text = "Mount and read scan media in Storage \"" + m_currentStorage + "\"";
+            text = tr("Read scan media in Storage \"%1\"").arg( m_currentStorage);
             actionUpdateSlotsScan->setText(text);
          }
       }
index 3faafd7dcd0ee64f10944785615a5d371e7e3897..c2be870a75f8f4a86c36d0ef45c42d0b8c681503 100644 (file)
@@ -66,7 +66,7 @@ private:
    void createContextMenu();
    void mediaList(QTreeWidgetItem *parent, const QString &storageID);
    QString m_currentStorage;
-   int m_currentAutoChanger;
+   bool m_currentAutoChanger;
    bool m_populated;
    bool m_checkcurwidget;
    void writeExpandedSettings();
index 8d893fd5039a72715e7d36fd1634606cd0d0bf1f..2e401d8de8b061fe78eb94313ebb6379cb03376f 100644 (file)
@@ -25,7 +25,7 @@
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+
 /*
  *   Version $Id$
  *
  *
  *   Riccardo Ghetta, May 2008
  *
- */ 
+ */
 
 #include <QComboBox>
 #include <QString>
 #include <QStringList>
 #include "bat.h"
+#include "fmtwidgetitem.h"
 #include "comboutil.h"
 
 static const QString QS_ANY(QObject::tr("Any"));
@@ -94,7 +95,7 @@ void levelComboFill(QComboBox *combo)
    combo->addItem(job_level_to_str(L_VERIFY_VOLUME_TO_CATALOG), L_VERIFY_VOLUME_TO_CATALOG);
    combo->addItem(job_level_to_str(L_VERIFY_DISK_TO_CATALOG), L_VERIFY_DISK_TO_CATALOG);
    combo->addItem(job_level_to_str(L_VERIFY_DATA), L_VERIFY_DATA);
-   /* combo->addItem(job_level_to_str(L_BASE), L_BASE);  base jobs ignored */ 
+   /* combo->addItem(job_level_to_str(L_BASE), L_BASE);  base jobs ignored */
 }
 
 void levelComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
@@ -106,3 +107,48 @@ void levelComboCond(QStringList &cndlist, const QComboBox *combo, const char *fl
    }
 }
 
+/* job status combo */
+void jobStatusComboFill(QComboBox *combo)
+{
+   static const char js[] = {
+                     JS_Terminated,
+                      JS_Created,
+                     JS_Running,
+                     JS_Blocked,
+                     JS_ErrorTerminated,
+                     JS_Error,
+                     JS_FatalError,
+                     JS_Differences,
+                     JS_Canceled,
+                     JS_WaitFD,
+                     JS_WaitSD,
+                     JS_WaitMedia,
+                     JS_WaitMount,
+                     JS_WaitStoreRes,
+                     JS_WaitJobRes,
+                     JS_WaitClientRes,
+                     JS_WaitMaxJobs,
+                     JS_WaitStartTime,
+                     JS_WaitPriority,
+                     JS_AttrDespooling,
+                     JS_AttrInserting,
+                     JS_DataDespooling,
+                     JS_DataCommitting,
+                     '\0'};
+
+   int pos;
+
+   combo->addItem(QS_ANY);
+   for (pos = 0 ; js[pos] != '\0' ; ++pos) {
+     combo->addItem(convertJobStatus( QString(js[pos]) ), js[pos]);
+   }
+}
+
+void jobStatusComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
+{
+   int index = combo->currentIndex();
+   if (index != -1 && combo->itemText(index) != QS_ANY ) {
+      QString cnd = combo->itemData(index).toChar();
+      cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );
+   }
+}
index c9e9d86b4c39d6cd6916359353218b0f408f6308..8bc128a166a7db1b875d7748c0d1dab2bb981e96 100644 (file)
@@ -59,4 +59,8 @@ void boolComboCond(QStringList &cndlist, const QComboBox *combo, const char *fld
 void levelComboFill(QComboBox *combo);
 void levelComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname);
 
+/* job status combo */
+void jobStatusComboFill(QComboBox *combo);
+void jobStatusComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname);
+
 #endif /* _COMBOUTIL_H_ */
index bb97e1d4418221885287cf2a39f28d3c97302431..6b30a767de703c152991305d93cdaf45d2cc913f 100644 (file)
 #include <QString>
 #include <QStringList>
 #include <math.h>
-#include "bacula.h"
+#include "bat.h"
 #include "fmtwidgetitem.h"
 
+/***********************************************
+ *
+ * common helpers
+ *
+ ***********************************************/
+
+QString convertJobStatus(const QString &sts)
+{
+   QString code( sts.trimmed() );
+   if ( code.size() != 1) {
+      return QObject::tr("Invalid job status %1").arg(sts);
+   }
+
+   char buf[256];
+   jobstatus_to_ascii_gui( code[0].toAscii(), buf, sizeof(buf));
+   return QString(buf);
+}
+
 /***********************************************
  *
  * ItemFormatterBase static members
@@ -263,28 +281,30 @@ void ItemFormatterBase::setDurationFld(int index, const QString &fld)
 
 void ItemFormatterBase::setVolStatusFld(int index, const QString &fld, bool center)
 {
-   setTextFld(index, fld, center);
+  QString mp(fld.trimmed());
+   setTextFld(index, volume_status_to_str(mp.toUtf8()), center);
 
-   if (fld == "Append" ) {
+   if (mp == "Append" ) {
       setBackground(index, Qt::green);
-   } else if (fld == "Error") {
+   } else if (mp == "Error") {
       setBackground(index, Qt::red);
-   } else if (fld == "Used" || fld == "Full"){
+   } else if (mp == "Used" || mp == "Full"){
       setBackground(index, Qt::yellow);
+   } else if (mp == "Read-only" || mp == "Disabled"){
+      setBackground(index, Qt::lightGray);
    }
 }
 
-void ItemFormatterBase::setJobStatusFld(int index, const QString &shortstatus, 
-                                       const QString &longstatus, bool center)
+void ItemFormatterBase::setJobStatusFld(int index, const QString &status, bool center)
 {
    /* C (created, not yet running) uses the default background */
    static QString greenchars("TR");
    static QString redchars("BEf");
    static QString yellowchars("eDAFSMmsjdctp");
 
-   setTextFld(index, longstatus, center);
+   setTextFld(index, convertJobStatus(status), center);
 
-   QString st(shortstatus.trimmed());
+   QString st(status.trimmed());
    if (greenchars.contains(st, Qt::CaseSensitive)) {
       setBackground(index, Qt::green);
    } else if (redchars.contains(st, Qt::CaseSensitive)) {
index 324a8c64c549660f5afbf1048ebec5c44abdf3d4..66f3202691f561be45637af61efd4ea5c4a1b999 100644 (file)
@@ -39,6 +39,14 @@ class QTableWidgetItem;
 class QString;
 class QBrush;
 
+
+/*
+ * common conversion routines
+ *
+ */
+QString convertJobStatus(const QString &sts);
+
+
 /*
  * base class for formatters
  *
@@ -79,8 +87,7 @@ public:
    void setVolStatusFld(int index, const QString &fld, bool center = true);
   
    /* fld value interpreted as job status. Colored accordingly */
-   void setJobStatusFld(int index, const QString &shortStatus, const QString &longstatus, 
-                       bool center = true);
+   void setJobStatusFld(int index, const QString &status, bool center = true);
   
    /* fld value interpreted as job type. */
    void setJobTypeFld(int index, const QString &fld, bool center = false);