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