From: Dirk H Bartley Date: Sat, 28 Jul 2007 18:59:49 +0000 (+0000) Subject: Change the "restore" command to use done instead of yes option. This removes X-Git-Tag: Release-7.0.0~5928 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=727a4eeeaf533b1349a237aeced490ac75e5a1e1;p=bacula%2Fbacula Change the "restore" command to use done instead of yes option. This removes the reason to have restorerun files. Add progress bar for refreshing and restoring. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5258 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/bat.pro.in b/bacula/src/qt-console/bat.pro.in index 16e9a73cf4..ce99dc8335 100644 --- a/bacula/src/qt-console/bat.pro.in +++ b/bacula/src/qt-console/bat.pro.in @@ -37,7 +37,6 @@ 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 @@ -116,8 +115,6 @@ 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 72167ee753..b088502457 100644 --- a/bacula/src/qt-console/restore/restoretree.cpp +++ b/bacula/src/qt-console/restore/restoretree.cpp @@ -38,7 +38,6 @@ #include "bat.h" #include "restoretree.h" #include "pages.h" -#include "restoretreerun.h" restoreTree::restoreTree() { @@ -58,6 +57,11 @@ restoreTree::restoreTree() m_slashregex.setPattern("/"); m_debugCnt = 0; m_debugTrap = true; + /* progress widgets */ + prBar1->setVisible(false); + prBar2->setVisible(false); + prLabel1->setVisible(false); + prLabel2->setVisible(false); } restoreTree::~restoreTree() @@ -112,7 +116,18 @@ void restoreTree::populateDirectoryTree() m_versionExceptionHash.clear(); m_directoryIconStateHash.clear(); - + /* Set progress bars and repaint */ + prBar1->setVisible(true); + prBar1->setRange(0,2); + prBar1->setValue(0); + prLabel1->setText("Task 1 of 2"); + prLabel1->setVisible(true); + prBar2->setVisible(true); + prBar2->setRange(0,0); + prLabel2->setText("Querying Database"); + prLabel2->setVisible(true); + repaint(); + int clientIndex = clientCombo->currentIndex(); int fileSetIndex = fileSetCombo->currentIndex(); QString jobComboText = jobCombo->itemText(jobCombo->currentIndex()); @@ -158,16 +173,27 @@ void restoreTree::populateDirectoryTree() if (mainWin->m_sqlDebug) { Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data()); } + prBar1->setValue(1); + prLabel1->setText("Task 2 of 2"); QStringList directories; if (m_console->sql_cmd(cmd, directories)) { if (mainWin->m_miscDebug) { Pmsg1(000, "Done with query %i directories\n", directories.count()); } + prBar2->setValue(0); + prBar2->setRange(0,directories.count()); + prLabel2->setText("Processing Directories"); + repaint(); foreach(QString directory, directories) { m_debugCnt += 1; + prBar2->setValue(m_debugCnt); parseDirectory(directory); } } + prBar1->setVisible(false); + prBar2->setVisible(false); + prLabel1->setVisible(false); + prLabel2->setVisible(false); } /* @@ -1265,11 +1291,33 @@ void restoreTree::directorySetIcon(int operation, int change, QString &path, QTr */ void restoreTree::restoreButtonPushed() { + /* Set progress bars and repaint */ + prLabel1->setVisible(true); + prLabel1->setText("Task 1 of 3"); + prLabel2->setVisible(true); + prLabel2->setText("Processing Checked directories"); + prBar1->setVisible(true); + prBar1->setRange(0, 3); + prBar1->setValue(0); + prBar2->setVisible(true); + prBar2->setRange(0, 0); + repaint(); QMultiHash versionFilesMulti; + int vFMCounter = 0; QHash fullPathDone; QHash fileIndexHash; if ((mainWin->m_rtRestore1Debug) || (mainWin->m_rtRestore2Debug) || (mainWin->m_rtRestore3Debug)) Pmsg0(000, "In restoreTree::restoreButtonPushed\n"); + /* Use a tree widget item iterator to count directories for the progress bar */ + QTreeWidgetItemIterator diterc(directoryTree, QTreeWidgetItemIterator::Checked); + int ditcount = 0; + while (*diterc) { + ditcount += 1; + ++diterc; + } /* while (*diterc) */ + prBar2->setRange(0, ditcount); + prBar2->setValue(0); + ditcount = 0; /* Use a tree widget item iterator filtering for Checked Items */ QTreeWidgetItemIterator diter(directoryTree, QTreeWidgetItemIterator::Checked); while (*diter) { @@ -1302,7 +1350,6 @@ void restoreTree::restoreButtonPushed() if (mainWin->m_sqlDebug) Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data()); QStringList results; if (m_console->sql_cmd(cmd, results)) { - QStringList fieldlist; int row = 0; @@ -1343,12 +1390,20 @@ void restoreTree::restoreButtonPushed() fullPathDone.insert(fullPath, 1); fileIndexHash.insert(fullPath, fileIndex); versionFilesMulti.insert(version, fullPath); + vFMCounter += 1; } row++; } } + ditcount += 1; + prBar2->setValue(ditcount); ++diter; } /* while (*diter) */ + prBar1->setValue(1); + prLabel1->setText("Task 2 of 3"); + prLabel2->setText("Processing Exceptions"); + prBar2->setRange(0, 0); + repaint(); /* There may be some exceptions not accounted for yet with fullPathDone */ QHashIterator ftera(m_fileExceptionHash); @@ -1376,10 +1431,19 @@ void restoreTree::restoreButtonPushed() if (mainWin->m_rtRestore1Debug) Pmsg2(000, "Restoring %s file %s\n", debugtext.toUtf8().data(), fullPath.toUtf8().data()); versionFilesMulti.insert(version, fullPath); + vFMCounter += 1; fileIndexHash.insert(fullPath, fileIndex); } /* if fullPathDone.value(fullPath, 0) == 0 */ } /* if state != 0 */ } /* while ftera.hasNext */ + /* The progress bars for the next step */ + prBar1->setValue(2); + prLabel1->setText("Task 3 of 3"); + prLabel2->setText("Filling Database Table"); + prBar2->setRange(0, vFMCounter); + vFMCounter = 0; + prBar2->setValue(vFMCounter); + repaint(); /* now for the final spit out of the versions and lists of files for each version */ QHash doneKeys; @@ -1413,20 +1477,40 @@ void restoreTree::restoreButtonPushed() int fileIndex = fileIndexHash.value(ffullPath); if (mainWin->m_rtRestore2Debug) Pmsg2(000, " file->%s id %i\n", ffullPath.toUtf8().data(), fileIndex); QString sqlcmd = "INSERT INTO " + tempTable + " (JobId, FileIndex) VALUES (" + QString("%1").arg(fversion) + ", " + QString("%1").arg(fileIndex) + ")"; - if (mainWin->m_sqlDebug) - Pmsg1(000, "Query cmd : %s ;\n", sqlcmd.toUtf8().data()); + if (mainWin->m_rtRestore3Debug) + Pmsg1(000, "Insert cmd : %s\n", sqlcmd.toUtf8().data()); QStringList results; if (!m_console->sql_cmd(sqlcmd, results)) Pmsg1(000, "INSERT INTO FAILED!!!! %s\n", sqlcmd.toUtf8().data()); + prBar2->setValue(++vFMCounter); } /* foreach fullPathList */ doneKeys.insert(fversion,1); jobList.append(fversion); } /* if (doneKeys.value(fversion, 0) == 0) */ } /* while (vFMiter.hasNext()) */ if (tempTable != "") { - QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(this); - new restoreTreeRunPage(tempTable, m_prevClientCombo, jobList, pageSelectorTreeWidgetItem); + /* a table was made, lets run the job */ + QString jobOption = " jobid=\""; + bool first = true; + /* create a list of jobs comma separated */ + foreach (int job, jobList) { + if (first) first = false; + else jobOption += ","; + jobOption += QString("%1").arg(job); + } + jobOption += "\""; + QString cmd = QString("restore"); + cmd += jobOption + + " file=\"?" + tempTable + "\" done"; + if (mainWin->m_commandDebug) + Pmsg1(000, "preRestore command \'%s\'\n", cmd.toUtf8().data()); + consoleCommand(cmd); } + /* turn off the progress widgets */ + prBar1->setVisible(false); + prBar2->setVisible(false); + prLabel1->setVisible(false); + prLabel2->setVisible(false); } int restoreTree::mostRecentVersionfromFullPath(QString &fullPath) diff --git a/bacula/src/qt-console/restore/restoretree.ui b/bacula/src/qt-console/restore/restoretree.ui index fc2eb680ff..1447db6c2e 100644 --- a/bacula/src/qt-console/restore/restoretree.ui +++ b/bacula/src/qt-console/restore/restoretree.ui @@ -5,8 +5,8 @@ 0 0 - 440 - 327 + 411 + 295 @@ -19,80 +19,6 @@ 6 - - - - 0 - - - 6 - - - - - - 5 - 0 - 0 - 0 - - - - Directory - - - - - - - 0 - - - 6 - - - - - Refresh - - - :/images/view-refresh.svg - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 21 - 26 - - - - - - - - Restore - - - - - - - @@ -106,7 +32,7 @@ Qt::Horizontal - + 0 @@ -114,8 +40,28 @@ 6 - - + + + + true + + + 24 + + + Qt::Horizontal + + + + + + + TextLabel + + + Qt::AlignCenter + + @@ -127,6 +73,32 @@ + + + + true + + + 24 + + + Qt::Horizontal + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + @@ -188,6 +160,80 @@ + + + + 0 + + + 6 + + + + + + 5 + 0 + 0 + 0 + + + + Directory + + + + + + + 0 + + + 6 + + + + + Refresh + + + :/images/view-refresh.svg + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 21 + 26 + + + + + + + + Restore + + + + + + + diff --git a/bacula/src/qt-console/restore/restoretreerun.cpp b/bacula/src/qt-console/restore/restoretreerun.cpp deleted file mode 100644 index ab2f817edf..0000000000 --- a/bacula/src/qt-console/restore/restoretreerun.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - 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); - clientCombo->setCurrentIndex(clientCombo->findText(m_client, Qt::MatchExactly)); - 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 += jobOption + - " file=\"?" + m_tempTable + "\" yes" - " replace=\"" + replaceCombo->currentText() + "\"" - " when=\"" + dateTimeEdit->dateTime().toString(mainWin->m_dtformat) + "\"" - " restoreclient=\"" + clientCombo->currentText() + "\""; - if (mainWin->m_commandDebug) - Pmsg1(000, "preRestore command \'%s\'\n", cmd.toUtf8().data()); - consoleCommand(cmd); - mainWin->resetFocus(); - closeStackPage(); - -/* QString cmd(".mod"); - 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 deleted file mode 100644 index 07f2672f83..0000000000 --- a/bacula/src/qt-console/restore/restoretreerun.h +++ /dev/null @@ -1,27 +0,0 @@ - -#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 deleted file mode 100644 index 9fd9651b4a..0000000000 --- a/bacula/src/qt-console/restore/restoretreerun.ui +++ /dev/null @@ -1,357 +0,0 @@ - - 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 - - - - - - - - -