From 6bc8ed6ce54a131fc87ce4f4bdcbd7bec4a6a91d Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Fri, 27 Jul 2007 02:43:58 +0000 Subject: [PATCH] This is an example of where I would like to go with offering the user the ability change options in the restore command like what is available in the runCmdPage class. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5249 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/bat.pro.in | 3 + bacula/src/qt-console/restore/restoretree.cpp | 19 +- .../src/qt-console/restore/restoretreerun.cpp | 124 ++++++ .../src/qt-console/restore/restoretreerun.h | 27 ++ .../src/qt-console/restore/restoretreerun.ui | 357 ++++++++++++++++++ 5 files changed, 514 insertions(+), 16 deletions(-) create mode 100644 bacula/src/qt-console/restore/restoretreerun.cpp create mode 100644 bacula/src/qt-console/restore/restoretreerun.h create mode 100644 bacula/src/qt-console/restore/restoretreerun.ui diff --git a/bacula/src/qt-console/bat.pro.in b/bacula/src/qt-console/bat.pro.in index 7f3de5d620..b56232bc38 100644 --- a/bacula/src/qt-console/bat.pro.in +++ b/bacula/src/qt-console/bat.pro.in @@ -37,6 +37,7 @@ FORMS += mount/mount.ui FORMS += console/console.ui FORMS += restore/restore.ui restore/prerestore.ui restore/brestore.ui FORMS += restore/restoretree.ui +FORMS += restore/restoretreerun.ui FORMS += run/run.ui run/runcmd.ui run/estimate.ui run/prune.ui FORMS += select/select.ui FORMS += medialist/medialist.ui mediaedit/mediaedit.ui joblist/joblist.ui @@ -115,6 +116,8 @@ SOURCES += jobs/jobs.cpp ## RestoreTree HEADERS += restore/restoretree.h SOURCES += restore/restoretree.cpp +HEADERS += restore/restoretreerun.h +SOURCES += restore/restoretreerun.cpp ## Job Step Graphs HEADERS += jobgraphs/jobplot.h diff --git a/bacula/src/qt-console/restore/restoretree.cpp b/bacula/src/qt-console/restore/restoretree.cpp index 4cbaa01694..a3f1210852 100644 --- a/bacula/src/qt-console/restore/restoretree.cpp +++ b/bacula/src/qt-console/restore/restoretree.cpp @@ -38,6 +38,7 @@ #include "bat.h" #include "restoretree.h" #include "pages.h" +#include "restoretreerun.h" restoreTree::restoreTree() { @@ -1422,22 +1423,8 @@ void restoreTree::testButtonPushed() } /* if (doneKeys.value(fversion, 0) == 0) */ } /* while (vFMiter.hasNext()) */ if (tempTable != "") { - QString jobOption = " jobid=\""; - bool first = true; - foreach (int job, jobList) { - if (first) first = false; - else jobOption += ","; - jobOption += QString("%1").arg(job); - } - jobOption += "\""; - QString cmd = QString("restore"); - cmd += " client=\"" + m_prevClientCombo + "\"" - + jobOption + - " file=\"?" + tempTable + "\" yes"; - if (mainWin->m_commandDebug) - Pmsg1(000, "preRestore command \'%s\'\n", cmd.toUtf8().data()); - consoleCommand(cmd); - mainWin->resetFocus(); + QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(this); + new restoreTreeRunPage(tempTable, m_prevClientCombo, jobList, pageSelectorTreeWidgetItem); } } diff --git a/bacula/src/qt-console/restore/restoretreerun.cpp b/bacula/src/qt-console/restore/restoretreerun.cpp new file mode 100644 index 0000000000..04acf86f0c --- /dev/null +++ b/bacula/src/qt-console/restore/restoretreerun.cpp @@ -0,0 +1,124 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ + +/* + * Run Command Dialog class + * + * This is called when a Run Command signal is received from the + * Director. We parse the Director's output and throw up a + * dialog box. This happens, for example, after the user finishes + * selecting files to be restored. The Director will then submit a + * run command, that causes this page to be popped up. + * + * Kern Sibbald, March MMVII + * + * $Id: $ + */ + +#include "bat.h" +#include "restoretreerun.h" + +/* + * Setup all the combo boxes and display the dialog + */ +restoreTreeRunPage::restoreTreeRunPage(QString &table, QString &client, QList &jobs, QTreeWidgetItem* parentItem) +{ + m_tempTable = table; + m_jobList = jobs; + m_client = client; + m_name = "Restore Tree Run"; + pgInitialize(parentItem); + setupUi(this); + QTreeWidgetItem* thisitem = mainWin->getFromHash(this); + thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/restore.png"))); + m_console->notify(false); + + fill(); + m_console->discardToPrompt(); + + connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed())); + connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed())); + dockPage(); + setCurrent(); + this->show(); +} + +void restoreTreeRunPage::fill() +{ + QDateTime dt; + clientCombo->addItems(m_console->client_list); + replaceCombo->addItems(QStringList() << "never" << "always" << "ifnewer" << "ifolder"); + replaceCombo->setCurrentIndex(replaceCombo->findText("never", Qt::MatchExactly)); + dateTimeEdit->setDisplayFormat(mainWin->m_dtformat); + dateTimeEdit->setDateTime(dt.currentDateTime()); +} + +void restoreTreeRunPage::okButtonPushed() +{ + QString jobOption = " jobid=\""; + bool first = true; + foreach (int job, m_jobList) { + if (first) first = false; + else jobOption += ","; + jobOption += QString("%1").arg(job); + } + jobOption += "\""; + QString cmd = QString("restore"); + cmd += " client=\"" + m_client + "\"" + + jobOption + + " file=\"?" + m_tempTable + "\" yes"; + if (mainWin->m_commandDebug) + Pmsg1(000, "preRestore command \'%s\'\n", cmd.toUtf8().data()); + consoleCommand(cmd); + mainWin->resetFocus(); + closeStackPage(); + +/* QString cmd(".mod"); + cmd += " restoreclient=\"" + clientCombo->currentText() + "\""; + cmd += " replace=\"" + replaceCombo->currentText() + "\""; + cmd += " when=\"" + dateTimeEdit->dateTime().toString(mainWin->m_dtformat) + "\""; + cmd += " bootstrap=\"" + bootstrap->text() + "\""; + cmd += " where=\"" + where->text() + "\""; + QString pri; + QTextStream(&pri) << " priority=\"" << prioritySpin->value() << "\""; + cmd += pri; + cmd += " yes\n"; */ +} + + +void restoreTreeRunPage::cancelButtonPushed() +{ + m_console->displayToPrompt(); + m_console->write_dir("."); + m_console->displayToPrompt(); + mainWin->set_status(" Canceled"); + this->hide(); + m_console->notify(true); + closeStackPage(); + mainWin->resetFocus(); +} diff --git a/bacula/src/qt-console/restore/restoretreerun.h b/bacula/src/qt-console/restore/restoretreerun.h new file mode 100644 index 0000000000..07f2672f83 --- /dev/null +++ b/bacula/src/qt-console/restore/restoretreerun.h @@ -0,0 +1,27 @@ + +#ifndef _RESTORETREERUN_H_ +#define _RESTORETREERUN_H_ + +#include +#include "ui_restoretreerun.h" +#include "console.h" + +class restoreTreeRunPage : public Pages, public Ui::restoreTreeRunForm +{ + Q_OBJECT + +public: + restoreTreeRunPage(QString &, QString &, QList &, QTreeWidgetItem*); + +public slots: + void okButtonPushed(); + void cancelButtonPushed(); + +private: + void fill(); + QString m_tempTable; + QString m_client; + QList m_jobList; +}; + +#endif /* _RESTORETREERUN_H_ */ diff --git a/bacula/src/qt-console/restore/restoretreerun.ui b/bacula/src/qt-console/restore/restoretreerun.ui new file mode 100644 index 0000000000..9fd9651b4a --- /dev/null +++ b/bacula/src/qt-console/restore/restoretreerun.ui @@ -0,0 +1,357 @@ + + restoreTreeRunForm + + + + 0 + 0 + 484 + 268 + + + + Form + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + 0 + + + 6 + + + + + 0 + + + 6 + + + + + + + + Replace: + + + + + + + + + + + 0 + 2 + 0 + 2000 + 1 + 1 + + + + yyyy-mm-dd hh:mm:ss + + + true + + + + + + + Where: + + + true + + + where + + + + + + + true + + + + 200 + 0 + + + + false + + + + + + + true + + + + 200 + 0 + + + + false + + + + + + + When: + + + dateTimeEdit + + + + + + + To client: + + + clientCombo + + + + + + + Bootstrap: + + + bootstrap + + + + + + + + + 0 + + + 6 + + + + + 0 + + + 6 + + + + + Priority: + + + prioritySpin + + + + + + + 10000 + + + 1 + + + 12 + + + + + + + + + Qt::Vertical + + + + 20 + 171 + + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 131 + 25 + + + + + + + + + 16777215 + 30 + + + + <h3>Run RestoreTree Job</h3> + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 131 + 25 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + -- 2.39.5