]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/restore/restoretreerun.cpp
Set keyword replacement on files
[bacula/bacula] / bacula / src / qt-console / restore / restoretreerun.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 Command Dialog class
31  *
32  *  This is called when a Run Command signal is received from the
33  *    Director. We parse the Director's output and throw up a 
34  *    dialog box.  This happens, for example, after the user finishes
35  *    selecting files to be restored. The Director will then submit a
36  *    run command, that causes this page to be popped up.
37  *
38  *   Kern Sibbald, March MMVII
39  *
40  *  $Id$
41  */ 
42
43 #include "bat.h"
44 #include "restoretreerun.h"
45
46 /*
47  * Setup all the combo boxes and display the dialog
48  */
49 restoreTreeRunPage::restoreTreeRunPage(QString &table, QString &client, QList<int> &jobs, QTreeWidgetItem* parentItem)
50 {
51    m_tempTable = table;
52    m_jobList = jobs;
53    m_client = client;
54    m_name = "Restore Tree Run";
55    pgInitialize(parentItem);
56    setupUi(this);
57    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
58    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/restore.png")));
59    m_console->notify(false);
60
61    fill();
62    m_console->discardToPrompt();
63
64    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
65    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
66    dockPage();
67    setCurrent();
68    this->show();
69 }
70
71 void restoreTreeRunPage::fill()
72 {
73    QDateTime dt;
74    clientCombo->addItems(m_console->client_list);
75    clientCombo->setCurrentIndex(clientCombo->findText(m_client, Qt::MatchExactly));
76    replaceCombo->addItems(QStringList() << "never" << "always" << "ifnewer" << "ifolder");
77    replaceCombo->setCurrentIndex(replaceCombo->findText("never", Qt::MatchExactly));
78    dateTimeEdit->setDisplayFormat(mainWin->m_dtformat);
79    dateTimeEdit->setDateTime(dt.currentDateTime());
80 }
81
82 void restoreTreeRunPage::okButtonPushed()
83 {
84    QString jobOption = " jobid=\"";
85    bool first = true;
86    foreach (int job, m_jobList) {
87       if (first) first = false;
88       else jobOption += ",";
89       jobOption += QString("%1").arg(job);
90    }
91    jobOption += "\"";
92    QString cmd = QString("restore");
93    cmd += jobOption + 
94           " file=\"?" + m_tempTable + "\" yes"
95           " replace=\"" + replaceCombo->currentText() + "\""
96           " when=\"" + dateTimeEdit->dateTime().toString(mainWin->m_dtformat) + "\""
97           " restoreclient=\"" + clientCombo->currentText() + "\"";
98    if (mainWin->m_commandDebug)
99       Pmsg1(000, "preRestore command \'%s\'\n", cmd.toUtf8().data());
100    consoleCommand(cmd);
101    mainWin->resetFocus();
102    closeStackPage();
103
104 /*   QString cmd(".mod");
105    cmd += " bootstrap=\"" + bootstrap->text() + "\"";
106    cmd += " where=\"" + where->text() + "\"";
107    QString pri;
108    QTextStream(&pri) << " priority=\"" << prioritySpin->value() << "\"";
109    cmd += pri;
110    cmd += " yes\n"; */
111 }
112
113
114 void restoreTreeRunPage::cancelButtonPushed()
115 {
116    m_console->displayToPrompt();
117    m_console->write_dir(".");
118    m_console->displayToPrompt();
119    mainWin->set_status(" Canceled");
120    this->hide();
121    m_console->notify(true);
122    closeStackPage();
123    mainWin->resetFocus();
124 }