]> git.sur5r.net Git - bacula/bacula/commitdiff
Allow table items to be selectable. If items are selected, then check to see if two
authorDirk H Bartley <dbartley@schupan.com>
Tue, 15 Jan 2008 03:05:37 +0000 (03:05 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Tue, 15 Jan 2008 03:05:37 +0000 (03:05 +0000)
are selected, set value to be used if deleting jobs so that more than one job can be
deleted at a time.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6290 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/joblist/joblist.cpp
bacula/src/qt-console/joblist/joblist.h

index 4664cd552cbd975cf58e3b3f049b178c1635d95a..2157970ba685b0a899caf543eb6fc48d32c87b6c 100644 (file)
@@ -231,6 +231,7 @@ void JobList::populateTable()
    QStringList headerlist = (QStringList()
       << "Job Id" << "Job Name" << "Client" << "Job Starttime" << "Job Type" 
       << "Job Level" << "Job Files" << "Job Bytes" << "Job Status"  << "Purged" << "File Set" );
+   m_jobIdIndex = headerlist.indexOf("Job Id");
    m_purgedIndex = headerlist.indexOf("Purged");
    m_typeIndex = headerlist.indexOf("Job Type");
    m_statusIndex = headerlist.indexOf("Job Status");
@@ -270,8 +271,8 @@ void JobList::populateTable()
                m_statusIndexDone = true;
                statusCode = field;
             } else {
-               p_tableitem = new QTableWidgetItem(field,1);
-               p_tableitem->setFlags(0);
+               p_tableitem = new QTableWidgetItem(field, 1);
+               p_tableitem->setFlags(Qt::ItemIsSelectable);
                p_tableitem->setForeground(blackBrush);
                mp_tableWidget->setItem(row, column, p_tableitem);
                if (column == m_statusIndex)
@@ -367,6 +368,7 @@ void JobList::tableItemChanged(QTableWidgetItem *currentItem, QTableWidgetItem *
       int row = currentItem->row();
       QTableWidgetItem* jobitem = mp_tableWidget->item(row, 0);
       m_currentJob = jobitem->text();
+      selectedJobsGet();
 
       /* include purged action or not */
       jobitem = mp_tableWidget->item(row, m_purgedIndex);
@@ -510,7 +512,7 @@ void JobList::consoleDeleteJob()
       == QMessageBox::Cancel) { return; }
 
    QString cmd("delete job jobid=");
-   cmd += m_currentJob;
+   cmd += m_selectedJobs;
    consoleCommand(cmd);
 }
 void JobList::consolePurgeFiles()
@@ -611,3 +613,34 @@ void JobList::readSettings()
    m_splitter->restoreState(settings.value(m_splitText).toByteArray());
    settings.endGroup();
 }
+
+/*
+ * Function to fill m_selectedJobsCount and m_selectedJobs with selected values
+ */
+void JobList::selectedJobsGet()
+{
+   QList<int> rowList;
+   QList<QTableWidgetItem *> sitems = mp_tableWidget->selectedItems();
+   foreach (QTableWidgetItem *sitem, sitems) {
+      int row = sitem->row();
+      if (!rowList.contains(row)) {
+         rowList.append(row);
+      }
+   }
+
+   m_selectedJobs = "";
+   bool first = true;
+   foreach(int row, rowList) {
+      QTableWidgetItem * sitem = mp_tableWidget->item(row, m_jobIdIndex);
+      if (!first) m_selectedJobs.append(",");
+      else first = false;
+      m_selectedJobs.append(sitem->text());
+   }
+   m_selectedJobsCount = rowList.count();
+   if (m_selectedJobsCount > 1) {
+      QString text = QString("Delete list of %1 Jobs").arg(m_selectedJobsCount);
+      actionDeleteJob->setText(text);
+   } else {
+      actionDeleteJob->setText("Delete Single Job");
+   }
+}
index f16fbd9e02bfa206f7dd613f9a38b41f3e6c78e8..15ec02c28d53b4172e531aa8dc148c623e521fa0 100644 (file)
@@ -74,6 +74,7 @@ private:
    void setStatusColor(QTableWidgetItem *item, QString &field);
    void writeSettings();
    void readSettings();
+   void selectedJobsGet();
    QSplitter *m_splitter;
    QString m_groupText;
    QString m_splitText;
@@ -84,12 +85,15 @@ private:
    QString m_currentJob;
    bool m_populated;
    bool m_checkCurrentWidget;
+   int m_jobIdIndex;
    int m_purgedIndex;
    int m_typeIndex;
    int m_statusIndex;
    int m_startIndex;
    int m_bytesIndex;
    int m_filesIndex;
+   int m_selectedJobsCount;
+   QString m_selectedJobs;
 };
 
 #endif /* _JOBLIST_H_ */