From: Dirk H Bartley Date: Sat, 12 May 2007 14:17:40 +0000 (+0000) Subject: Moved behavior of MainWin::setContextMenuDockText and setTreeWidgetItemDockColor X-Git-Tag: Release-7.0.0~6369 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bf94d6bea37c0f31880ee579e619de09a4b7a57e;p=bacula%2Fbacula Moved behavior of MainWin::setContextMenuDockText and setTreeWidgetItemDockColor to the pages class. Add column for purged flag to joblist. Add four filters: job, level, status and purged. Add Feature to right click on job and get restore from time option, this populates the timestamp in the before box of the prerestore page. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4762 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/TODO b/bacula/src/qt-console/TODO index 68a1a2e92f..21b36caba1 100644 --- a/bacula/src/qt-console/TODO +++ b/bacula/src/qt-console/TODO @@ -5,11 +5,6 @@ a specific job. Want the ability to create an instance of that class from joblist. I also want a table to convert termination code into human readable text. -move behavior of: - MainWin::setContextMenuDockText - MainWin::setTreeWidgetItemDockColor -to the pages class - Test left pane of restore with 2 windows drives in one backup job. User preferences. With log to stdout options. @@ -88,6 +83,11 @@ global one defined in the mainWin class (if I remember right). ============================================================ DONE: ============================================================ +move behavior of: + MainWin::setContextMenuDockText + MainWin::setTreeWidgetItemDockColor +to the pages class + preempt all connections to console with if (!is_connectedGui()) or some other mechanism. May find more as users start finding them. diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 963c63ed17..48b864d96e 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -99,6 +99,14 @@ void JobList::populateTable() if (volumeIndex != -1) { volumeComboBox->setCurrentIndex(volumeIndex); } + jobComboBox->addItem("Any"); + jobComboBox->addItems(m_console->job_list); + levelComboBox->addItem("Any"); + levelComboBox->addItems( QStringList() << "F" << "D" << "I"); + statusComboBox->addItem("Any"); + statusComboBox->addItems( QStringList() << "T"); + purgedComboBox->addItem("Any"); + purgedComboBox->addItems( QStringList() << "0" << "1"); } /* Set up query QString and header QStringList */ @@ -106,7 +114,8 @@ void JobList::populateTable() query += "SELECT DISTINCT Job.Jobid AS Id, Job.Name AS JobName, Client.Name AS Client," " Job.Starttime AS JobStart, Job.Type AS JobType," " Job.Level AS BackupLevel, Job.Jobfiles AS FileCount," - " Job.JobBytes AS Bytes, Job.JobStatus AS Status" + " Job.JobBytes AS Bytes, Job.JobStatus AS Status," + " Job.PurgedFiles AS Purged" " FROM Job, JobMedia, Media, Client" " WHERE JobMedia.JobId=Job.JobId and JobMedia.MediaId=Media.MediaId" " and Client.ClientId=Job.ClientId"; @@ -124,6 +133,22 @@ void JobList::populateTable() query += " AND Client.Name='" + m_clientName + "'"; m_closeable=true; } + int jobIndex = jobComboBox->currentIndex(); + if ((jobIndex != -1) && (jobComboBox->itemText(jobIndex) != "Any")) { + query += " AND Job.Name='" + jobComboBox->itemText(jobIndex) + "'"; + } + int levelIndex = levelComboBox->currentIndex(); + if ((levelIndex != -1) && (levelComboBox->itemText(levelIndex) != "Any")) { + query += " AND Job.Level='" + levelComboBox->itemText(levelIndex) + "'"; + } + int statusIndex = statusComboBox->currentIndex(); + if ((statusIndex != -1) && (statusComboBox->itemText(statusIndex) != "Any")) { + query += " AND Job.JobStatus='" + statusComboBox->itemText(statusIndex) + "'"; + } + int purgedIndex = purgedComboBox->currentIndex(); + if ((purgedIndex != -1) && (purgedComboBox->itemText(purgedIndex) != "Any")) { + query += " AND Job.PurgedFiles='" + purgedComboBox->itemText(purgedIndex) + "'"; + } /* If Limit check box For limit by days is checked */ if (daysCheckBox->checkState() == Qt::Checked) { QDateTime stamp = QDateTime::currentDateTime().addDays(-daysSpinBox->value()); @@ -140,7 +165,7 @@ void JobList::populateTable() } QStringList headerlist = (QStringList() << "Job Id" << "Job Name" << "Client" << "Job Starttime" << "Job Type" - << "Job Level" << "Job Files" << "Job Bytes" << "Job Status" ); + << "Job Level" << "Job Files" << "Job Bytes" << "Job Status" << "Purged" ); /* Initialize the QTableWidget */ m_checkCurrentWidget = false; @@ -277,6 +302,7 @@ void JobList::createConnections() mp_tableWidget->addAction(actionDeleteJob); mp_tableWidget->addAction(actionPurgeFiles); mp_tableWidget->addAction(actionRestoreFromJob); + mp_tableWidget->addAction(actionRestoreFromTime); /* Make Connections */ connect(actionLongListJob, SIGNAL(triggered()), this, @@ -295,6 +321,8 @@ void JobList::createConnections() SLOT(consolePurgeFiles())); connect(actionRestoreFromJob, SIGNAL(triggered()), this, SLOT(preRestoreFromJob())); + connect(actionRestoreFromTime, SIGNAL(triggered()), this, + SLOT(preRestoreFromTime())); } /* @@ -373,5 +401,13 @@ void JobList::consolePurgeFiles() */ void JobList::preRestoreFromJob() { - new prerestorePage(m_currentJob); + new prerestorePage(m_currentJob, R_JOBIDLIST); +} + +/* + * Subroutine to call preRestore to restore from a select job + */ +void JobList::preRestoreFromTime() +{ + new prerestorePage(m_currentJob, R_JOBDATETIME); } diff --git a/bacula/src/qt-console/joblist/joblist.h b/bacula/src/qt-console/joblist/joblist.h index 5d35d7e4ea..cacc930d4f 100644 --- a/bacula/src/qt-console/joblist/joblist.h +++ b/bacula/src/qt-console/joblist/joblist.h @@ -62,6 +62,7 @@ private slots: void consoleDeleteJob(); void consolePurgeFiles(); void preRestoreFromJob(); + void preRestoreFromTime(); private: void createConnections(); diff --git a/bacula/src/qt-console/joblist/joblist.ui b/bacula/src/qt-console/joblist/joblist.ui index faa15cbacd..eb50b2387e 100644 --- a/bacula/src/qt-console/joblist/joblist.ui +++ b/bacula/src/qt-console/joblist/joblist.ui @@ -5,8 +5,8 @@ 0 0 - 621 - 500 + 547 + 361 @@ -19,13 +19,16 @@ 6 + + + 0 - 6 + 0 @@ -36,24 +39,58 @@ 6 - - - Record Limit + + + 0 + + + 6 - + + + + Record Limit + + + + + + + 10000 + + + 1 + + + 25 + + + + - - - 10000 - - - 1 + + + 0 - - 25 + + 6 - + + + + Days Limit + + + + + + + 10 + + + + @@ -66,18 +103,44 @@ 6 - - - Days Limit + + + 0 - + + 6 + + + + + Clients + + + + + + + - - - 10 + + + 0 + + + 6 - + + + + Volume + + + + + + + @@ -90,14 +153,44 @@ 6 - - - Clients + + + 0 + + + 6 - + + + + Job + + + + + + + - + + + 0 + + + 6 + + + + + Level + + + + + + + @@ -110,14 +203,44 @@ 6 - - - Volume + + + 0 + + + 6 - + + + + Status + + + + + + + - + + + 0 + + + 6 + + + + + Purged + + + + + + + @@ -136,9 +259,6 @@ - - - @@ -215,6 +335,14 @@ Restore From Job + + + ../images/unmark.png + + + Restore From Time + + diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 68e2d81ce2..8fa0aec17a 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -417,7 +417,7 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre nextPage->raise(); } /* for the page selectors menu action to dock or undock, set the text */ - setContextMenuDockText(nextPage, currentitem); + nextPage->setContextMenuDockText(); treeWidget->addAction(actionToggleDock); /* if this page is closeable, then add that action */ @@ -503,8 +503,6 @@ void MainWin::undockWindowButton() { Pages* page = (Pages*)stackedWidget->currentWidget(); page->togglePageDocking(); - /* The window has been undocked, lets change the context menu */ - setContextMenuDockText(); } /* @@ -520,78 +518,6 @@ void MainWin::toggleDockContextWindow() if (getFromHash(currentitem)) { Pages* page = getFromHash(currentitem); page->togglePageDocking(); - if (page->isDocked()) { - stackedWidget->setCurrentWidget(page); - } - /* Toggle the menu item. The window's dock status has been toggled */ - setContextMenuDockText(page, currentitem); - } -} - -/* - * Function to set the text of the toggle dock context menu when page and - * widget item are NOT known. This is an overoaded funciton. - * It is called from MainWin::undockWindowButton, it is not intended to change - * for the top pages tree widget, it is for the currently active tree widget - * item. Which is why the page is not passed. - */ -void MainWin::setContextMenuDockText() -{ - QTreeWidgetItem *currentitem = treeWidget->currentItem(); - - /* Is this a page that has been inserted into the hash */ - if (getFromHash(currentitem)) { - Pages* page = getFromHash(currentitem); - setContextMenuDockText(page, currentitem); - } -} - -/* - * Function to set the text of the toggle dock context menu when page and - * widget item are known. This is the more commonly used. - */ -void MainWin::setContextMenuDockText(Pages* page, QTreeWidgetItem* item) -{ - QString docktext(""); - if (page->isDocked()) { - docktext += "UnDock "; - } else { - docktext += "ReDock "; - } - docktext += item->text(0) += " Window"; - - actionToggleDock->setText(docktext); - setTreeWidgetItemDockColor(page, item); -} - -/* - * Function to set the color of the tree widget item based on whether it is - * docked or not. - */ -void MainWin::setTreeWidgetItemDockColor(Pages* page, QTreeWidgetItem* item) -{ - if (item->text(0) != "Console") { - if (page->isDocked()) { - /* Set the brush to blue if undocked */ - QBrush blackBrush(Qt::black); - item->setForeground(0, blackBrush); - } else { - /* Set the brush back to black if docked */ - QBrush blueBrush(Qt::blue); - item->setForeground(0, blueBrush); - } - } -} - -/* - * Overload of previous function, use treeindex to get item from page - * This is called when an undocked window is closed. - */ -void MainWin::setTreeWidgetItemDockColor(Pages* page) -{ - QTreeWidgetItem* item = getFromHash(page); - if (item) { - setTreeWidgetItemDockColor(page, item); } } diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 19da0df74f..60ad2630b3 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -55,10 +55,6 @@ public: void writeSettings(); void readSettings(); void resetFocus() { lineEdit->setFocus(); }; - void setContextMenuDockText(); - void setContextMenuDockText(Pages *, QTreeWidgetItem *); - void setTreeWidgetItemDockColor(Pages *, QTreeWidgetItem *); - void setTreeWidgetItemDockColor(Pages *); void hashInsert(QTreeWidgetItem *, Pages *); void hashRemove(Pages *); void hashRemove(QTreeWidgetItem *, Pages *); diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 2e94f0a786..1e57794d39 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -46,13 +46,15 @@ void Pages::dockPage() * that it has the proper window flag and parent. */ setWindowFlags(Qt::Widget); -// setParent(m_parent); /* This was being done already */ m_parent->addWidget(this); /* Set docked flag */ m_docked = true; + mainWin->stackedWidget->setCurrentWidget(this); + /* lets set the page selectors action for docking or undocking */ + setContextMenuDockText(); } /* @@ -69,6 +71,8 @@ void Pages::undockPage() show(); /* Clear docked flag */ m_docked = false; + /* The window has been undocked, lets change the context menu */ + setContextMenuDockText(); } /* @@ -117,24 +121,12 @@ void Pages::closeEvent(QCloseEvent* event) /* A Widget was closed, lets toggle it back into the window, and set it in front. */ dockPage(); - /* is the tree widget item for "this" the current widget item */ - if (mainWin->treeWidget->currentItem() == mainWin->getFromHash(this)) - /* in case the current widget is the one which represents this, lets set the context - * menu to undock */ - mainWin->setContextMenuDockText(); - else - /* in case the current widget is not the one which represents this, lets set the - * color back to black */ - mainWin->setTreeWidgetItemDockColor(this); - /* this fixes my woes of getting the widget to show up on top when closed */ event->ignore(); - /* put this widget on the top of the stack widget */ - m_parent->setCurrentWidget(this); - /* Set the current tree widget item in the Page Selector window to the item - * which represents "this" */ + * which represents "this" + * Which will also bring "this" to the top of the stacked widget */ setCurrent(); } @@ -220,7 +212,11 @@ void Pages::consoleCommand(QString &command) #ifdef xxdebugcode m_console->display_text("Context sensitive command :\n\n"); m_console->display_text("**** "); - m_console->display_text(command + " ****\n"); +#endif + m_console->display_text(command); + m_console->display_text("\n"); +#ifdef xxdebugcode + m_console->display_text(" ****\n"); m_console->display_text("Director Response :\n\n"); #endif m_console->write_dir(command.toUtf8().data()); @@ -269,3 +265,44 @@ void Pages::setCurrent() { mainWin->treeWidget->setCurrentItem(mainWin->getFromHash(this)); } + +/* + * Function to set the text of the toggle dock context menu when page and + * widget item are NOT known. + */ +void Pages::setContextMenuDockText() +{ + QTreeWidgetItem *item = mainWin->getFromHash(this); + QString docktext(""); + if (isDocked()) { + docktext += "UnDock "; + } else { + docktext += "ReDock "; + } + docktext += item->text(0) += " Window"; + + mainWin->actionToggleDock->setText(docktext); + setTreeWidgetItemDockColor(); +} + +/* + * Function to set the color of the tree widget item based on whether it is + * docked or not. + */ +void Pages::setTreeWidgetItemDockColor() +{ + QTreeWidgetItem* item = mainWin->getFromHash(this); + if (item) { + if (item->text(0) != "Console") { + if (isDocked()) { + /* Set the brush to blue if undocked */ + QBrush blackBrush(Qt::black); + item->setForeground(0, blackBrush); + } else { + /* Set the brush back to black if docked */ + QBrush blueBrush(Qt::blue); + item->setForeground(0, blueBrush); + } + } + } +} diff --git a/bacula/src/qt-console/pages.h b/bacula/src/qt-console/pages.h index 857ed70635..c7e7d1a1f1 100644 --- a/bacula/src/qt-console/pages.h +++ b/bacula/src/qt-console/pages.h @@ -67,6 +67,8 @@ public: void closeStackPage(); Console *console() { return m_console; }; void setCurrent(); + void setContextMenuDockText(); + void setTreeWidgetItemDockColor(); public slots: /* closeEvent is a virtual function inherited from QWidget */ diff --git a/bacula/src/qt-console/restore/prerestore.cpp b/bacula/src/qt-console/restore/prerestore.cpp index 458201237a..56995db43f 100644 --- a/bacula/src/qt-console/restore/prerestore.cpp +++ b/bacula/src/qt-console/restore/prerestore.cpp @@ -39,16 +39,18 @@ #include "restore.h" /* Constructor to have job id list default in */ -prerestorePage::prerestorePage(QString &jobIdString) +prerestorePage::prerestorePage(QString &data, unsigned int datatype) { - m_jobIdListIn = jobIdString; + m_dataIn = data; + m_dataInType = datatype; buildPage(); } /* Basic Constructor */ prerestorePage::prerestorePage() { - m_jobIdListIn = ""; + m_dataIn = ""; + m_dataInType = R_NONE; buildPage(); } @@ -57,7 +59,7 @@ prerestorePage::prerestorePage() */ void prerestorePage::buildPage() { - m_dtformat = "yyyy-MM-dd HH:MM:ss"; + m_dtformat = "yyyy-MM-dd HH:mm:ss"; m_name = "Restore"; setupUi(this); pgInitialize(); @@ -76,19 +78,31 @@ void prerestorePage::buildPage() beforeDateTime->setDateTime(QDateTime::currentDateTime()); beforeDateTime->setEnabled(false); selectFilesRadio->setChecked(true); - if (m_jobIdListIn == "") { + if (m_dataInType == R_NONE) { selectJobsRadio->setChecked(true); jobIdEdit->setText("Comma separted list of jobs id's"); jobIdEdit->setEnabled(false); - } else { + } else if (m_dataInType == R_JOBIDLIST) { listJobsRadio->setChecked(true); - jobIdEdit->setText(m_jobIdListIn); + jobIdEdit->setText(m_dataIn); jobsRadioClicked(false); QStringList fieldlist; - jobdefsFromJob(fieldlist,m_jobIdListIn); + jobdefsFromJob(fieldlist,m_dataIn); + filesetCombo->setCurrentIndex(filesetCombo->findText(fieldlist[2], Qt::MatchExactly)); + clientCombo->setCurrentIndex(clientCombo->findText(fieldlist[1], Qt::MatchExactly)); + jobCombo->setCurrentIndex(jobCombo->findText(fieldlist[0], Qt::MatchExactly)); + } else if (m_dataInType == R_JOBDATETIME) { + selectJobsRadio->setChecked(true); + jobIdEdit->setText("Comma separted list of jobs id's"); + jobIdEdit->setEnabled(false); + recentCheckBox->setCheckState(Qt::Unchecked); + jobsRadioClicked(true); + QStringList fieldlist; + jobdefsFromJob(fieldlist,m_dataIn); filesetCombo->setCurrentIndex(filesetCombo->findText(fieldlist[2], Qt::MatchExactly)); clientCombo->setCurrentIndex(clientCombo->findText(fieldlist[1], Qt::MatchExactly)); jobCombo->setCurrentIndex(jobCombo->findText(fieldlist[0], Qt::MatchExactly)); + beforeDateTime->setDateTime(QDateTime::fromString(fieldlist[3], m_dtformat)); } job_name_change(0); connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int))); @@ -143,7 +157,7 @@ void prerestorePage::okButtonPushed() } /* ***FIXME*** */ - //printf("preRestore command \'%s\'\n", cmd.toUtf8().data()); + printf("preRestore command \'%s\'\n", cmd.toUtf8().data()); consoleCommand(cmd); /* Note, do not turn notifier back on here ... */ if (selectFilesRadio->isChecked()) { @@ -237,7 +251,8 @@ void prerestorePage::jobdefsFromJob(QStringList &fieldlist, QString jobId) { QString job, client, fileset; QString query(""); - query = "SELECT DISTINCT Job.Name AS JobName, Client.Name AS Client, FileSet.FileSet AS FileSet " + query = "SELECT DISTINCT Job.Name AS JobName, Client.Name AS Client," + " FileSet.FileSet AS FileSet, Job.Starttime AS JobStart" " From Job, Client, FileSet" " WHERE Job.FileSetId=FileSet.FileSetId AND Job.ClientId=Client.ClientId" " AND JobId=\'" + jobId + "\'"; @@ -271,7 +286,6 @@ bool prerestorePage::checkJobIdList() "Press OK to continue?"), QMessageBox::Ok ); return false; } - //printf("In prerestorePage::jobIdEditFinished %s\n",line.toUtf8().data()); QStringList joblist = line.split(",", QString::SkipEmptyParts); bool allintokay = true, alljobok = true, allisjob = true; QString jobName(""), clientName(""); diff --git a/bacula/src/qt-console/restore/restore.h b/bacula/src/qt-console/restore/restore.h index f027e233e5..39150a3cc8 100644 --- a/bacula/src/qt-console/restore/restore.h +++ b/bacula/src/qt-console/restore/restore.h @@ -40,6 +40,12 @@ #include "ui_restore.h" #include "ui_prerestore.h" +enum { + R_NONE, + R_JOBIDLIST, + R_JOBDATETIME +}; + /* * The pre-restore dialog selects the Job/Client to be restored * It really could use considerable enhancement. @@ -50,7 +56,7 @@ class prerestorePage : public Pages, public Ui::prerestoreForm public: prerestorePage(); - prerestorePage(QString &jobIdString); + prerestorePage(QString &data, unsigned int); private slots: void okButtonPushed(); @@ -65,7 +71,8 @@ private: void buildPage(); bool checkJobIdList(); QString m_dtformat; - QString m_jobIdListIn; + QString m_dataIn; + unsigned int m_dataInType; }; /*