]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/run/prune.cpp
cf6c4b71a1198d9542c678c20e624d2477821ef2
[bacula/bacula] / bacula / src / qt-console / run / prune.cpp
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28  
29 /*
30  *  Run Dialog class
31  *
32  *   Kern Sibbald, February MMVII
33  *
34  *  $Id$
35  */ 
36
37 #include "bat.h"
38 #include "run.h"
39
40 /*
41  * Setup all the combo boxes and display the dialog
42  */
43 prunePage::prunePage(const QString &volume, const QString &client)
44 {
45    QDateTime dt;
46
47    m_name = tr("Prune");
48    pgInitialize();
49    setupUi(this);
50    m_console->notify(false);
51
52    QString query("SELECT VolumeName AS Media FROM Media ORDER BY Media");
53    if (mainWin->m_sqlDebug) {
54       Pmsg1(000, "Query cmd : %s\n",query.toUtf8().data());
55    }
56    QStringList results, volumeList;
57    if (m_console->sql_cmd(query, results)) {
58       QString field;
59       QStringList fieldlist;
60       /* Iterate through the lines of results. */
61       foreach (QString resultline, results) {
62          fieldlist = resultline.split("\t");
63          volumeList.append(fieldlist[0]);
64       } /* foreach resultline */
65    } /* if results from query */
66
67    volumeCombo->addItem(tr("Any"));
68    volumeCombo->addItems(volumeList);
69    clientCombo->addItem(tr("Any"));
70    clientCombo->addItems(m_console->client_list);
71    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
72    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
73    filesRadioButton->setChecked(true);
74    if (clientCombo->findText(client, Qt::MatchExactly) != -1)
75       clientCombo->setCurrentIndex(clientCombo->findText(client, Qt::MatchExactly));
76    else
77       clientCombo->setCurrentIndex(0);
78    if (volumeCombo->findText(volume, Qt::MatchExactly) != -1)
79       volumeCombo->setCurrentIndex(volumeCombo->findText(volume, Qt::MatchExactly));
80    else
81       volumeCombo->setCurrentIndex(0);
82    connect(volumeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(volumeChanged()));
83    connect(clientCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(clientChanged()));
84
85    dockPage();
86    setCurrent();
87    this->show();
88 }
89
90 void prunePage::okButtonPushed()
91 {
92    this->hide();
93    QString cmd("prune");
94    if (filesRadioButton->isChecked()) {
95       cmd += " files";
96    }
97    if (jobsRadioButton->isChecked()) {
98       cmd += " jobs";
99    }
100    if (filesRadioButton->isChecked()) {
101       cmd += " volume";
102    }
103    if (volumeCombo->currentText() != tr("Any")) {
104       cmd += " volume=\"" + volumeCombo->currentText() + "\"";
105    }
106    if (clientCombo->currentText() != tr("Any")) {
107       cmd += " client=\"" + clientCombo->currentText() + "\"";
108    }
109    cmd += " yes";
110
111    if (mainWin->m_commandDebug) {
112       Pmsg1(000, "command : %s\n", cmd.toUtf8().data());
113    }
114
115    consoleCommand(cmd);
116    m_console->notify(true);
117    closeStackPage();
118    mainWin->resetFocus();
119 }
120
121
122 void prunePage::cancelButtonPushed()
123 {
124    mainWin->set_status(tr(" Canceled"));
125    this->hide();
126    m_console->notify(true);
127    closeStackPage();
128    mainWin->resetFocus();
129 }
130
131 void prunePage::volumeChanged()
132 {
133    if ((volumeCombo->currentText() == tr("Any")) && (clientCombo->currentText() == tr("Any"))) {
134       clientCombo->setCurrentIndex(1);
135    }
136 }
137
138 void prunePage::clientChanged()
139 {
140    if ((volumeCombo->currentText() == tr("Any")) && (clientCombo->currentText() == tr("Any"))) {
141       volumeCombo->setCurrentIndex(1);
142    }
143 }