]> git.sur5r.net Git - bacula/bacula/commitdiff
Add columns for first media and volume count. Change some semantics of how
authorDirk H Bartley <dbartley@schupan.com>
Sun, 31 May 2009 22:02:20 +0000 (22:02 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Sun, 31 May 2009 22:02:20 +0000 (22:02 +0000)
signals execute functions when a selection list is changed.

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

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

index 838746078e19bb4d4f434866cc180a3e52db883b..6c77a9dc6adb39cc9cf34b5a57b9b3571adf0437 100644 (file)
@@ -123,7 +123,7 @@ void JobList::populateTable()
       << tr("Job Id") << tr("Job Name") << tr("Client") << tr("Job Starttime") 
       << tr("Job Type") << tr("Job Level") << tr("Job Files") 
       << tr("Job Bytes") << tr("Job Status")  << tr("Purged") << tr("File Set")
-      << tr("Pool Name"));
+      << tr("Pool Name") << tr("First Volume") << tr("VolCount"));
 
    m_jobIdIndex = headerlist.indexOf(tr("Job Id"));
    m_purgedIndex = headerlist.indexOf(tr("Purged"));
@@ -203,6 +203,12 @@ void JobList::populateTable()
 
          /* pool name */
          jobitem.setTextFld(col++, fld.next());
+
+         /* First Media */
+         jobitem.setTextFld(col++, fld.next());
+
+         /* Medias count */
+         jobitem.setNumericFld(col++, fld.next());
          row++;
       }
    } 
@@ -275,13 +281,15 @@ void JobList::fillQueryString(QString &query)
       m_mediaName = volumeComboBox->itemText(volumeIndex);
    QString distinct = "";
    if (m_mediaName != tr("Any")) { distinct = "DISTINCT "; }
-   query += "SELECT " + distinct + "Job.Jobid AS Id, Job.Name AS JobName, " 
+   query += "SELECT " + distinct + "Job.JobId AS JobId, Job.Name AS JobName, " 
             " 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,"
             " Job.PurgedFiles AS Purged, FileSet.FileSet,"
-            " Pool.Name AS Pool"
+            " Pool.Name AS Pool,"
+            " (SELECT Media.VolumeName FROM JobMedia JOIN Media ON JobMedia.MediaId=Media.MediaId WHERE JobMedia.JobId=Job.JobId ORDER BY JobMediaId LIMIT 1) AS FirdtVolume,"
+            " (SELECT count(DISTINCT MediaId) FROM JobMedia WHERE JobMedia.JobId=Job.JobId) AS Volumes"
             " FROM Job"
             " JOIN Client ON (Client.ClientId=Job.ClientId)"
             " LEFT OUTER JOIN FileSet ON (FileSet.FileSetId=Job.FileSetId) "
@@ -365,43 +373,6 @@ void JobList::treeWidgetName(QString &desc)
    }
 }
 
-/*
- * This functions much line tableItemChanged for trees like the page selector,
- * but I will do much less here
- */
-void JobList::tableItemChanged(QTableWidgetItem *currentItem, QTableWidgetItem * /*previousItem*/)
-{
-   if (m_checkCurrentWidget) {
-      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 == tr("No") ) {
-         mp_tableWidget->addAction(actionPurgeFiles);
-      }
-      /* include restore from time and job action or not */
-      jobitem = mp_tableWidget->item(row, m_typeIndex);
-      QString type = jobitem->text();
-      mp_tableWidget->removeAction(actionRestoreFromJob);
-      mp_tableWidget->removeAction(actionRestoreFromTime);
-      if (type == tr("Backup")) {
-         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 == tr("Running") || status == tr("Created, not yet running")) {
-         mp_tableWidget->addAction(actionCancelJob);
-      }
-   }
-}
-
 /*
  * Function to create connections for context sensitive menu for this and
  * the page selector
@@ -419,14 +390,8 @@ void JobList::createConnections()
    graphButton->setEnabled(false);
    graphButton->setVisible(false);
 #endif
-   /* for the tableItemChanged to maintain m_currentJob */
-   connect(mp_tableWidget, SIGNAL(
-           currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
-           this, SLOT(tableItemChanged(QTableWidgetItem *, QTableWidgetItem *)));
-
-   /* for the tableItemChanged to maintain a delete selection */
-   connect(mp_tableWidget, SIGNAL( itemSelectionChanged()),
-           this, SLOT(selectedJobsGet()) );
+   /* for the selectionChanged to maintain m_currentJob and a delete selection */
+   connect(mp_tableWidget, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()));
 
    /* Do what is required for the local context sensitive menu */
 
@@ -434,19 +399,6 @@ void JobList::createConnections()
    /* setContextMenuPolicy is required */
    mp_tableWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
 
-   /* Add Actions */
-   mp_tableWidget->addAction(actionRefreshJobList);
-   mp_tableWidget->addAction(actionListJobid);
-   mp_tableWidget->addAction(actionListFilesOnJob);
-   mp_tableWidget->addAction(actionListJobMedia);
-   mp_tableWidget->addAction(actionListVolumes);
-   mp_tableWidget->addAction(actionDeleteJob);
-   mp_tableWidget->addAction(actionPurgeFiles);
-   mp_tableWidget->addAction(actionRestoreFromJob);
-   mp_tableWidget->addAction(actionRestoreFromTime);
-   mp_tableWidget->addAction(actionShowLogForJob);
-
-   /* Make Connections */
    connect(actionListJobid, SIGNAL(triggered()), this,
                 SLOT(consoleListJobid()));
    connect(actionListFilesOnJob, SIGNAL(triggered()), this,
@@ -544,9 +496,11 @@ void JobList::consolePurgeFiles()
       QMessageBox::Ok | QMessageBox::Cancel)
       == QMessageBox::Cancel) { return; }
 
