]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/run/run.cpp
Get bat select dialog working
[bacula/bacula] / bacula / src / qt-console / run / run.cpp
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2007 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 plus additions
11    that are listed 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 John Walker.
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 runDialog::runDialog(Console *console)
44 {
45    QDateTime dt;
46
47    m_console = console;
48    setupUi(this);
49    m_console->beginNewCommand();
50    jobCombo->addItems(console->job_list);
51    filesetCombo->addItems(console->fileset_list);
52    levelCombo->addItems(console->level_list);
53    clientCombo->addItems(console->client_list);
54    poolCombo->addItems(console->pool_list);
55    storageCombo->addItems(console->storage_list);
56    dateTimeEdit->setDateTime(dt.currentDateTime());
57    job_name_change(0);
58    connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int)));
59    this->show();
60 }
61
62 void runDialog::accept()
63 {
64    char cmd[1000];
65
66    this->hide();
67    
68    bsnprintf(cmd, sizeof(cmd),
69              "run job=\"%s\" fileset=\"%s\" level=%s client=\"%s\" pool=\"%s\" "
70              "when=\"%s\" storage=\"%s\" priority=\"%d\" yes\n",
71              jobCombo->currentText().toUtf8().data(),
72              filesetCombo->currentText().toUtf8().data(),
73              levelCombo->currentText().toUtf8().data(),
74              clientCombo->currentText().toUtf8().data(),
75              poolCombo->currentText().toUtf8().data(),
76 //           dateTimeEdit->textFromDateTime(dateTimeEdit->dateTime()).toUtf8().data(),
77              "",
78              storageCombo->currentText().toUtf8().data(),
79              prioritySpin->value());
80
81    m_console->write_dir(cmd);
82    m_console->display_text(cmd);
83    m_console->displayToPrompt();
84    delete this;
85    mainWin->resetFocus();
86 }
87
88
89 void runDialog::reject()
90 {
91    mainWin->set_status(" Canceled");
92    this->hide();
93    delete this;
94    mainWin->resetFocus();
95 }
96
97 /*
98  * Called here when the jobname combo box is changed.
99  *  We load the default values for the new job in the
100  *  other combo boxes.
101  */
102 void runDialog::job_name_change(int index)
103 {
104    job_defaults job_defs;
105
106    (void)index;
107    job_defs.job_name = jobCombo->currentText();
108    if (m_console->get_job_defaults(job_defs)) {
109       filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
110       levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, Qt::MatchExactly));
111       clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
112       poolCombo->setCurrentIndex(poolCombo->findText(job_defs.pool_name, Qt::MatchExactly));
113       storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
114       typeCombo->clear();
115       typeCombo->addItem(job_defs.type);
116    }
117 }