From 48c08b5b62e3a48dd2486aa7b9d7e1c420234c9d Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sun, 6 May 2007 19:51:52 +0000 Subject: [PATCH] Add intelegence to prerestore. Radio buttons for select or all files. Radio button for select or list jobs. Text input for list of jobs. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4716 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/restore/prerestore.cpp | 94 ++++- bacula/src/qt-console/restore/prerestore.ui | 408 +++++++++++++------ bacula/src/qt-console/restore/restore.cpp | 1 + bacula/src/qt-console/restore/restore.h | 3 + bacula/src/qt-console/restore/restore.ui | 6 +- bacula/src/qt-console/run/runcmd.cpp | 5 +- 6 files changed, 380 insertions(+), 137 deletions(-) diff --git a/bacula/src/qt-console/restore/prerestore.cpp b/bacula/src/qt-console/restore/prerestore.cpp index a1a8423ecb..4828794dcf 100644 --- a/bacula/src/qt-console/restore/prerestore.cpp +++ b/bacula/src/qt-console/restore/prerestore.cpp @@ -41,6 +41,7 @@ prerestorePage::prerestorePage() { + m_dtformat = "yyyy-MM-dd HH:MM:ss"; m_name = "Pre-Restore"; setupUi(this); pgInitialize(); @@ -50,14 +51,24 @@ prerestorePage::prerestorePage() jobCombo->addItems(m_console->job_list); filesetCombo->addItems(m_console->fileset_list); clientCombo->addItems(m_console->client_list); + poolCombo->addItem("Any"); poolCombo->addItems(m_console->pool_list); storageCombo->addItems(m_console->storage_list); + /* current or before . . Start out with current checked */ + recentCheckBox->setCheckState(Qt::Checked); + beforeDateTime->setDisplayFormat(m_dtformat); beforeDateTime->setDateTime(QDateTime::currentDateTime()); beforeDateTime->setEnabled(false); + selectFilesRadio->setChecked(true); + selectJobsRadio->setChecked(true); + jobIdEdit->setText("Comma separted list of jobs id's"); + jobIdEdit->setEnabled(false); job_name_change(0); connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int))); connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed())); connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed())); + connect(recentCheckBox, SIGNAL(stateChanged(int)), this, SLOT(recentChanged(int))); + connect(selectJobsRadio, SIGNAL(toggled(bool)), this, SLOT(jobsRadioClicked(bool))); dockPage(); setCurrent(); @@ -69,22 +80,43 @@ void prerestorePage::okButtonPushed() QString cmd; this->hide(); - - cmd = QString( - "restore select current fileset=\"%1\" client=\"%2\" pool=\"%3\" " - "storage=\"%4\"\n") - .arg(filesetCombo->currentText()) - .arg(clientCombo->currentText()) - .arg(poolCombo->currentText()) - .arg(storageCombo->currentText()); + + cmd = QString("restore "); + if (selectFilesRadio->isChecked()) { + cmd += "select "; + } else { + cmd += "all done "; + } + cmd += "fileset=\"" + filesetCombo->currentText() + "\" "; + if (selectJobsRadio->isChecked()) { + cmd += "client=\"" + clientCombo->currentText() + "\" "; + if (poolCombo->currentText() != "Any" ){ + cmd += "pool=\"" + poolCombo->currentText() + "\" "; + } + cmd += "storage=\"" + storageCombo->currentText() + "\" "; + if (recentCheckBox->checkState() == Qt::Checked) { + cmd += " current"; + } else { + QDateTime stamp = beforeDateTime->dateTime(); + QString before = stamp.toString(m_dtformat); + cmd += " before=\"" + before + "\""; + } + } else { + cmd += "jobid=\"" + jobIdEdit->text() + "\""; + } /* ***FIXME*** */ - //printf("preRestore command \"%s\"\n", cmd.toUtf8().data()); - m_console->write(cmd); - m_console->display_text(cmd); + //printf("preRestore command \'%s\'\n", cmd.toUtf8().data()); + consoleCommand(cmd); /* Note, do not turn notifier back on here ... */ - new restorePage(); - closeStackPage(); + if (selectFilesRadio->isChecked()) { + new restorePage(); + closeStackPage(); + } else { + m_console->notify(true); + closeStackPage(); + mainWin->resetFocus(); + } } @@ -110,3 +142,39 @@ void prerestorePage::job_name_change(int index) storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly)); } } + +void prerestorePage::recentChanged(int state) +{ + if ((state == Qt::Unchecked) && (selectJobsRadio->isChecked())) { + beforeDateTime->setEnabled(true); + } else { + beforeDateTime->setEnabled(false); + } +} + +void prerestorePage::jobsRadioClicked(bool checked) +{ + if (checked) { + printf("In prerestorePage::jobsRadioClicked checked\n"); + jobCombo->setEnabled(true); +// filesetCombo->setEnabled(true); + clientCombo->setEnabled(true); + poolCombo->setEnabled(true); + storageCombo->setEnabled(true); + recentCheckBox->setEnabled(true); + if (!recentCheckBox->isChecked()) { + beforeDateTime->setEnabled(true); + } + jobIdEdit->setEnabled(false); + } else { + printf("In prerestorePage::jobsRadioClicked UNchecked\n"); + jobCombo->setEnabled(false); +// filesetCombo->setEnabled(false); + clientCombo->setEnabled(false); + poolCombo->setEnabled(false); + storageCombo->setEnabled(false); + recentCheckBox->setEnabled(false); + beforeDateTime->setEnabled(false); + jobIdEdit->setEnabled(true); + } +} diff --git a/bacula/src/qt-console/restore/prerestore.ui b/bacula/src/qt-console/restore/prerestore.ui index b230563350..96876736f5 100644 --- a/bacula/src/qt-console/restore/prerestore.ui +++ b/bacula/src/qt-console/restore/prerestore.ui @@ -5,13 +5,16 @@ 0 0 - 578 - 406 + 589 + 458 Form + + true + 9 @@ -19,15 +22,15 @@ 6 - + - Qt::Horizontal + Qt::Vertical - 40 - 20 + 20 + 40 @@ -45,6 +48,32 @@ + + + + Qt::Horizontal + + + + 93 + 301 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -53,10 +82,176 @@ 6 - - + + + + Before: + + + beforeDateTime + + + + + + + + + + Pool: + + + poolCombo + + + + + + + + 2000 + 1 + 1 + + + + yyyy-mm-dd h:mm:ss + + + true + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Select Jobs + + + false + + + + + + + List Jobs + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + Job: + + + jobCombo + + + + + + + + + + Qt::RightToLeft + + + Use Most Recent + + + + + + + Qt::Horizontal + + + + 221 + 20 + + + + + + + + Storage: + + + storageCombo + + + + + JobIds: + + + jobCombo + + + + File Set: @@ -66,7 +261,25 @@ - + + + + + 7 + 0 + 0 + 0 + + + + + 600 + 600 + + + + + 0 @@ -103,20 +316,10 @@ - - - - - - - Client: - - - clientCombo - - + + - + 0 @@ -146,7 +349,7 @@ - <h3>Pre - Restore</h3> + <h3>Select Jobs</h3> @@ -165,115 +368,82 @@ - - - - Pool: - - - poolCombo - - - - - - - - - - - - - Before: - - - beforeDateTime - - - - - - - Job: + + + + QFrame::NoFrame - - jobCombo - - - - - - - - 2000 - 1 - 1 - - - - yyyy-mm-dd h:mm:ss - - - true - - - - - - - - 7 - 0 - 0 - 0 - - - - - 600 - 600 - + + QFrame::Plain + + + 0 + + + 6 + + + + + All Files + + + false + + + + + + + Select Files + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - + - Storage: + Client: - storageCombo + clientCombo - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/bacula/src/qt-console/restore/restore.cpp b/bacula/src/qt-console/restore/restore.cpp index b6e8f8d36d..f8107f1c68 100644 --- a/bacula/src/qt-console/restore/restore.cpp +++ b/bacula/src/qt-console/restore/restore.cpp @@ -237,6 +237,7 @@ void restorePage::cancelButtonPushed() { this->hide(); m_console->write("quit"); + m_console->displayToPrompt(); mainWin->set_status("Canceled"); closeStackPage(); m_console->notify(true); diff --git a/bacula/src/qt-console/restore/restore.h b/bacula/src/qt-console/restore/restore.h index c4eabc69aa..f952b530df 100644 --- a/bacula/src/qt-console/restore/restore.h +++ b/bacula/src/qt-console/restore/restore.h @@ -55,8 +55,11 @@ private slots: void okButtonPushed(); void cancelButtonPushed(); void job_name_change(int index); + void recentChanged(int); + void jobsRadioClicked(bool); private: + QString m_dtformat; }; /* diff --git a/bacula/src/qt-console/restore/restore.ui b/bacula/src/qt-console/restore/restore.ui index 043ff8775f..e890eb8f3f 100644 --- a/bacula/src/qt-console/restore/restore.ui +++ b/bacula/src/qt-console/restore/restore.ui @@ -239,7 +239,7 @@ Up - ../../../../../../../:images/up.png + :images/up.png @@ -263,7 +263,7 @@ Mark - ../../../../../../../:images/mark.png + :images/mark.png @@ -287,7 +287,7 @@ Unmark - ../../../../../../../:images/unmark.png + :images/unmark.png diff --git a/bacula/src/qt-console/run/runcmd.cpp b/bacula/src/qt-console/run/runcmd.cpp index 847d00c3b4..e1f70c93a8 100644 --- a/bacula/src/qt-console/run/runcmd.cpp +++ b/bacula/src/qt-console/run/runcmd.cpp @@ -125,16 +125,17 @@ void runCmdPage::okButtonPushed() m_console->write_dir("yes"); m_console->displayToPrompt(); m_console->notify(true); - delete this; + closeStackPage(); mainWin->resetFocus(); } void runCmdPage::cancelButtonPushed() { + m_console->displayToPrompt(); mainWin->set_status(" Canceled"); this->hide(); m_console->notify(true); - delete this; + closeStackPage(); mainWin->resetFocus(); } -- 2.39.5