From 40c526df635c69babcc22ee187f9789a957d74d8 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sat, 21 Jun 2008 14:44:50 +0000 Subject: [PATCH] Commit of patch by Riccardo. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7206 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/lib/protos.h | 2 + bacula/src/lib/util.c | 73 +++++++++++++++++++ bacula/src/qt-console/bcomm/dircomm.cpp | 9 ++- bacula/src/qt-console/console/console.cpp | 3 +- bacula/src/qt-console/jobgraphs/jobplot.cpp | 3 +- bacula/src/qt-console/joblist/joblist.cpp | 17 ++--- bacula/src/qt-console/joblog/joblog.cpp | 3 +- bacula/src/qt-console/mediaedit/mediaedit.cpp | 3 +- bacula/src/qt-console/pages.cpp | 13 +++- bacula/src/qt-console/pages.h | 3 +- bacula/src/qt-console/restore/restoretree.cpp | 7 +- bacula/src/qt-console/status/clientstat.cpp | 8 +- bacula/src/qt-console/status/dirstat.cpp | 3 +- bacula/src/qt-console/status/storstat.cpp | 6 +- bacula/src/qt-console/storage/storage.cpp | 24 +++--- bacula/src/qt-console/storage/storage.h | 2 +- bacula/src/qt-console/util/comboutil.cpp | 52 ++++++++++++- bacula/src/qt-console/util/comboutil.h | 4 + bacula/src/qt-console/util/fmtwidgetitem.cpp | 38 +++++++--- bacula/src/qt-console/util/fmtwidgetitem.h | 11 ++- 20 files changed, 221 insertions(+), 63 deletions(-) diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 4197b31e74..c5c153bdb6 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -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); diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 37bfadfaea..2aeb5a6ba3 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -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 diff --git a/bacula/src/qt-console/bcomm/dircomm.cpp b/bacula/src/qt-console/bcomm/dircomm.cpp index 88fd594af1..ae97f9af33 100644 --- a/bacula/src/qt-console/bcomm/dircomm.cpp +++ b/bacula/src/qt-console/bcomm/dircomm.cpp @@ -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); } diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 68fce9ffc3..f159083c9e 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -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; } } } diff --git a/bacula/src/qt-console/jobgraphs/jobplot.cpp b/bacula/src/qt-console/jobgraphs/jobplot.cpp index 5e50a6d325..d930e072d8 100644 --- a/bacula/src/qt-console/jobgraphs/jobplot.cpp +++ b/bacula/src/qt-console/jobgraphs/jobplot.cpp @@ -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"))); diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 3bb8bfde99..3c1707a9c1 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -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"); diff --git a/bacula/src/qt-console/joblog/joblog.cpp b/bacula/src/qt-console/joblog/joblog.cpp index 3d9c5f2f01..07e247fae4 100644 --- a/bacula/src/qt-console/joblog/joblog.cpp +++ b/bacula/src/qt-console/joblog/joblog.cpp @@ -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()); diff --git a/bacula/src/qt-console/mediaedit/mediaedit.cpp b/bacula/src/qt-console/mediaedit/mediaedit.cpp index e2b7d542f7..892e946a92 100644 --- a/bacula/src/qt-console/mediaedit/mediaedit.cpp +++ b/bacula/src/qt-console/mediaedit/mediaedit.cpp @@ -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; diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 173f7fbf3c..a6f5c654fe 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -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(); diff --git a/bacula/src/qt-console/pages.h b/bacula/src/qt-console/pages.h index f472c0383d..c987716e1c 100644 --- a/bacula/src/qt-console/pages.h +++ b/bacula/src/qt-console/pages.h @@ -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(); diff --git a/bacula/src/qt-console/restore/restoretree.cpp b/bacula/src/qt-console/restore/restoretree.cpp index 8c37d650b5..6aa4b54d03 100644 --- a/bacula/src/qt-console/restore/restoretree.cpp +++ b/bacula/src/qt-console/restore/restoretree.cpp @@ -360,12 +360,13 @@ void restoreTree::parseDirectory(QString &dir_in) } for (int k=0; km_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) { diff --git a/bacula/src/qt-console/status/clientstat.cpp b/bacula/src/qt-console/status/clientstat.cpp index 28b7caeb43..0ef28f89b3 100644 --- a/bacula/src/qt-console/status/clientstat.cpp +++ b/bacula/src/qt-console/status/clientstat.cpp @@ -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; } diff --git a/bacula/src/qt-console/status/dirstat.cpp b/bacula/src/qt-console/status/dirstat.cpp index a0becc182a..911c1a6c55 100644 --- a/bacula/src/qt-console/status/dirstat.cpp +++ b/bacula/src/qt-console/status/dirstat.cpp @@ -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; } diff --git a/bacula/src/qt-console/status/storstat.cpp b/bacula/src/qt-console/status/storstat.cpp index d624763359..d9dfd9dba9 100644 --- a/bacula/src/qt-console/status/storstat.cpp +++ b/bacula/src/qt-console/status/storstat.cpp @@ -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; } diff --git a/bacula/src/qt-console/storage/storage.cpp b/bacula/src/qt-console/storage/storage.cpp index 019ad781c8..9ba048ab0b 100644 --- a/bacula/src/qt-console/storage/storage.cpp +++ b/bacula/src/qt-console/storage/storage.cpp @@ -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); } } diff --git a/bacula/src/qt-console/storage/storage.h b/bacula/src/qt-console/storage/storage.h index 3faafd7dcd..c2be870a75 100644 --- a/bacula/src/qt-console/storage/storage.h +++ b/bacula/src/qt-console/storage/storage.h @@ -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(); diff --git a/bacula/src/qt-console/util/comboutil.cpp b/bacula/src/qt-console/util/comboutil.cpp index 8d893fd503..2e401d8de8 100644 --- a/bacula/src/qt-console/util/comboutil.cpp +++ b/bacula/src/qt-console/util/comboutil.cpp @@ -25,7 +25,7 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ - + /* * Version $Id$ * @@ -33,12 +33,13 @@ * * Riccardo Ghetta, May 2008 * - */ + */ #include #include #include #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) ); + } +} diff --git a/bacula/src/qt-console/util/comboutil.h b/bacula/src/qt-console/util/comboutil.h index c9e9d86b4c..8bc128a166 100644 --- a/bacula/src/qt-console/util/comboutil.h +++ b/bacula/src/qt-console/util/comboutil.h @@ -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_ */ diff --git a/bacula/src/qt-console/util/fmtwidgetitem.cpp b/bacula/src/qt-console/util/fmtwidgetitem.cpp index bb97e1d441..6b30a767de 100644 --- a/bacula/src/qt-console/util/fmtwidgetitem.cpp +++ b/bacula/src/qt-console/util/fmtwidgetitem.cpp @@ -42,9 +42,27 @@ #include #include #include -#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)) { diff --git a/bacula/src/qt-console/util/fmtwidgetitem.h b/bacula/src/qt-console/util/fmtwidgetitem.h index 324a8c64c5..66f3202691 100644 --- a/bacula/src/qt-console/util/fmtwidgetitem.h +++ b/bacula/src/qt-console/util/fmtwidgetitem.h @@ -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); -- 2.39.5