]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/restore/prerestore.cpp
Update description of PAGES and changes to TODO. Also removed spacers
[bacula/bacula] / bacula / src / qt-console / restore / prerestore.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  *   Version $Id: restore.cpp 4307 2007-03-04 10:24:39Z kerns $
31  *
32  *  preRestore -> dialog put up to determine the restore type
33  *
34  *   Kern Sibbald, February MMVII
35  *
36  */ 
37
38 #include "bat.h"
39 #include "restore.h"
40
41
42 prerestorePage::prerestorePage()
43 {
44    m_name = "Pre-Restore";
45    setupUi(this);
46    pgInitialize();
47    m_console->notify(false);
48    m_closeable = true;
49
50    jobCombo->addItems(m_console->job_list);
51    filesetCombo->addItems(m_console->fileset_list);
52    clientCombo->addItems(m_console->client_list);
53    poolCombo->addItems(m_console->pool_list);
54    storageCombo->addItems(m_console->storage_list);
55    beforeDateTime->setDateTime(QDateTime::currentDateTime());
56    beforeDateTime->setEnabled(false);
57    job_name_change(0);
58    connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int)));
59    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
60    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
61
62    dockPage();
63    setCurrent();
64    this->show();
65 }
66
67 void prerestorePage::okButtonPushed()
68 {
69    QString cmd;
70
71    this->hide();
72    
73    cmd = QString(
74          "restore select current fileset=\"%1\" client=\"%2\" pool=\"%3\" "
75              "storage=\"%4\"\n")
76              .arg(filesetCombo->currentText())
77              .arg(clientCombo->currentText())
78              .arg(poolCombo->currentText())
79              .arg(storageCombo->currentText());
80
81    /* ***FIXME*** */
82    //printf("preRestore command \"%s\"\n", cmd.toUtf8().data());
83    m_console->write(cmd);
84    m_console->display_text(cmd);
85    /* Note, do not turn notifier back on here ... */
86    new restorePage();
87    closeStackPage();
88 }
89
90
91 void prerestorePage::cancelButtonPushed()
92 {
93    mainWin->set_status("Canceled");
94    this->hide();
95    m_console->notify(true);
96    closeStackPage();
97 }
98
99
100 void prerestorePage::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(job_defs)) {
107       filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
108       clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
109       poolCombo->setCurrentIndex(poolCombo->findText(job_defs.pool_name, Qt::MatchExactly));
110       storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
111    }
112 }