-   QString cmd("purge files jobid=");
-   cmd += m_currentJob;
-   consoleCommand(cmd);
+   foreach(QString job, m_selectedJobsList) {
+      QString cmd("purge files jobid=");
+      cmd += job;
+      consoleCommand(cmd);
+   }
 }
 
 /*
@@ -635,7 +589,7 @@ void JobList::readSettings()
 /*
  * Function to fill m_selectedJobsCount and m_selectedJobs with selected values
  */
-void JobList::selectedJobsGet()
+void JobList::selectionChanged()
 {
    QList<int> rowList;
    QList<QTableWidgetItem *> sitems = mp_tableWidget->selectedItems();
@@ -647,18 +601,75 @@ void JobList::selectedJobsGet()
    }
 
    m_selectedJobs = "";
+   m_selectedJobsList.clear();
    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_selectedJobsList.append(sitem->text());
    }
    m_selectedJobsCount = rowList.count();
    if (m_selectedJobsCount > 1) {
-     QString text = QString( tr("Delete list of %1 Jobs")).arg(m_selectedJobsCount);
-       actionDeleteJob->setText(text);
+      QString text = QString( tr("Delete list of %1 Jobs")).arg(m_selectedJobsCount);
+      actionDeleteJob->setText(text);
+      text = QString( tr("Purge Files from list of %1 Jobs")).arg(m_selectedJobsCount);
+      actionPurgeFiles->setText(text);
    } else {
-     actionDeleteJob->setText(tr("Delete Single Job"));
+      actionDeleteJob->setText(tr("Delete Single Job"));
+      actionPurgeFiles->setText(tr("Purge Files from single job"));
+   }
+
+   /* remove all actions */
+   foreach(QAction* mediaAction, mp_tableWidget->actions()) {
+      mp_tableWidget->removeAction(mediaAction);
+   }
+
+   /* Add Actions */
+   mp_tableWidget->addAction(actionRefreshJobList);
+   if (m_selectedJobsCount == 1) {
+      mp_tableWidget->addAction(actionListJobid);
+      mp_tableWidget->addAction(actionListFilesOnJob);
+      mp_tableWidget->addAction(actionListJobMedia);
+      mp_tableWidget->addAction(actionListVolumes);
+      mp_tableWidget->addAction(actionRestoreFromJob);
+      mp_tableWidget->addAction(actionRestoreFromTime);
+      mp_tableWidget->addAction(actionShowLogForJob);
+   }
+   if (m_selectedJobsCount >= 1) {
+      mp_tableWidget->addAction(actionDeleteJob);
+      mp_tableWidget->addAction(actionPurgeFiles);
+   }
+
+   /* Make Connections */
+   if (m_checkCurrentWidget) {
+      int row = mp_tableWidget->currentRow();
+      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 == tr("No") ) {
+         mp_tableWidget->addAction(actionPurgeFiles);
+      }*/
+      /* include restore from time and job action or not */
+      jobitem = mp_tableWidget->item(row, m_typeIndex);
+      QString type = jobitem->text();
+      mp_tableWidget->removeAction(actionRestoreFromJob);
+      mp_tableWidget->removeAction(actionRestoreFromTime);
+      if (type == tr("Backup")) {
+         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 == tr("Running") || status == tr("Created, not yet running")) {
+         mp_tableWidget->addAction(actionCancelJob);
+      }
    }
 }
index 7138e3b50700e555a386b1602d2367e7c1065768..9492a1cbe49bc6753eecf8f771b9eebe88469342 100644 (file)
@@ -53,8 +53,7 @@ public:
 public slots:
    void populateTable();
    virtual void treeWidgetName(QString &);
-   void tableItemChanged(QTableWidgetItem *, QTableWidgetItem *);
-   void selectedJobsGet();
+   void selectionChanged();
 
 private slots:
    void consoleListJobid();
@@ -95,6 +94,7 @@ private:
    int m_filesIndex;
    int m_selectedJobsCount;
    QString m_selectedJobs;
+   QStringList m_selectedJobsList;
 };
 
 #endif /* _JOBLIST_H_ */
index 91df7435410befb5aec18ec816bd4a5848a81cad..4f8fbf7e953135df59c00b8680e8350cc331ef4e 100644 (file)
@@ -27,8 +27,8 @@
     <rect>
      <x>20</x>
      <y>220</y>
-     <width>545</width>
-     <height>154</height>
+     <width>565</width>
+     <height>146</height>
     </rect>
    </property>
    <property name="maximumSize" >
     </item>
     <item row="0" column="4" >
      <layout class="QVBoxLayout" >
+      <property name="leftMargin" >
+       <number>3</number>
+      </property>
+      <property name="topMargin" >
+       <number>3</number>
+      </property>
+      <property name="rightMargin" >
+       <number>3</number>
+      </property>
+      <property name="bottomMargin" >
+       <number>3</number>
+      </property>
       <item>
        <layout class="QVBoxLayout" >
         <property name="spacing" >