From: Dirk H Bartley Date: Sun, 20 May 2007 16:04:27 +0000 (+0000) Subject: Cancel a running job from joblist. X-Git-Tag: Release-7.0.0~6288 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5d3c9810a0148e0b4b421ec3cb0e7f7b1138b7a6;p=bacula%2Fbacula Cancel a running job from joblist. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4857 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/TODO b/bacula/src/qt-console/TODO index c8dd24af34..bf4d3dc4d5 100644 --- a/bacula/src/qt-console/TODO +++ b/bacula/src/qt-console/TODO @@ -1,10 +1,5 @@ dhb ==================================================== -joblist cancel a running job. - -Fixes to final restore widgets. - all but messages done. - Add context sensitive options for most commands status dir on page select director item All items with jobid= that I thought could work from joblist are done. @@ -76,6 +71,10 @@ global one defined in the mainWin class (if I remember right). ============================================================ DONE: ============================================================ +joblist cancel a running job. + +Fixes to final restore widgets. + Set default for replace in run restore job to "always"?????? Option in joblist like with restore from jobid but restore populating timestamp diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index d31043709d..fbca3d3196 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -209,7 +209,7 @@ void JobList::populateTable() << "Job Level" << "Job Files" << "Job Bytes" << "Job Status" << "Purged" << "File Set" ); m_purgedIndex = headerlist.indexOf("Purged"); m_typeIndex = headerlist.indexOf("Job Type"); - statusIndex = headerlist.indexOf("Job Status"); + m_statusIndex = headerlist.indexOf("Job Status"); /* Initialize the QTableWidget */ m_checkCurrentWidget = false; @@ -234,20 +234,20 @@ void JobList::populateTable() foreach (resultline, results) { fieldlist = resultline.split("\t"); int column = 0; - bool statusIndexDone = false; + bool m_statusIndexDone = false; QString statusCode(""); /* Iterate through fields in the record */ foreach (field, fieldlist) { field = field.trimmed(); /* strip leading & trailing spaces */ - if ((column == statusIndex) && (!statusIndexDone)){ - statusIndexDone = true; + if ((column == m_statusIndex) && (!m_statusIndexDone)){ + m_statusIndexDone = true; statusCode = field; } else { p_tableitem = new QTableWidgetItem(field,1); p_tableitem->setFlags(0); p_tableitem->setForeground(blackBrush); mp_tableWidget->setItem(row, column, p_tableitem); - if (column == statusIndex) + if (column == m_statusIndex) setStatusColor(p_tableitem, statusCode); column++; } @@ -335,20 +335,30 @@ void JobList::tableItemChanged(QTableWidgetItem *currentItem, QTableWidgetItem * int row = currentItem->row(); QTableWidgetItem* jobitem = mp_tableWidget->item(row, 0); m_currentJob = jobitem->text(); + + /* include purged action or not */ jobitem = mp_tableWidget->item(row, m_purgedIndex); QString purged = jobitem->text(); mp_tableWidget->removeAction(actionPurgeFiles); if (purged == "0") { mp_tableWidget->addAction(actionPurgeFiles); } + /* include restore from time and job action or not */ jobitem = mp_tableWidget->item(row, m_typeIndex); - QString status = jobitem->text(); + QString type = jobitem->text(); mp_tableWidget->removeAction(actionRestoreFromJob); mp_tableWidget->removeAction(actionRestoreFromTime); - if (status == "B") { + if (type == "B") { mp_tableWidget->addAction(actionRestoreFromJob); mp_tableWidget->addAction(actionRestoreFromTime); } + /* include cancel action or not */ + jobitem = mp_tableWidget->item(row, m_statusIndex); + QString status = jobitem->text(); + mp_tableWidget->removeAction(actionCancelJob); + if (status == "Running") { + mp_tableWidget->addAction(actionCancelJob); + } } } @@ -408,6 +418,8 @@ void JobList::createConnections() SLOT(preRestoreFromTime())); connect(actionShowLogForJob, SIGNAL(triggered()), this, SLOT(showLogForJob())); + connect(actionCancelJob, SIGNAL(triggered()), this, + SLOT(consoleCancelJob())); } /* @@ -505,3 +517,13 @@ void JobList::showLogForJob() QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(this); new JobLog(m_currentJob, pageSelectorTreeWidgetItem); } + +/* + * Cancel a running job + */ +void JobList::consoleCancelJob() +{ + QString cmd("cancel jobid="); + cmd += m_currentJob; + consoleCommand(cmd); +} diff --git a/bacula/src/qt-console/joblist/joblist.h b/bacula/src/qt-console/joblist/joblist.h index 2f68096b85..f28ec2a237 100644 --- a/bacula/src/qt-console/joblist/joblist.h +++ b/bacula/src/qt-console/joblist/joblist.h @@ -64,6 +64,7 @@ private slots: void preRestoreFromJob(); void preRestoreFromTime(); void showLogForJob(); + void consoleCancelJob(); private: void createConnections(); @@ -75,6 +76,7 @@ private: bool m_checkCurrentWidget; int m_purgedIndex; int m_typeIndex; + int m_statusIndex; }; #endif /* _JOBLIST_H_ */ diff --git a/bacula/src/qt-console/joblist/joblist.ui b/bacula/src/qt-console/joblist/joblist.ui index fd67d053e1..9dd5637e31 100644 --- a/bacula/src/qt-console/joblist/joblist.ui +++ b/bacula/src/qt-console/joblist/joblist.ui @@ -324,7 +324,7 @@ - ../../../../../../../:images/run.png + :images/run.png Refresh Job List @@ -335,7 +335,7 @@ - ../../../../../../../:images/unmark.png + :images/unmark.png ListJobid @@ -343,7 +343,7 @@ - ../../../../../../../:images/unmark.png + :images/unmark.png List Files On Job @@ -351,7 +351,7 @@ - ../../../../../../../:images/unmark.png + :images/unmark.png ListJobMedia @@ -359,7 +359,7 @@ - ../../../../../../../:images/unmark.png + :images/unmark.png ListVolumes @@ -367,7 +367,7 @@ - ../../../../../../../:images/unmark.png + :images/unmark.png LongListJob @@ -375,7 +375,7 @@ - ../../../../../../../:images/unmark.png + :images/unmark.png DeleteJob @@ -383,7 +383,7 @@ - ../../../../../../../:images/unmark.png + :images/unmark.png PurgeFiles @@ -391,7 +391,7 @@ - ../../../../../../../:images/unmark.png + :images/unmark.png Restore From Job @@ -399,7 +399,7 @@ - ../../../../../../../:images/unmark.png + :images/unmark.png Restore From Time @@ -407,12 +407,20 @@ - ../../../../../../../:images/unmark.png + :images/unmark.png Show Log for Job + + + :images/unmark.png + + + Cancel Currently Running Job + +