From c894fae8c75d1e2ff13a2f0fe823274294526276 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sun, 6 Apr 2008 18:50:04 +0000 Subject: [PATCH] Allow for the user to cancel more than one jobs from the director status interface at the same time git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6752 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/status/dirstat.cpp | 37 ++++++++++--- bacula/src/qt-console/status/dirstat.h | 2 + bacula/src/qt-console/status/dirstat.ui | 69 ++++++++++++++++++------ 3 files changed, 86 insertions(+), 22 deletions(-) diff --git a/bacula/src/qt-console/status/dirstat.cpp b/bacula/src/qt-console/status/dirstat.cpp index 06102b9734..fce1a794c6 100644 --- a/bacula/src/qt-console/status/dirstat.cpp +++ b/bacula/src/qt-console/status/dirstat.cpp @@ -261,7 +261,7 @@ void DirStat::populateRunning() field = field.trimmed(); /* strip leading & trailing spaces */ p_tableitem = new QTableWidgetItem(field, 1); p_tableitem->setForeground(blackBrush); - p_tableitem->setFlags(0); + p_tableitem->setFlags(Qt::ItemIsSelectable); runningTable->setItem(row, column, p_tableitem); column += 1; } @@ -309,6 +309,9 @@ void DirStat::createConnections() SLOT(consoleCancelJob())); connect(actionDisableScheduledJob, SIGNAL(triggered()), this, SLOT(consoleDisableJob())); + connect(runningTable, SIGNAL( + currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), + this, SLOT(runningTableItemChanged(QTableWidgetItem *, QTableWidgetItem *))); scheduledTable->setContextMenuPolicy(Qt::ActionsContextMenu); scheduledTable->addAction(actionRefresh); @@ -349,12 +352,10 @@ void DirStat::readSettings() */ void DirStat::consoleCancelJob() { - int currentrow = runningTable->currentRow(); - QTableWidgetItem *item = runningTable->item(currentrow, 0); - if (item) { - QString text = item->text(); + foreach( QString job, m_selectedJobsList ) + { QString cmd("cancel jobid="); - cmd += text; + cmd += job; consoleCommand(cmd); } } @@ -373,4 +374,28 @@ void DirStat::consoleDisableJob() consoleCommand(cmd); } } +/* + * Function to fill m_selectedJobsList with selected values + */ +void DirStat::runningTableItemChanged(QTableWidgetItem * /*currentItem*/, QTableWidgetItem * /*previousItem*/) +{ + QList rowList; + QList sitems = runningTable->selectedItems(); + foreach (QTableWidgetItem *sitem, sitems) { + int row = sitem->row(); + if (!rowList.contains(row)) { + rowList.append(row); + } + } + m_selectedJobsList.clear(); + foreach(int row, rowList) { + QTableWidgetItem * sitem = runningTable->item(row, 0); + m_selectedJobsList.append(sitem->text()); + } + if (m_selectedJobsList.count() > 1) { + actionCancelRunning->setText(QString("Cancel list of %1 Jobs").arg(m_selectedJobsList.count())); + } else { + actionCancelRunning->setText("Cancel Single Job"); + } +} diff --git a/bacula/src/qt-console/status/dirstat.h b/bacula/src/qt-console/status/dirstat.h index 8c81c1304f..97d00fe589 100644 --- a/bacula/src/qt-console/status/dirstat.h +++ b/bacula/src/qt-console/status/dirstat.h @@ -59,6 +59,7 @@ private slots: void timerTriggered(); void consoleCancelJob(); void consoleDisableJob(); + void runningTableItemChanged(QTableWidgetItem *, QTableWidgetItem *); private: void createConnections(); @@ -69,6 +70,7 @@ private: void getFont(); QString m_groupText, m_splitText; QTimer *m_timer; + QStringList m_selectedJobsList; }; #endif /* _DIRSTAT_H_ */ diff --git a/bacula/src/qt-console/status/dirstat.ui b/bacula/src/qt-console/status/dirstat.ui index 1ef8294c87..4d2b615f50 100644 --- a/bacula/src/qt-console/status/dirstat.ui +++ b/bacula/src/qt-console/status/dirstat.ui @@ -5,18 +5,30 @@ 0 0 - 504 - 410 + 409 + 326 Form - + 9 - + + 9 + + + 9 + + + 9 + + + 6 + + 6 @@ -26,9 +38,7 @@ - - 0 - 0 + 200 0 @@ -87,12 +97,21 @@ - - 0 - 6 + + 0 + + + 0 + + + 0 + + + 0 + @@ -116,12 +135,21 @@ p, li { white-space: pre-wrap; } - - 0 - 6 + + 0 + + + 0 + + + 0 + + + 0 + @@ -145,12 +173,21 @@ p, li { white-space: pre-wrap; } - - 0 - 6 + + 0 + + + 0 + + + 0 + + + 0 + -- 2.39.5