]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/restore/prerestore.cpp
Addressed issue of long compiles. Simplify with Pages::setCurrent
[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(Console *console)
43 {
44    console->notify(false);
45    m_name = "Pre-Restore";
46    setupUi(this);
47    QTreeWidgetItem *parent = mainWin->getFromHash(console);
48    if (!parent) {
49       /* ***FIXME*** */
50       printf("Error retrieving tree widget.");
51       return;
52    }
53    pgInitialize(parent);
54    m_closeable = true;
55
56    jobCombo->addItems(console->job_list);
57    filesetCombo->addItems(console->fileset_list);
58    clientCombo->addItems(console->client_list);
59    poolCombo->addItems(console->pool_list);
60    storageCombo->addItems(console->storage_list);
61    //beforeDateTime->setDate(QDateTime::currentDateTime().toUTC().date());
62    beforeDateTime->setDateTime(QDateTime::currentDateTime());
63    beforeDateTime->setEnabled(false);
64    job_name_change(0);
65    connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int)));
66    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
67    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
68
69    dockPage();
70    setCurrent();
71    this->show();
72 }
73
74 void prerestorePage::okButtonPushed()
75 {
76    QString cmd;
77
78    this->hide();
79    
80    cmd = QString(
81          "restore select current fileset=\"%1\" client=\"%2\" pool=\"%3\" "
82              "storage=\"%4\"\n")
83              .arg(filesetCombo->currentText())
84              .arg(clientCombo->currentText())
85              .arg(poolCombo->currentText())
86              .arg(storageCombo->currentText());
87
88    /* ***FIXME*** */
89    printf("preRestore command \"%s\"\n", cmd.toUtf8().data());
90    m_console->write(cmd);
91    m_console->display_text(cmd);
92    /* Note, do not turn notifier back on here ... */
93    new restorePage(m_console);
94    closeStackPage();
95 }
96
97
98 void prerestorePage::cancelButtonPushed()
99 {
100    mainWin->set_status("Canceled");
101    this->hide();
102    m_console->notify(true);
103    closeStackPage();
104 }
105
106
107 void prerestorePage::job_name_change(int index)
108 {
109    job_defaults job_defs;
110
111    (void)index;
112    job_defs.job_name = jobCombo->currentText();
113    if (m_console->get_job_defaults(job_defs)) {
114       filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
115       clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
116       poolCombo->setCurrentIndex(poolCombo->findText(job_defs.pool_name, Qt::MatchExactly));
117       storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
118    }
119 }