From d82f42248a6cf071e946814fe21dcb61ff436c29 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Mon, 28 May 2007 11:51:53 +0000 Subject: [PATCH] Create a prune page. Populate it from medialist and clients. move m_contextActions.append from currentStackItem to constructor. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4923 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/bat.pro.in | 4 +- bacula/src/qt-console/clients/clients.cpp | 20 +- bacula/src/qt-console/clients/clients.h | 2 +- bacula/src/qt-console/clients/clients.ui | 29 +- bacula/src/qt-console/fileset/fileset.cpp | 7 +- bacula/src/qt-console/medialist/medialist.cpp | 27 +- bacula/src/qt-console/medialist/medialist.h | 1 + bacula/src/qt-console/medialist/medialist.ui | 10 +- bacula/src/qt-console/run/prune.cpp | 157 +++++++++ bacula/src/qt-console/run/prune.ui | 311 ++++++++++++++++++ bacula/src/qt-console/run/run.h | 18 + bacula/src/qt-console/storage/storage.cpp | 7 +- 12 files changed, 567 insertions(+), 26 deletions(-) create mode 100644 bacula/src/qt-console/run/prune.cpp create mode 100644 bacula/src/qt-console/run/prune.ui diff --git a/bacula/src/qt-console/bat.pro.in b/bacula/src/qt-console/bat.pro.in index 587cb9d6ae..7dc375575a 100644 --- a/bacula/src/qt-console/bat.pro.in +++ b/bacula/src/qt-console/bat.pro.in @@ -35,7 +35,7 @@ FORMS += relabel/relabel.ui FORMS += mount/mount.ui FORMS += console/console.ui FORMS += restore/restore.ui restore/prerestore.ui restore/brestore.ui -FORMS += run/run.ui run/runcmd.ui run/estimate.ui +FORMS += run/run.ui run/runcmd.ui run/estimate.ui run/prune.ui FORMS += select/select.ui FORMS += medialist/medialist.ui mediaedit/mediaedit.ui joblist/joblist.ui FORMS += clients/clients.ui storage/storage.ui fileset/fileset.ui @@ -67,7 +67,7 @@ SOURCES += mount/mount.cpp # Run dialog HEADERS += run/run.h -SOURCES += run/run.cpp run/runcmd.cpp run/estimate.cpp +SOURCES += run/run.cpp run/runcmd.cpp run/estimate.cpp run/prune.cpp # Select dialog HEADERS += select/select.h diff --git a/bacula/src/qt-console/clients/clients.cpp b/bacula/src/qt-console/clients/clients.cpp index 3e7b588911..81ec330bf7 100644 --- a/bacula/src/qt-console/clients/clients.cpp +++ b/bacula/src/qt-console/clients/clients.cpp @@ -39,6 +39,7 @@ #include #include "bat.h" #include "clients/clients.h" +#include "run/run.h" Clients::Clients() { @@ -52,6 +53,9 @@ Clients::Clients() m_populated = false; m_checkcurwidget = true; m_closeable = false; + /* add context sensitive menu items specific to this classto the page + * selector tree. m_contextActions is QList of QActions */ + m_contextActions.append(actionRefreshClients); } Clients::~Clients() @@ -159,6 +163,7 @@ void Clients::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte mp_treeWidget->removeAction(actionListJobsofClient); mp_treeWidget->removeAction(actionStatusClientInConsole); mp_treeWidget->removeAction(actionPurgeJobs); + mp_treeWidget->removeAction(actionPrune); } } @@ -170,6 +175,7 @@ void Clients::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte mp_treeWidget->addAction(actionListJobsofClient); mp_treeWidget->addAction(actionStatusClientInConsole); mp_treeWidget->addAction(actionPurgeJobs); + mp_treeWidget->addAction(actionPrune); } } } @@ -195,6 +201,8 @@ void Clients::createContextMenu() SLOT(consoleStatusClient())); connect(actionPurgeJobs, SIGNAL(triggered()), this, SLOT(consolePurgeJobs())); + connect(actionPrune, SIGNAL(triggered()), this, + SLOT(prune())); } /* @@ -226,10 +234,6 @@ void Clients::currentStackItem() { if(!m_populated) { populateTree(); - /* add context sensitive menu items specific to this classto the page - * selector tree. m_contextActions is QList of QActions, so this is - * only done once with the first population. */ - m_contextActions.append(actionRefreshClients); /* Create the context menu for the client tree */ createContextMenu(); m_populated=true; @@ -260,3 +264,11 @@ void Clients::consolePurgeJobs() consoleCommand(cmd); } +/* + * Function responding to actionPrune + */ +void Clients::prune() +{ + new prunePage("", m_currentlyselected); +} + diff --git a/bacula/src/qt-console/clients/clients.h b/bacula/src/qt-console/clients/clients.h index ea07fb03d8..3b10f7f12e 100644 --- a/bacula/src/qt-console/clients/clients.h +++ b/bacula/src/qt-console/clients/clients.h @@ -37,7 +37,6 @@ #include "ui_clients.h" #include "console.h" #include "pages.h" -//#include class Clients : public Pages, public Ui::ClientForm { @@ -57,6 +56,7 @@ private slots: void showJobs(); void consoleStatusClient(); void consolePurgeJobs(); + void prune(); private: void createContextMenu(); diff --git a/bacula/src/qt-console/clients/clients.ui b/bacula/src/qt-console/clients/clients.ui index 8311bc3953..11edc4c1d2 100644 --- a/bacula/src/qt-console/clients/clients.ui +++ b/bacula/src/qt-console/clients/clients.ui @@ -25,7 +25,7 @@ - ../../../../../../../:images/run.png + images/run.png Refresh Client List @@ -36,24 +36,47 @@ - ../../../../../../../:images/unmark.png + images/unmark.png List Jobs of Client + + Open a joblist page selecting this client. + - ../../../../../../../:images/status.png + images/status.png Status Client In Console + + Execute status client in console. + + + images/unmark.png + Purge Jobs + + Purge jobs peformed from this client. + + + + + images/unmark.png + + + Prune Jobs + + + Open the diaolog to prune for this client. + diff --git a/bacula/src/qt-console/fileset/fileset.cpp b/bacula/src/qt-console/fileset/fileset.cpp index c9b10c63fc..e346760c9a 100644 --- a/bacula/src/qt-console/fileset/fileset.cpp +++ b/bacula/src/qt-console/fileset/fileset.cpp @@ -53,6 +53,9 @@ FileSet::FileSet() m_checkcurwidget = true; m_closeable = false; readSettings(); + /* add context sensitive menu items specific to this classto the page + * selector tree. m_contextActions is QList of QActions */ + m_contextActions.append(actionRefreshFileSet); } FileSet::~FileSet() @@ -211,10 +214,6 @@ void FileSet::currentStackItem() { if(!m_populated) { populateTree(); - /* add context sensitive menu items specific to this classto the page - * selector tree. m_contextActions is QList of QActions, so this is - * only done once with the first population. */ - m_contextActions.append(actionRefreshFileSet); /* Create the context menu for the fileset tree */ createContextMenu(); m_populated=true; diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 9da7cc9055..f558572627 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -42,6 +42,7 @@ #include "mediaedit/mediaedit.h" #include "joblist/joblist.h" #include "relabel/relabel.h" +#include "run/run.h" MediaList::MediaList() { @@ -55,6 +56,9 @@ MediaList::MediaList() m_populated = false; m_checkcurwidget = true; m_closeable = false; + /* add context sensitive menu items specific to this classto the page + * selector tree. m_contextActions is QList of QActions */ + m_contextActions.append(actionRefreshMediaList); } MediaList::~MediaList() @@ -202,6 +206,7 @@ void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetI mp_treeWidget->removeAction(actionEditVolume); mp_treeWidget->removeAction(actionListJobsOnVolume); mp_treeWidget->removeAction(actionDeleteVolume); + mp_treeWidget->removeAction(actionPruneVolume); mp_treeWidget->removeAction(actionPurgeVolume); mp_treeWidget->removeAction(actionRelabelVolume); } @@ -214,6 +219,7 @@ void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetI mp_treeWidget->addAction(actionEditVolume); mp_treeWidget->addAction(actionListJobsOnVolume); mp_treeWidget->addAction(actionDeleteVolume); + mp_treeWidget->addAction(actionPruneVolume); mp_treeWidget->addAction(actionPurgeVolume); mp_treeWidget->addAction(actionRelabelVolume); } @@ -233,6 +239,7 @@ void MediaList::createContextMenu() connect(actionListJobsOnVolume, SIGNAL(triggered()), this, SLOT(showJobs())); connect(actionDeleteVolume, SIGNAL(triggered()), this, SLOT(deleteVolume())); connect(actionPurgeVolume, SIGNAL(triggered()), this, SLOT(purgeVolume())); + connect(actionPruneVolume, SIGNAL(triggered()), this, SLOT(pruneVolume())); connect(actionRelabelVolume, SIGNAL(triggered()), this, SLOT(relabelVolume())); connect(mp_treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), @@ -249,10 +256,6 @@ void MediaList::currentStackItem() { if(!m_populated) { populateTree(); - /* add context sensitive menu items specific to this classto the page - * selector tree. m_contextActions is QList of QActions, so this is - * only done once with the first population. */ - m_contextActions.append(actionRefreshMediaList); /* Create the context menu for the medialist tree */ createContextMenu(); m_populated=true; @@ -260,7 +263,7 @@ void MediaList::currentStackItem() } /* - * Called from the signal of the context sensitive menu! + * Called from the signal of the context sensitive menu to delete a volume! */ void MediaList::deleteVolume() { @@ -280,8 +283,9 @@ void MediaList::deleteVolume() cmd += m_currentVolumeName; consoleCommand(cmd); } + /* - * Called from the signal of the context sensitive menu! + * Called from the signal of the context sensitive menu to purge! */ void MediaList::purgeVolume() { @@ -302,8 +306,17 @@ void MediaList::purgeVolume() consoleCommand(cmd); populateTree(); } + /* - * Called from the signal of the context sensitive menu! + * Called from the signal of the context sensitive menu to prune! + */ +void MediaList::pruneVolume() +{ + new prunePage(m_currentVolumeName, ""); +} + +/* + * Called from the signal of the context sensitive menu to relabel! */ void MediaList::relabelVolume() { diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index 52a6ca69be..143e83a3ad 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -57,6 +57,7 @@ private slots: void editVolume(); void deleteVolume(); void purgeVolume(); + void pruneVolume(); void relabelVolume(); private: diff --git a/bacula/src/qt-console/medialist/medialist.ui b/bacula/src/qt-console/medialist/medialist.ui index 69e45d0e48..71b8383dd9 100644 --- a/bacula/src/qt-console/medialist/medialist.ui +++ b/bacula/src/qt-console/medialist/medialist.ui @@ -58,6 +58,14 @@ Delete Volume + + + :images/unmark.png + + + Prune Volume + + :images/unmark.png @@ -68,7 +76,7 @@ - ../images/unmark.png + :images/unmark.png Relabel Volume diff --git a/bacula/src/qt-console/run/prune.cpp b/bacula/src/qt-console/run/prune.cpp new file mode 100644 index 0000000000..b64bd581b2 --- /dev/null +++ b/bacula/src/qt-console/run/prune.cpp @@ -0,0 +1,157 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ + +/* + * Run Dialog class + * + * Kern Sibbald, February MMVII + * + * $Id: prune.cpp 4856 2007-05-20 15:28:43Z bartleyd2 $ + */ + +#include "bat.h" +#include "run.h" + +/* + * Setup all the combo boxes and display the dialog + */ +prunePage::prunePage(const QString &volume, const QString &client) +{ + QDateTime dt; + + m_name = "Prune"; + pgInitialize(); + setupUi(this); + m_console->notify(false); + + QString query("SELECT VolumeName AS Media FROM Media ORDER BY Media"); + if (mainWin->m_sqlDebug) { + Pmsg1(000, "Query cmd : %s\n",query.toUtf8().data()); + } + QStringList results, volumeList; + if (m_console->sql_cmd(query, results)) { + QString field; + QStringList fieldlist; + /* Iterate through the lines of results. */ + foreach (QString resultline, results) { + fieldlist = resultline.split("\t"); + volumeList.append(fieldlist[0]); + } /* foreach resultline */ + } /* if results from query */ + + volumeCombo->addItem("Any"); + volumeCombo->addItems(volumeList); + clientCombo->addItem("Any"); + clientCombo->addItems(m_console->client_list); + connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed())); + connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed())); + filesCheckBox->setCheckState(Qt::Checked); + jobsCheckBox->setCheckState(Qt::Checked); + volumeCheckBox->setCheckState(Qt::Checked); + connect(filesCheckBox, SIGNAL(stateChanged(int)), this, SLOT(checkStateChanged())); + connect(jobsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(checkStateChanged())); + connect(volumeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(checkStateChanged())); + if (clientCombo->findText(client, Qt::MatchExactly) != -1) + clientCombo->setCurrentIndex(clientCombo->findText(client, Qt::MatchExactly)); + else + clientCombo->setCurrentIndex(0); + if (volumeCombo->findText(volume, Qt::MatchExactly) != -1) + volumeCombo->setCurrentIndex(volumeCombo->findText(volume, Qt::MatchExactly)); + else + volumeCombo->setCurrentIndex(0); + connect(volumeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(volumeChanged())); + connect(clientCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(clientChanged())); + + dockPage(); + setCurrent(); + this->show(); +} + +void prunePage::okButtonPushed() +{ + this->hide(); + QString cmd("prune"); + if (filesCheckBox->checkState() == Qt::Checked) { + cmd += " files"; + } + if (jobsCheckBox->checkState() == Qt::Checked) { + cmd += " jobs"; + } + if (filesCheckBox->checkState() == Qt::Checked) { + cmd += " volume"; + } + if (volumeCombo->currentText() != "Any") { + cmd += " volume=\"" + volumeCombo->currentText() + "\""; + } + if (clientCombo->currentText() != "Any") { + cmd += " client=\"" + clientCombo->currentText() + "\""; + } + cmd += " yes"; + + if (mainWin->m_commandDebug) { + Pmsg1(000, "command : %s\n", cmd.toUtf8().data()); + } + + consoleCommand(cmd); + m_console->notify(true); + closeStackPage(); + mainWin->resetFocus(); +} + + +void prunePage::cancelButtonPushed() +{ + mainWin->set_status(" Canceled"); + this->hide(); + m_console->notify(true); + closeStackPage(); + mainWin->resetFocus(); +} + +void prunePage::checkStateChanged() +{ + if ((filesCheckBox->checkState() == Qt::Unchecked) && + (jobsCheckBox->checkState() == Qt::Unchecked) && + (volumeCheckBox->checkState() == Qt::Unchecked)) { + filesCheckBox->setCheckState(Qt::Checked); + } +} + +void prunePage::volumeChanged() +{ + if ((volumeCombo->currentText() == "Any") && (clientCombo->currentText() == "Any")) { + clientCombo->setCurrentIndex(1); + } +} + +void prunePage::clientChanged() +{ + if ((volumeCombo->currentText() == "Any") && (clientCombo->currentText() == "Any")) { + volumeCombo->setCurrentIndex(1); + } +} diff --git a/bacula/src/qt-console/run/prune.ui b/bacula/src/qt-console/run/prune.ui new file mode 100644 index 0000000000..6a1f29f576 --- /dev/null +++ b/bacula/src/qt-console/run/prune.ui @@ -0,0 +1,311 @@ + + pruneForm + + + + 0 + 0 + 501 + 326 + + + + Form + + + + 9 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 351 + 16 + + + + + + + + 0 + + + 6 + + + + + + + + 0 + + + 6 + + + + + Qt::RightToLeft + + + Prune Volumes + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 71 + 21 + + + + + + + + + 16777215 + 30 + + + + <h3>Prune Files/Jobs/Volumes</h3> + + + + + + + Qt::Horizontal + + + + 81 + 20 + + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + 0 + + + 6 + + + + + Qt::RightToLeft + + + Prune Jobs + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 65 + 16777215 + + + + Client: + + + clientCombo + + + + + + + 0 + + + 6 + + + + + Qt::RightToLeft + + + Prune Files + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Volume: + + + volumeCombo + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 351 + 16 + + + + + + + + + diff --git a/bacula/src/qt-console/run/run.h b/bacula/src/qt-console/run/run.h index f077d4e4f6..41232daac7 100644 --- a/bacula/src/qt-console/run/run.h +++ b/bacula/src/qt-console/run/run.h @@ -6,6 +6,7 @@ #include "ui_run.h" #include "ui_runcmd.h" #include "ui_estimate.h" +#include "ui_prune.h" #include "console.h" class runPage : public Pages, public Ui::runForm @@ -53,4 +54,21 @@ public slots: private: }; +class prunePage : public Pages, public Ui::pruneForm +{ + Q_OBJECT + +public: + prunePage(const QString &volume, const QString &client); + +public slots: + void okButtonPushed(); + void cancelButtonPushed(); + void checkStateChanged(); + void volumeChanged(); + void clientChanged(); + +private: +}; + #endif /* _RUN_H_ */ diff --git a/bacula/src/qt-console/storage/storage.cpp b/bacula/src/qt-console/storage/storage.cpp index 0069a589a6..153319ac93 100644 --- a/bacula/src/qt-console/storage/storage.cpp +++ b/bacula/src/qt-console/storage/storage.cpp @@ -55,6 +55,9 @@ Storage::Storage() m_checkcurwidget = true; m_closeable = false; m_currentStorage = ""; + /* add context sensitive menu items specific to this classto the page + * selector tree. m_contextActions is QList of QActions */ + m_contextActions.append(actionRefreshStorage); } Storage::~Storage() @@ -220,10 +223,6 @@ void Storage::currentStackItem() { if(!m_populated) { populateTree(); - /* add context sensitive menu items specific to this classto the page - * selector tree. m_contextActions is QList of QActions, so this is - * only done once with the first population. */ - m_contextActions.append(actionRefreshStorage); /* Create the context menu for the storage tree */ createContextMenu(); m_populated=true; -- 2.39.5