]> git.sur5r.net Git - bacula/bacula/commitdiff
Allow for the user to cancel more than one jobs from the director status
authorDirk H Bartley <dbartley@schupan.com>
Sun, 6 Apr 2008 18:50:04 +0000 (18:50 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Sun, 6 Apr 2008 18:50:04 +0000 (18:50 +0000)
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
bacula/src/qt-console/status/dirstat.h
bacula/src/qt-console/status/dirstat.ui

index 06102b97340a46c022abffc67aba5fb8f7f51039..fce1a794c63d122b315b435158507ce84e0de3ee 100644 (file)
@@ -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<int> rowList;
+   QList<QTableWidgetItem *> 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");
+   }
+}
index 8c81c1304f7b340dcf444a92c1fe6f7db83ae2b5..97d00fe5890b049681b0c983ac66aa8f9d4c907c 100644 (file)
@@ -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_ */
index 1ef8294c87c5a472aacb8b4f5f61aa52478362fd..4d2b615f501fa7dbcae2ca34fc21ff11e28b28c1 100644 (file)
@@ -5,18 +5,30 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>504</width>
-    <height>410</height>
+    <width>409</width>
+    <height>326</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <string>Form</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" >
@@ -26,9 +38,7 @@
      </property>
      <widget class="QTextEdit" name="textEdit" >
       <property name="sizePolicy" >
-       <sizepolicy>
-        <hsizetype>0</hsizetype>
-        <vsizetype>0</vsizetype>
+       <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
         <horstretch>200</horstretch>
         <verstretch>0</verstretch>
        </sizepolicy>
      </widget>
      <widget class="QWidget" name="layoutWidget" >
       <layout class="QVBoxLayout" >
-       <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>
         <widget class="QLabel" name="scheduledLabel" >
          <property name="layoutDirection" >
@@ -116,12 +135,21 @@ p, li { white-space: pre-wrap; }
      </widget>
      <widget class="QWidget" name="layoutWidget_2" >
       <layout class="QVBoxLayout" >
-       <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>
         <widget class="QLabel" name="runningLabel" >
          <property name="layoutDirection" >
@@ -145,12 +173,21 @@ p, li { white-space: pre-wrap; }
      </widget>
      <widget class="QWidget" name="layoutWidget" >
       <layout class="QVBoxLayout" >
-       <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>
         <widget class="QLabel" name="terminatedLabel" >
          <property name="layoutDirection" >