]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/run/estimate.cpp
Fix invalid .mod command in BAT during restore
[bacula/bacula] / bacula / src / qt-console / run / estimate.cpp
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from many
7    others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    Bacula® is a registered trademark of Kern Sibbald.
15 */
16
17 /*
18  *  Run Dialog class
19  *
20  *   Kern Sibbald, February MMVII
21  *
22  *  $Id$
23  */
24
25 #include "bat.h"
26 #include "run.h"
27
28 /*
29  * Setup all the combo boxes and display the dialog
30  */
31 estimatePage::estimatePage() : Pages()
32 {
33    QDateTime dt;
34
35    m_name = tr("Estimate");
36    pgInitialize();
37    setupUi(this);
38    m_conn = m_console->notifyOff();
39
40    m_console->beginNewCommand(m_conn);
41    jobCombo->addItems(m_console->job_list);
42    filesetCombo->addItems(m_console->fileset_list);
43    levelCombo->addItems(m_console->level_list);
44    clientCombo->addItems(m_console->client_list);
45    job_name_change(0);
46    connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int)));
47    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
48    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
49    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
50    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/estimate-job.png")));
51
52    dockPage();
53    setCurrent();
54    this->show();
55    m_aButtonPushed = false;
56 }
57
58 void estimatePage::okButtonPushed()
59 {
60    if (m_aButtonPushed) return;
61    m_aButtonPushed = true;
62    this->hide();
63    QString cmd;
64    QTextStream(&cmd) << "estimate" <<
65       " job=\"" << jobCombo->currentText() << "\"" <<
66       " fileset=\"" << filesetCombo->currentText() << "\"" <<
67       " level=\"" << levelCombo->currentText() << "\"" <<
68       " client=\"" << clientCombo->currentText() << "\"";
69    if (listingCheckBox->checkState() == Qt::Checked) {
70       cmd += " listing";
71    }
72
73    if (mainWin->m_commandDebug) {
74       Pmsg1(000, "command : %s\n", cmd.toUtf8().data());
75    }
76
77    consoleCommand(cmd, m_conn, true, true);
78    m_console->notify(m_conn, true);
79    closeStackPage();
80    mainWin->resetFocus();
81 }
82
83
84 void estimatePage::cancelButtonPushed()
85 {
86    if (m_aButtonPushed) return;
87    m_aButtonPushed = true;
88    mainWin->set_status(" Canceled");
89    this->hide();
90    m_console->notify(m_conn, true);
91    closeStackPage();
92    mainWin->resetFocus();
93 }
94
95 /*
96  * Called here when the jobname combo box is changed.
97  *  We load the default values for the new job in the
98  *  other combo boxes.
99  */
100 void estimatePage::job_name_change(int index)
101 {
102    job_defaults job_defs;
103
104    (void)index;
105    job_defs.job_name = jobCombo->currentText();
106    if (m_console->get_job_defaults(m_conn, job_defs)) {
107       filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
108       levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, Qt::MatchExactly));
109       clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
110    }
111 }