]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/run/run.cpp
Set keyword replacement on files
[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 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 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 runPage::runPage(const QString &defJob)
44 {
45    QDateTime dt;
46
47    m_name = "Run";
48    pgInitialize();
49    setupUi(this);
50    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
51    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/run.png")));
52    m_console->notify(false);
53
54    m_console->beginNewCommand();
55    jobCombo->addItems(m_console->job_list);
56    filesetCombo->addItems(m_console->fileset_list);
57    levelCombo->addItems(m_console->level_list);
58    clientCombo->addItems(m_console->client_list);
59    poolCombo->addItems(m_console->pool_list);
60    storageCombo->addItems(m_console->storage_list);
61    dateTimeEdit->setDisplayFormat(mainWin->m_dtformat);
62    dateTimeEdit->setDateTime(dt.currentDateTime());
63    /*printf("listing messages resources");  ***FIME ***
64    foreach(QString mes, m_console->messages_list) {
65       printf("%s\n", mes.toUtf8().data());
66    }*/
67    messagesCombo->addItems(m_console->messages_list);
68    messagesCombo->setEnabled(false);
69    job_name_change(0);
70    connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int)));
71    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
72    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
73
74    dockPage();
75    setCurrent();
76    this->show();
77    if (defJob != "")
78       jobCombo->setCurrentIndex(jobCombo->findText(defJob, Qt::MatchExactly));
79 }
80
81 void runPage::okButtonPushed()
82 {
83    this->hide();
84    QString cmd;
85    QTextStream(&cmd) << "run" << 
86       " job=\"" << jobCombo->currentText() << "\"" <<
87       " fileset=\"" << filesetCombo->currentText() << "\"" <<
88       " level=\"" << levelCombo->currentText() << "\"" <<
89       " client=\"" << clientCombo->currentText() << "\"" <<
90       " pool=\"" << poolCombo->currentText() << "\"" <<
91       " storage=\"" << storageCombo->currentText() << "\"" <<
92       " priority=\"" << prioritySpin->value() << "\""
93       " when=\"" << dateTimeEdit->dateTime().toString(mainWin->m_dtformat) << "\"";
94 #ifdef xxx
95       " messages=\"" << messagesCombo->currentText() << "\"";
96      /* FIXME when there is an option to modify the messages resoruce associated
97       * with a  job */
98 #endif
99    if (bootstrap->text() != "") {
100       cmd += " bootstrap=\"" + bootstrap->text() + "\""; 
101    }
102    cmd += " yes";
103
104    if (mainWin->m_commandDebug) {
105       Pmsg1(000, "command : %s\n", cmd.toUtf8().data());
106    }
107
108    consoleCommand(cmd);
109    m_console->notify(true);
110    closeStackPage();
111    mainWin->resetFocus();
112 }
113
114
115 void runPage::cancelButtonPushed()
116 {
117    mainWin->set_status(" Canceled");
118    this->hide();
119    m_console->notify(true);
120    closeStackPage();
121    mainWin->resetFocus();
122 }
123
124 /*
125  * Called here when the jobname combo box is changed.
126  *  We load the default values for the new job in the
127  *  other combo boxes.
128  */
129 void runPage::job_name_change(int index)
130 {
131    job_defaults job_defs;
132
133    (void)index;
134    job_defs.job_name = jobCombo->currentText();
135    if (m_console->get_job_defaults(job_defs)) {
136       filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
137       levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, Qt::MatchExactly));
138       clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
139       poolCombo->setCurrentIndex(poolCombo->findText(job_defs.pool_name, Qt::MatchExactly));
140       storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
141       messagesCombo->setCurrentIndex(messagesCombo->findText(job_defs.messages_name, Qt::MatchExactly));
142    }
143 }