From: Dirk H Bartley Date: Sun, 31 May 2009 22:02:20 +0000 (+0000) Subject: Add columns for first media and volume count. Change some semantics of how X-Git-Tag: Release-3.0.2~186 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bf0872ce7c31798a0cfdff8c128beef36c3c8736;p=bacula%2Fbacula Add columns for first media and volume count. Change some semantics of how 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 --- diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 838746078e..6c77a9dc6a 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -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 rowList; QList 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); + } } } diff --git a/bacula/src/qt-console/joblist/joblist.h b/bacula/src/qt-console/joblist/joblist.h index 7138e3b507..9492a1cbe4 100644 --- a/bacula/src/qt-console/joblist/joblist.h +++ b/bacula/src/qt-console/joblist/joblist.h @@ -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_ */ diff --git a/bacula/src/qt-console/joblist/joblist.ui b/bacula/src/qt-console/joblist/joblist.ui index 91df743541..4f8fbf7e95 100644 --- a/bacula/src/qt-console/joblist/joblist.ui +++ b/bacula/src/qt-console/joblist/joblist.ui @@ -27,8 +27,8 @@ 20 220 - 545 - 154 + 565 + 146 @@ -368,6 +368,18 @@ + + 3 + + + 3 + + + 3 + + + 3 +