2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
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 and included
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.
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
23 Bacula® is a registered trademark of Kern Sibbald.
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.
32 * Main Window control for bat (qt-console)
34 * Kern Sibbald, January MMVII
40 #include "joblist/joblist.h"
41 #include "storage/storage.h"
42 #include "fileset/fileset.h"
43 #include "label/label.h"
46 #include "restore/restore.h"
47 #include "medialist/medialist.h"
48 #include "joblist/joblist.h"
49 #include "clients/clients.h"
50 #include "restore/restoretree.h"
51 #include "help/help.h"
52 #include "jobs/jobs.h"
54 #include "jobgraphs/jobplot.h"
56 #include "status/dirstat.h"
57 #include "util/fmtwidgetitem.h"
60 * Daemon message callback
62 void message_callback(int /* type */, char *msg)
64 QMessageBox::warning(mainWin, "Bat", msg, QMessageBox::Ok);
67 MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
69 app->setOverrideCursor(QCursor(Qt::WaitCursor));
73 m_treeStackTrap = false;
74 m_dtformat = "yyyy-MM-dd HH:mm:ss";
76 setupUi(this); /* Setup UI defined by main.ui (designer) */
77 register_message_callback(message_callback);
80 treeWidget->setColumnCount(1);
81 treeWidget->setHeaderLabel( tr("Select Page") );
82 treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
83 // tabWidget->setTabsClosable(true); /* wait for QT 4.5 */
86 resetFocus(); /* lineEdit->setFocus() */
89 actionJobPlot->setEnabled(false);
90 actionJobPlot->setVisible(false);
97 foreach(Console *console, m_consoleHash)
98 console->connect_dir();
99 m_currentConsole = (Console*)getFromHash(m_firstItem);
100 QTimer::singleShot(750, this, SLOT(popLists()));
102 QString directoryResourceName;
103 m_currentConsole->getDirResName(directoryResourceName);
104 Pmsg1(100, "Setting initial window to %s\n", directoryResourceName.toUtf8().data());
108 void MainWin::popLists()
110 foreach(Console *console, m_consoleHash)
111 console->populateLists(true);
112 app->restoreOverrideCursor();
114 connectConsoleSignals();
116 m_currentConsole->setCurrent();
119 void MainWin::createPages()
122 QTreeWidgetItem *item, *topItem;
126 foreach_res(dir, R_DIRECTOR) {
128 /* Create console tree stacked widget item */
129 m_currentConsole = new Console(tabWidget);
130 m_currentConsole->setDirRes(dir);
131 m_currentConsole->readSettings();
133 /* The top tree item representing the director */
134 topItem = new QTreeWidgetItem(treeWidget);
135 topItem->setText(0, dir->name());
136 topItem->setIcon(0, QIcon(":images/server.png"));
137 /* Set background to grey for ease of identification of inactive Director */
138 QBrush greyBrush(Qt::lightGray);
139 topItem->setBackground(0, greyBrush);
140 m_currentConsole->setDirectorTreeItem(topItem);
141 m_consoleHash.insert(topItem, m_currentConsole);
143 /* Create Tree Widget Item */
144 item = new QTreeWidgetItem(topItem);
145 item->setText(0, tr("Console"));
146 if (!m_firstItem){ m_firstItem = item; }
147 item->setIcon(0,QIcon(QString::fromUtf8(":images/utilities-terminal.png")));
149 /* insert the cosole and tree widget item into the hashes */
150 hashInsert(item, m_currentConsole);
152 /* Set Color of treeWidgetItem for the console
153 * It will be set to green in the console class if the connection is made.
155 QBrush redBrush(Qt::red);
156 item->setForeground(0, redBrush);
157 m_currentConsole->dockPage();
160 * Create instances in alphabetic order of the rest
161 * of the classes that will by default exist under each Director.
167 createPageJobList("", "", "", "", NULL);
172 new JobPlot(NULL, pass);
181 treeWidget->expandItem(topItem);
182 tabWidget->setCurrentWidget(m_currentConsole);
188 * create an instance of the the joblist class on the stack
190 void MainWin::createPageJobList(const QString &media, const QString &client,
191 const QString &job, const QString &fileset, QTreeWidgetItem *parentTreeWidgetItem)
193 QTreeWidgetItem *holdItem;
195 /* save current tree widget item in case query produces no results */
196 holdItem = treeWidget->currentItem();
197 JobList* joblist = new JobList(media, client, job, fileset, parentTreeWidgetItem);
198 /* If this is a query of jobs on a specific media */
199 if ((media != "") || (client != "") || (job != "") || (fileset != "")) {
200 joblist->setCurrent();
201 /* did query produce results, if not close window and set back to hold */
202 if (joblist->m_resultCount == 0) {
203 joblist->closeStackPage();
204 treeWidget->setCurrentItem(holdItem);
210 * Handle up and down arrow keys for the command line
213 void MainWin::keyPressEvent(QKeyEvent *event)
215 if (m_cmd_history.size() == 0) {
219 switch (event->key()) {
221 if (m_cmd_last < 0 || m_cmd_last >= (m_cmd_history.size()-1)) {
228 if (m_cmd_last == 0) {
232 if (m_cmd_last < 0 || m_cmd_last > (m_cmd_history.size()-1)) {
233 m_cmd_last = m_cmd_history.size() - 1;
242 lineEdit->setText(m_cmd_history[m_cmd_last]);
245 void MainWin::connectSignals()
247 /* Connect signals to slots */
248 connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
249 connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about()));
250 connect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help()));
251 connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
252 connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
253 connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
254 connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
255 connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked()));
256 connect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked()));
257 connect(actionEstimate, SIGNAL(triggered()), this, SLOT(estimateButtonClicked()));
258 connect(actionBrowse, SIGNAL(triggered()), this, SLOT(browseButtonClicked()));
259 connect(actionStatusDirPage, SIGNAL(triggered()), this, SLOT(statusPageButtonClicked()));
261 connect(actionJobPlot, SIGNAL(triggered()), this, SLOT(jobPlotButtonClicked()));
263 connect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked()));
264 connect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton()));
265 connect(actionToggleDock, SIGNAL(triggered()), this, SLOT(toggleDockContextWindow()));
266 connect(actionClosePage, SIGNAL(triggered()), this, SLOT(closePage()));
267 connect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences()));
268 connect(actionRepopLists, SIGNAL(triggered()), this, SLOT(repopLists()));
269 connect(actionReloadRepop, SIGNAL(triggered()), this, SLOT(reloadRepopLists()));
272 void MainWin::disconnectSignals()
274 /* Connect signals to slots */
275 disconnect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
276 disconnect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about()));
277 disconnect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help()));
278 disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
279 disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
280 disconnect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
281 disconnect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
282 disconnect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked()));
283 disconnect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked()));
284 disconnect(actionEstimate, SIGNAL(triggered()), this, SLOT(estimateButtonClicked()));
285 disconnect(actionBrowse, SIGNAL(triggered()), this, SLOT(browseButtonClicked()));
286 disconnect(actionStatusDirPage, SIGNAL(triggered()), this, SLOT(statusPageButtonClicked()));
288 disconnect(actionJobPlot, SIGNAL(triggered()), this, SLOT(jobPlotButtonClicked()));
290 disconnect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked()));
291 disconnect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton()));
292 disconnect(actionToggleDock, SIGNAL(triggered()), this, SLOT(toggleDockContextWindow()));
293 disconnect(actionClosePage, SIGNAL(triggered()), this, SLOT(closePage()));
294 disconnect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences()));
295 disconnect(actionRepopLists, SIGNAL(triggered()), this, SLOT(repopLists()));
296 disconnect(actionReloadRepop, SIGNAL(triggered()), this, SLOT(reloadRepopLists()));
302 void MainWin::waitEnter()
305 if (mainWin->m_connDebug)
306 Pmsg0(000, "Should Never Get Here DANGER DANGER, for now I'll return\n");
310 if (mainWin->m_connDebug)
311 Pmsg0(000, "Entering Wait State\n");
312 app->setOverrideCursor(QCursor(Qt::WaitCursor));
314 disconnectConsoleSignals(m_currentConsole);
315 m_waitTreeItem = treeWidget->currentItem();
321 void MainWin::waitExit()
324 if (mainWin->m_connDebug) Pmsg0(000, "Exiting Wait State\n");
325 app->restoreOverrideCursor();
326 if (m_waitTreeItem != treeWidget->currentItem())
327 treeWidget->setCurrentItem(m_waitTreeItem);
330 connectConsoleSignals();
334 void MainWin::connectConsoleSignals()
336 connect(actionConnect, SIGNAL(triggered()), m_currentConsole, SLOT(connect_dir()));
337 connect(actionSelectFont, SIGNAL(triggered()), m_currentConsole, SLOT(set_font()));
338 connect(actionMessages, SIGNAL(triggered()), m_currentConsole, SLOT(messages()));
341 void MainWin::disconnectConsoleSignals(Console *console)
343 disconnect(actionConnect, SIGNAL(triggered()), console, SLOT(connect_dir()));
344 disconnect(actionMessages, SIGNAL(triggered()), console, SLOT(messages()));
345 disconnect(actionSelectFont, SIGNAL(triggered()), console, SLOT(set_font()));
350 * Two functions to respond to menu items to repop lists and execute reload and repopulate
351 * the lists for jobs, clients, filesets .. ..
353 void MainWin::repopLists()
355 m_currentConsole->populateLists(false);
357 void MainWin::reloadRepopLists()
359 QString cmd = "reload";
360 m_currentConsole->consoleCommand(cmd);
361 m_currentConsole->populateLists(false);
365 * Reimplementation of QWidget closeEvent virtual function
367 void MainWin::closeEvent(QCloseEvent *event)
371 /* Remove all groups from settings for OpenOnExit so that we can start some of the status windows */
372 foreach(Console *console, m_consoleHash){
373 QSettings settings(console->m_dir->name(), "bat");
374 settings.beginGroup("OpenOnExit");
378 /* close all non console pages, this will call settings in destructors */
379 while (m_consoleHash.count() < m_pagehash.count()) {
380 foreach(Pages *page, m_pagehash) {
381 if (page != page->console()) {
382 QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(page);
383 if (pageSelectorTreeWidgetItem->childCount() == 0) {
384 page->console()->setCurrent();
385 page->closeStackPage();
390 foreach(Console *console, m_consoleHash){
391 console->writeSettings();
392 console->terminate();
393 console->closeStackPage();
398 void MainWin::writeSettings()
400 QSettings settings("bacula.org", "bat");
402 settings.beginGroup("MainWin");
403 settings.setValue("winSize", size());
404 settings.setValue("winPos", pos());
405 settings.setValue("state", saveState());
410 void MainWin::readSettings()
412 QSettings settings("bacula.org", "bat");
414 settings.beginGroup("MainWin");
415 resize(settings.value("winSize", QSize(1041, 801)).toSize());
416 move(settings.value("winPos", QPoint(200, 150)).toPoint());
417 restoreState(settings.value("state").toByteArray());
422 * This subroutine is called with an item in the Page Selection window
425 void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/)
427 /* Is this a page that has been inserted into the hash */
428 if (getFromHash(item)) {
429 Pages* page = getFromHash(item);
430 int stackindex=tabWidget->indexOf(page);
432 if (stackindex >= 0) {
433 tabWidget->setCurrentWidget(page);
435 /* run the virtual function in case this class overrides it */
436 page->PgSeltreeWidgetClicked();
441 * Called with a change of the highlighed tree widget item in the page selector.
443 void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *previousitem)
445 if (m_isClosing) return; /* if closing the application, do nothing here */
447 Pages *previousPage, *nextPage;
448 Console *previousConsole = NULL;
449 Console *nextConsole;
451 /* remove all actions before adding actions appropriate for new page */
452 foreach(QAction* pageAction, treeWidget->actions()) {
453 treeWidget->removeAction(pageAction);
456 /* first determine the next item */
458 /* knowing the treeWidgetItem, get the page from the hash */
459 nextPage = getFromHash(currentitem);
460 nextConsole = m_consoleHash.value(currentitem);
461 /* Is this a page that has been inserted into the hash */
463 nextConsole = nextPage->console();
464 /* then is it a treeWidgetItem representing a director */
465 } else if (nextConsole) {
466 /* let the next page BE the console */
467 nextPage = nextConsole;
469 /* Should never get here */
474 /* The Previous item */
476 /* this condition prevents a segfault. The first time there is no previousitem*/
478 if (m_treeStackTrap == false) { /* keep track of previous items for going Back */
479 m_treeWidgetStack.append(previousitem);
481 /* knowing the treeWidgetItem, get the page from the hash */
482 previousPage = getFromHash(previousitem);
483 previousConsole = m_consoleHash.value(previousitem);
485 previousConsole = previousPage->console();
486 } else if (previousConsole) {
487 previousPage = previousConsole;
489 if ((previousPage) || (previousConsole)) {
490 if (nextConsole != previousConsole) {
491 /* remove connections to the current console */
492 disconnectConsoleSignals(previousConsole);
493 QTreeWidgetItem *dirItem = previousConsole->directorTreeItem();
494 QBrush greyBrush(Qt::lightGray);
495 dirItem->setBackground(0, greyBrush);
500 /* process the current (next) item */
502 if ((nextPage) || (nextConsole)) {
503 if (nextConsole != previousConsole) {
504 /* make connections to the current console */
505 m_currentConsole = nextConsole;
506 connectConsoleSignals();
508 /* Set director's tree widget background to magenta for ease of identification */
509 QTreeWidgetItem *dirItem = m_currentConsole->directorTreeItem();
510 QBrush magentaBrush(Qt::magenta);
511 dirItem->setBackground(0, magentaBrush);
513 /* set the value for the currently active console */
514 int stackindex = tabWidget->indexOf(nextPage);
516 /* Is this page currently on the stack or is it undocked */
517 if (stackindex >= 0) {
518 /* put this page on the top of the stack */
519 tabWidget->setCurrentIndex(stackindex);
521 /* it is undocked, raise it to the front */
524 /* for the page selectors menu action to dock or undock, set the text */
525 nextPage->setContextMenuDockText();
527 treeWidget->addAction(actionToggleDock);
528 /* if this page is closeable, and it has no childern, then add that action */
529 if ((nextPage->isCloseable()) && (currentitem->child(0) == NULL))
530 treeWidget->addAction(actionClosePage);
532 /* Add the actions to the Page Selectors tree widget that are part of the
533 * current items list of desired actions regardless of whether on top of stack*/
534 treeWidget->addActions(nextPage->m_contextActions);
538 void MainWin::labelButtonClicked()
543 void MainWin::runButtonClicked()
548 void MainWin::estimateButtonClicked()
553 void MainWin::browseButtonClicked()
558 void MainWin::statusPageButtonClicked()
560 /* if one exists, then just set it current */
562 foreach(Pages *page, m_pagehash) {
563 if (m_currentConsole == page->console()) {
564 if (page->name() == tr("Director Status")) {
574 void MainWin::restoreButtonClicked()
576 new prerestorePage();
579 void MainWin::jobPlotButtonClicked()
584 new JobPlot(NULL, pass);
589 * The user just finished typing a line in the command line edit box
591 void MainWin::input_line()
594 QString cmdStr = lineEdit->text(); /* Get the text */
595 lineEdit->clear(); /* clear the lineEdit box */
596 if (m_currentConsole->is_connected()) {
597 if (m_currentConsole->currentDirComm(conn)) {
598 m_currentConsole->consoleCommand(cmdStr, conn);
600 /* Use consoleCommand to allow typing anything */
601 m_currentConsole->consoleCommand(cmdStr);
604 set_status(tr("Director not connected. Click on connect button."));
606 m_cmd_history.append(cmdStr);
608 if (treeWidget->currentItem() != getFromHash(m_currentConsole))
609 m_currentConsole->setCurrent();
613 void MainWin::about()
615 QMessageBox::about(this, tr("About bat"),
616 tr("<br><h2>bat %1 (%2), by Dirk H Bartley and Kern Sibbald</h2>"
617 "<p>Copyright © 2007-%3 Free Software Foundation Europe e.V."
618 "<p>The <b>bat</b> is an administrative console"
619 " interface to the Director.").arg(VERSION).arg(BDATE).arg(BYEAR));
624 Help::displayFile("index.html");
627 void MainWin::set_statusf(const char *fmt, ...)
632 va_start(arg_ptr, fmt);
633 len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
638 void MainWin::set_status_ready()
640 set_status(tr(" Ready"));
643 void MainWin::set_status(const QString &str)
645 statusBar()->showMessage(str);
648 void MainWin::set_status(const char *buf)
650 statusBar()->showMessage(buf);
654 * Function to respond to the button bar button to undock
656 void MainWin::undockWindowButton()
658 Pages* page = (Pages*)tabWidget->currentWidget();
659 page->togglePageDocking();
663 * Function to respond to action on page selector context menu to toggle the
664 * dock status of the window associated with the page selectors current
667 void MainWin::toggleDockContextWindow()
669 QTreeWidgetItem *currentitem = treeWidget->currentItem();
671 /* Is this a page that has been inserted into the hash */
672 if (getFromHash(currentitem)) {
673 Pages* page = getFromHash(currentitem);
674 page->togglePageDocking();
679 * This function is called when the stack item is changed. Call
680 * the virtual function here. Avoids a window being undocked leaving
681 * a window at the top of the stack unpopulated.
683 void MainWin::stackItemChanged(int)
685 if (m_isClosing) return; /* if closing the application, do nothing here */
686 Pages* page = (Pages*)tabWidget->currentWidget();
687 /* run the virtual function in case this class overrides it */
688 page->currentStackItem();
690 disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
691 disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
692 treeWidget->setCurrentItem(getFromHash(page));
693 connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
694 connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
699 * Function to simplify insertion of QTreeWidgetItem <-> Page association
700 * into a double direction hash.
702 void MainWin::hashInsert(QTreeWidgetItem *item, Pages *page)
704 m_pagehash.insert(item, page);
705 m_widgethash.insert(page, item);
709 * Function to simplify removal of QTreeWidgetItem <-> Page association
710 * into a double direction hash.
712 void MainWin::hashRemove(QTreeWidgetItem *item, Pages *page)
714 /* I had all sorts of return status checking code here. Do we have a log
715 * level capability in bat. I would have left it in but it used printf's
716 * and it should really be some kind of log level facility ???
717 * ******FIXME********/
718 m_pagehash.remove(item);
719 m_widgethash.remove(page);
723 * Function to retrieve a Page* when the item in the page selector's tree is
726 Pages* MainWin::getFromHash(QTreeWidgetItem *item)
728 return m_pagehash.value(item);
732 * Function to retrieve the page selectors tree widget item when the page is
735 QTreeWidgetItem* MainWin::getFromHash(Pages *page)
737 return m_widgethash.value(page);
741 * Function to respond to action on page selector context menu to close the
744 void MainWin::closePage()
746 QTreeWidgetItem *currentitem = treeWidget->currentItem();
748 /* Is this a page that has been inserted into the hash */
749 if (getFromHash(currentitem)) {
750 Pages* page = getFromHash(currentitem);
751 if (page->isCloseable()) {
752 page->closeStackPage();
757 /* Quick function to return the current console */
758 Console *MainWin::currentConsole()
760 return m_currentConsole;
763 /* Quick function to return the tree item for the director */
764 QTreeWidgetItem *MainWin::currentTopItem()
766 return m_currentConsole->directorTreeItem();
769 /* Preferences menu item clicked */
770 void MainWin::setPreferences()
773 prefs.commDebug->setCheckState(m_commDebug ? Qt::Checked : Qt::Unchecked);
774 prefs.connDebug->setCheckState(m_connDebug ? Qt::Checked : Qt::Unchecked);
775 prefs.displayAll->setCheckState(m_displayAll ? Qt::Checked : Qt::Unchecked);
776 prefs.sqlDebug->setCheckState(m_sqlDebug ? Qt::Checked : Qt::Unchecked);
777 prefs.commandDebug->setCheckState(m_commandDebug ? Qt::Checked : Qt::Unchecked);
778 prefs.miscDebug->setCheckState(m_miscDebug ? Qt::Checked : Qt::Unchecked);
779 prefs.recordLimit->setCheckState(m_recordLimitCheck ? Qt::Checked : Qt::Unchecked);
780 prefs.recordSpinBox->setValue(m_recordLimitVal);
781 prefs.daysLimit->setCheckState(m_daysLimitCheck ? Qt::Checked : Qt::Unchecked);
782 prefs.daysSpinBox->setValue(m_daysLimitVal);
783 prefs.checkMessages->setCheckState(m_checkMessages ? Qt::Checked : Qt::Unchecked);
784 prefs.checkMessagesSpin->setValue(m_checkMessagesInterval);
785 prefs.executeLongCheckBox->setCheckState(m_longList ? Qt::Checked : Qt::Unchecked);
786 prefs.rtPopDirCheckBox->setCheckState(m_rtPopDirDebug ? Qt::Checked : Qt::Unchecked);
787 prefs.rtDirCurICCheckBox->setCheckState(m_rtDirCurICDebug ? Qt::Checked : Qt::Unchecked);
788 prefs.rtDirICCheckBox->setCheckState(m_rtDirICDebug ? Qt::Checked : Qt::Unchecked);
789 prefs.rtFileTabICCheckBox->setCheckState(m_rtFileTabICDebug ? Qt::Checked : Qt::Unchecked);
790 prefs.rtVerTabICCheckBox->setCheckState(m_rtVerTabICDebug ? Qt::Checked : Qt::Unchecked);
791 prefs.rtUpdateFTCheckBox->setCheckState(m_rtUpdateFTDebug ? Qt::Checked : Qt::Unchecked);
792 prefs.rtUpdateVTCheckBox->setCheckState(m_rtUpdateVTDebug ? Qt::Checked : Qt::Unchecked);
793 prefs.rtChecksCheckBox->setCheckState(m_rtChecksDebug ? Qt::Checked : Qt::Unchecked);
794 prefs.rtIconStateCheckBox->setCheckState(m_rtIconStateDebug ? Qt::Checked : Qt::Unchecked);
795 prefs.rtRestore1CheckBox->setCheckState(m_rtRestore1Debug ? Qt::Checked : Qt::Unchecked);
796 prefs.rtRestore2CheckBox->setCheckState(m_rtRestore2Debug ? Qt::Checked : Qt::Unchecked);
797 prefs.rtRestore3CheckBox->setCheckState(m_rtRestore3Debug ? Qt::Checked : Qt::Unchecked);
798 switch (ItemFormatterBase::getBytesConversion()) {
799 case ItemFormatterBase::BYTES_CONVERSION_NONE:
800 prefs.radioConvertOff->setChecked(Qt::Checked);
802 case ItemFormatterBase::BYTES_CONVERSION_IEC:
803 prefs.radioConvertIEC->setChecked(Qt::Checked);
806 prefs.radioConvertStandard->setChecked(Qt::Checked);
809 prefs.openPlotCheckBox->setCheckState(m_openPlot ? Qt::Checked : Qt::Unchecked);
811 prefs.openPlotCheckBox->setVisible(false);
813 prefs.openBrowserCheckBox->setCheckState(m_openBrowser ? Qt::Checked : Qt::Unchecked);
814 prefs.openDirStatCheckBox->setCheckState(m_openDirStat ? Qt::Checked : Qt::Unchecked);
818 /* Preferences dialog */
819 prefsDialog::prefsDialog()
824 void prefsDialog::accept()
827 mainWin->m_commDebug = this->commDebug->checkState() == Qt::Checked;
828 mainWin->m_connDebug = this->connDebug->checkState() == Qt::Checked;
829 mainWin->m_displayAll = this->displayAll->checkState() == Qt::Checked;
830 mainWin->m_sqlDebug = this->sqlDebug->checkState() == Qt::Checked;
831 mainWin->m_commandDebug = this->commandDebug->checkState() == Qt::Checked;
832 mainWin->m_miscDebug = this->miscDebug->checkState() == Qt::Checked;
833 mainWin->m_recordLimitCheck = this->recordLimit->checkState() == Qt::Checked;
834 mainWin->m_recordLimitVal = this->recordSpinBox->value();
835 mainWin->m_daysLimitCheck = this->daysLimit->checkState() == Qt::Checked;
836 mainWin->m_daysLimitVal = this->daysSpinBox->value();
837 mainWin->m_checkMessages = this->checkMessages->checkState() == Qt::Checked;
838 mainWin->m_checkMessagesInterval = this->checkMessagesSpin->value();
839 mainWin->m_longList = this->executeLongCheckBox->checkState() == Qt::Checked;
841 mainWin->m_rtPopDirDebug = this->rtPopDirCheckBox->checkState() == Qt::Checked;
842 mainWin->m_rtDirCurICDebug = this->rtDirCurICCheckBox->checkState() == Qt::Checked;
843 mainWin->m_rtDirICDebug = this->rtDirICCheckBox->checkState() == Qt::Checked;
844 mainWin->m_rtFileTabICDebug = this->rtFileTabICCheckBox->checkState() == Qt::Checked;
845 mainWin->m_rtVerTabICDebug = this->rtVerTabICCheckBox->checkState() == Qt::Checked;
846 mainWin->m_rtUpdateFTDebug = this->rtUpdateFTCheckBox->checkState() == Qt::Checked;
847 mainWin->m_rtUpdateVTDebug = this->rtUpdateVTCheckBox->checkState() == Qt::Checked;
848 mainWin->m_rtChecksDebug = this->rtChecksCheckBox->checkState() == Qt::Checked;
849 mainWin->m_rtIconStateDebug = this->rtIconStateCheckBox->checkState() == Qt::Checked;
850 mainWin->m_rtRestore1Debug = this->rtRestore1CheckBox->checkState() == Qt::Checked;
851 mainWin->m_rtRestore2Debug = this->rtRestore2CheckBox->checkState() == Qt::Checked;
852 mainWin->m_rtRestore3Debug = this->rtRestore3CheckBox->checkState() == Qt::Checked;
853 if (this->radioConvertOff->isChecked()) {
854 ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_NONE);
855 } else if (this->radioConvertIEC->isChecked()){
856 ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_IEC);
858 ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_SI);
860 mainWin->m_openPlot = this->openPlotCheckBox->checkState() == Qt::Checked;
861 mainWin->m_openBrowser = this->openBrowserCheckBox->checkState() == Qt::Checked;
862 mainWin->m_openDirStat = this->openDirStatCheckBox->checkState() == Qt::Checked;
864 QSettings settings("www.bacula.org", "bat");
865 settings.beginGroup("Debug");
866 settings.setValue("commDebug", mainWin->m_commDebug);
867 settings.setValue("connDebug", mainWin->m_connDebug);
868 settings.setValue("displayAll", mainWin->m_displayAll);
869 settings.setValue("sqlDebug", mainWin->m_sqlDebug);
870 settings.setValue("commandDebug", mainWin->m_commandDebug);
871 settings.setValue("miscDebug", mainWin->m_miscDebug);
873 settings.beginGroup("JobList");
874 settings.setValue("recordLimitCheck", mainWin->m_recordLimitCheck);
875 settings.setValue("recordLimitVal", mainWin->m_recordLimitVal);
876 settings.setValue("daysLimitCheck", mainWin->m_daysLimitCheck);
877 settings.setValue("daysLimitVal", mainWin->m_daysLimitVal);
879 settings.beginGroup("Timers");
880 settings.setValue("checkMessages", mainWin->m_checkMessages);
881 settings.setValue("checkMessagesInterval", mainWin->m_checkMessagesInterval);
883 settings.beginGroup("Misc");
884 settings.setValue("longList", mainWin->m_longList);
885 settings.setValue("byteConvert", ItemFormatterBase::getBytesConversion());
886 settings.setValue("openplot", mainWin->m_openPlot);
887 settings.setValue("openbrowser", mainWin->m_openBrowser);
888 settings.setValue("opendirstat", mainWin->m_openDirStat);
890 settings.beginGroup("RestoreTree");
891 settings.setValue("rtPopDirDebug", mainWin->m_rtPopDirDebug);
892 settings.setValue("rtDirCurICDebug", mainWin->m_rtDirCurICDebug);
893 settings.setValue("rtDirCurICRetDebug", mainWin->m_rtDirICDebug);
894 settings.setValue("rtFileTabICDebug", mainWin->m_rtFileTabICDebug);
895 settings.setValue("rtVerTabICDebug", mainWin->m_rtVerTabICDebug);
896 settings.setValue("rtUpdateFTDebug", mainWin->m_rtUpdateFTDebug);
897 settings.setValue("rtUpdateVTDebug", mainWin->m_rtUpdateVTDebug);
898 settings.setValue("rtChecksDebug", mainWin->m_rtChecksDebug);
899 settings.setValue("rtIconStateDebug", mainWin->m_rtIconStateDebug);
900 settings.setValue("rtRestore1Debug", mainWin->m_rtRestore1Debug);
901 settings.setValue("rtRestore2Debug", mainWin->m_rtRestore2Debug);
902 settings.setValue("rtRestore3Debug", mainWin->m_rtRestore3Debug);
906 void prefsDialog::reject()
909 mainWin->set_status(tr("Canceled"));
912 /* read preferences for the prefences dialog box */
913 void MainWin::readPreferences()
915 QSettings settings("www.bacula.org", "bat");
916 settings.beginGroup("Debug");
917 m_commDebug = settings.value("commDebug", false).toBool();
918 m_connDebug = settings.value("connDebug", false).toBool();
919 m_displayAll = settings.value("displayAll", false).toBool();
920 m_sqlDebug = settings.value("sqlDebug", false).toBool();
921 m_commandDebug = settings.value("commandDebug", false).toBool();
922 m_miscDebug = settings.value("miscDebug", false).toBool();
924 settings.beginGroup("JobList");
925 m_recordLimitCheck = settings.value("recordLimitCheck", true).toBool();
926 m_recordLimitVal = settings.value("recordLimitVal", 150).toInt();
927 m_daysLimitCheck = settings.value("daysLimitCheck", false).toBool();
928 m_daysLimitVal = settings.value("daysLimitVal", 28).toInt();
930 settings.beginGroup("Timers");
931 m_checkMessages = settings.value("checkMessages", false).toBool();
932 m_checkMessagesInterval = settings.value("checkMessagesInterval", 28).toInt();
934 settings.beginGroup("Misc");
935 m_longList = settings.value("longList", false).toBool();
936 ItemFormatterBase::setBytesConversion(
937 (ItemFormatterBase::BYTES_CONVERSION) settings.value("byteConvert",
938 ItemFormatterBase::BYTES_CONVERSION_IEC).toInt());
939 m_openPlot = settings.value("openplot", false).toBool();
940 m_openBrowser = settings.value("openbrowser", false).toBool();
941 m_openDirStat = settings.value("opendirstat", false).toBool();
943 settings.beginGroup("RestoreTree");
944 m_rtPopDirDebug = settings.value("rtPopDirDebug", false).toBool();
945 m_rtDirCurICDebug = settings.value("rtDirCurICDebug", false).toBool();
946 m_rtDirICDebug = settings.value("rtDirCurICRetDebug", false).toBool();
947 m_rtFileTabICDebug = settings.value("rtFileTabICDebug", false).toBool();
948 m_rtVerTabICDebug = settings.value("rtVerTabICDebug", false).toBool();
949 m_rtUpdateFTDebug = settings.value("rtUpdateFTDebug", false).toBool();
950 m_rtUpdateVTDebug = settings.value("rtUpdateVTDebug", false).toBool();
951 m_rtChecksDebug = settings.value("rtChecksDebug", false).toBool();
952 m_rtIconStateDebug = settings.value("rtIconStateDebug", false).toBool();
953 m_rtRestore1Debug = settings.value("rtRestore1Debug", false).toBool();
954 m_rtRestore2Debug = settings.value("rtRestore2Debug", false).toBool();
955 m_rtRestore3Debug = settings.value("rtRestore3Debug", false).toBool();
959 void MainWin::setMessageIcon()
961 if (m_currentConsole->is_messagesPending())
962 actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-pending.png")));
964 actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-new.png")));
967 void MainWin::goToPreviousPage()
969 m_treeStackTrap = true;
972 /* If stack list is emtpty, then done */
973 if (m_treeWidgetStack.isEmpty()) {
976 QTreeWidgetItem* testItem = m_treeWidgetStack.takeLast();
977 QTreeWidgetItemIterator it(treeWidget);
978 /* lets avoid a segfault by setting an item current that no longer exists */
980 if (*it == testItem) {
981 if (testItem != treeWidget->currentItem()) {
982 treeWidget->setCurrentItem(testItem);
991 m_treeStackTrap = false;