2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2008 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 John Walker.
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)
70 m_dtformat = "yyyy-MM-dd HH:mm:ss";
72 setupUi(this); /* Setup UI defined by main.ui (designer) */
73 register_message_callback(message_callback);
76 treeWidget->setColumnCount(1);
77 treeWidget->setHeaderLabel( tr("Select Page") );
78 treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
87 actionJobPlot->setEnabled(false);
88 actionJobPlot->setVisible(false);
95 foreach(Console *console, m_consoleHash) {
96 console->connect_dir();
98 m_currentConsole = (Console*)getFromHash(m_firstItem);
99 m_currentConsole->setCurrent();
101 QString directoryResourceName;
102 m_currentConsole->getDirResName(directoryResourceName);
103 Pmsg1(000, "Setting initial window to %s\n", directoryResourceName.toUtf8().data());
107 void MainWin::createPages()
110 QTreeWidgetItem *item, *topItem;
114 foreach_res(dir, R_DIRECTOR) {
116 /* Create console tree stacked widget item */
117 m_currentConsole = new Console(stackedWidget);
118 m_currentConsole->setDirRes(dir);
119 m_currentConsole->readSettings();
121 /* The top tree item representing the director */
122 topItem = new QTreeWidgetItem(treeWidget);
123 topItem->setText(0, dir->name());
124 topItem->setIcon(0, QIcon(":images/server.png"));
125 /* Set background to grey for ease of identification of inactive Director */
126 QBrush greyBrush(Qt::lightGray);
127 topItem->setBackground(0, greyBrush);
128 m_currentConsole->setDirectorTreeItem(topItem);
129 m_consoleHash.insert(topItem, m_currentConsole);
131 /* Create Tree Widget Item */
132 item = new QTreeWidgetItem(topItem);
133 item->setText(0, tr("Console"));
134 if (!m_firstItem){ m_firstItem = item; }
135 item->setIcon(0,QIcon(QString::fromUtf8(":images/utilities-terminal.png")));
137 /* insert the cosole and tree widget item into the hashes */
138 hashInsert(item, m_currentConsole);
140 /* Set Color of treeWidgetItem for the console
141 * It will be set to green in the console class if the connection is made.
143 QBrush redBrush(Qt::red);
144 item->setForeground(0, redBrush);
145 m_currentConsole->dockPage();
148 * Create instances in alphabetic order of the rest
149 * of the classes that will by default exist under each Director.
155 createPageJobList("", "", "", "", NULL);
160 new JobPlot(NULL, pass);
169 treeWidget->expandItem(topItem);
170 stackedWidget->setCurrentWidget(m_currentConsole);
176 * create an instance of the the joblist class on the stack
178 void MainWin::createPageJobList(const QString &media, const QString &client,
179 const QString &job, const QString &fileset, QTreeWidgetItem *parentTreeWidgetItem)
181 QTreeWidgetItem *holdItem;
183 /* save current tree widget item in case query produces no results */
184 holdItem = treeWidget->currentItem();
185 JobList* joblist = new JobList(media, client, job, fileset, parentTreeWidgetItem);
186 /* If this is a query of jobs on a specific media */
187 if ((media != "") || (client != "") || (job != "") || (fileset != "")) {
188 joblist->setCurrent();
189 /* did query produce results, if not close window and set back to hold */
190 if (joblist->m_resultCount == 0) {
191 joblist->closeStackPage();
192 treeWidget->setCurrentItem(holdItem);
198 * Handle up and down arrow keys for the command line
201 void MainWin::keyPressEvent(QKeyEvent *event)
203 if (m_cmd_history.size() == 0) {
207 switch (event->key()) {
209 if (m_cmd_last < 0 || m_cmd_last >= (m_cmd_history.size()-1)) {
216 if (m_cmd_last == 0) {
220 if (m_cmd_last < 0 || m_cmd_last > (m_cmd_history.size()-1)) {
221 m_cmd_last = m_cmd_history.size() - 1;
230 lineEdit->setText(m_cmd_history[m_cmd_last]);
233 void MainWin::createConnections()
235 /* Connect signals to slots */
236 connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
237 connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about()));
238 connect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help()));
239 connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this,
240 SLOT(treeItemClicked(QTreeWidgetItem *, int)));
241 connect(treeWidget, SIGNAL(
242 currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
243 this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
244 connect(stackedWidget, SIGNAL(currentChanged(int)),
245 this, SLOT(stackItemChanged(int)));
246 connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
247 connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked()));
248 connect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked()));
249 connect(actionEstimate, SIGNAL(triggered()), this, SLOT(estimateButtonClicked()));
250 connect(actionBrowse, SIGNAL(triggered()), this, SLOT(browseButtonClicked()));
251 connect(actionStatusDirPage, SIGNAL(triggered()), this, SLOT(statusPageButtonClicked()));
253 connect(actionJobPlot, SIGNAL(triggered()), this, SLOT(jobPlotButtonClicked()));
255 connect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked()));
256 connect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton()));
257 connect(actionToggleDock, SIGNAL(triggered()), this, SLOT(toggleDockContextWindow()));
258 connect(actionClosePage, SIGNAL(triggered()), this, SLOT(closePage()));
259 connect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences()));
263 * Reimplementation of QWidget closeEvent virtual function
265 void MainWin::closeEvent(QCloseEvent *event)
269 /* foreach(Console *console, m_consoleHash){
270 console->writeSettings();
271 console->terminate();
272 console->closeStackPage();
274 /* close all non console pages, this will call settings in destructors */
275 while (m_consoleHash.count() < m_pagehash.count()) {
276 foreach(Pages *page, m_pagehash) {
277 if (page != page->console()) {
278 QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(page);
279 if (pageSelectorTreeWidgetItem->childCount() == 0) {
280 page->console()->setCurrent();
281 page->closeStackPage();
286 foreach(Console *console, m_consoleHash){
287 console->writeSettings();
288 console->terminate();
289 console->closeStackPage();
294 void MainWin::writeSettings()
296 QSettings settings("bacula.org", "bat");
298 settings.beginGroup("MainWin");
299 settings.setValue("winSize", size());
300 settings.setValue("winPos", pos());
301 settings.setValue("state", saveState());
305 void MainWin::readSettings()
307 QSettings settings("bacula.org", "bat");
309 settings.beginGroup("MainWin");
310 resize(settings.value("winSize", QSize(1041, 801)).toSize());
311 move(settings.value("winPos", QPoint(200, 150)).toPoint());
312 restoreState(settings.value("state").toByteArray());
317 * This subroutine is called with an item in the Page Selection window
320 void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/)
322 /* Is this a page that has been inserted into the hash */
323 if (getFromHash(item)) {
324 Pages* page = getFromHash(item);
325 int stackindex=stackedWidget->indexOf(page);
327 if (stackindex >= 0) {
328 stackedWidget->setCurrentWidget(page);
330 /* run the virtual function in case this class overrides it */
331 page->PgSeltreeWidgetClicked();
336 * Called with a change of the highlighed tree widget item in the page selector.
338 void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *previousitem)
340 if (m_isClosing) return; /* if closing the application, do nothing here */
342 Pages *previousPage, *nextPage;
343 Console *previousConsole = NULL;
344 Console *nextConsole;
346 /* remove all actions before adding actions appropriate for new page */
347 foreach(QAction* pageAction, treeWidget->actions()) {
348 treeWidget->removeAction(pageAction);
351 /* first determine the next item */
353 /* knowing the treeWidgetItem, get the page from the hash */
354 nextPage = getFromHash(currentitem);
355 nextConsole = m_consoleHash.value(currentitem);
356 /* Is this a page that has been inserted into the hash */
358 nextConsole = nextPage->console();
359 /* then is it a treeWidgetItem representing a director */
360 } else if (nextConsole) {
361 /* let the next page BE the console */
362 nextPage = nextConsole;
364 /* Should never get here */
369 /* The Previous item */
371 /* this condition prevents a segfault. The first time there is no previousitem*/
373 /* knowing the treeWidgetItem, get the page from the hash */
374 previousPage = getFromHash(previousitem);
375 previousConsole = m_consoleHash.value(previousitem);
377 previousConsole = previousPage->console();
378 } else if (previousConsole) {
379 previousPage = previousConsole;
381 if ((previousPage) || (previousConsole)) {
382 if (nextConsole != previousConsole) {
383 /* remove connections to the current console */
384 disconnect(actionConnect, SIGNAL(triggered()), previousConsole, SLOT(connect_dir()));
385 disconnect(actionStatusDir, SIGNAL(triggered()), previousConsole, SLOT(status_dir()));
386 disconnect(actionMessages, SIGNAL(triggered()), previousConsole, SLOT(messages()));
387 disconnect(actionSelectFont, SIGNAL(triggered()), previousConsole, SLOT(set_font()));
388 QTreeWidgetItem *dirItem = previousConsole->directorTreeItem();
389 QBrush greyBrush(Qt::lightGray);
390 dirItem->setBackground(0, greyBrush);
395 /* process the current (next) item */
397 if ((nextPage) || (nextConsole)) {
398 if (nextConsole != previousConsole) {
399 /* make connections to the current console */
400 m_currentConsole = nextConsole;
401 connect(actionConnect, SIGNAL(triggered()), m_currentConsole, SLOT(connect_dir()));
402 connect(actionSelectFont, SIGNAL(triggered()), m_currentConsole, SLOT(set_font()));
403 connect(actionStatusDir, SIGNAL(triggered()), m_currentConsole, SLOT(status_dir()));
404 connect(actionMessages, SIGNAL(triggered()), m_currentConsole, SLOT(messages()));
405 /* Set director's tree widget background to magenta for ease of identification */
406 QTreeWidgetItem *dirItem = m_currentConsole->directorTreeItem();
407 QBrush magentaBrush(Qt::magenta);
408 dirItem->setBackground(0, magentaBrush);
410 /* set the value for the currently active console */
411 int stackindex = stackedWidget->indexOf(nextPage);
413 /* Is this page currently on the stack or is it undocked */
414 if (stackindex >= 0) {
415 /* put this page on the top of the stack */
416 stackedWidget->setCurrentIndex(stackindex);
418 /* it is undocked, raise it to the front */
421 /* for the page selectors menu action to dock or undock, set the text */
422 nextPage->setContextMenuDockText();
424 treeWidget->addAction(actionToggleDock);
425 /* if this page is closeable, and it has no childern, then add that action */
426 if ((nextPage->isCloseable()) && (currentitem->child(0) == NULL))
427 treeWidget->addAction(actionClosePage);
429 /* Add the actions to the Page Selectors tree widget that are part of the
430 * current items list of desired actions regardless of whether on top of stack*/
431 treeWidget->addActions(nextPage->m_contextActions);
435 void MainWin::labelButtonClicked()
440 void MainWin::runButtonClicked()
445 void MainWin::estimateButtonClicked()
450 void MainWin::browseButtonClicked()
455 void MainWin::statusPageButtonClicked()
457 /* if one exists, then just set it current */
459 foreach(Pages *page, m_pagehash) {
460 if (m_currentConsole == page->console()) {
461 if (page->name() == tr("Director Status")) {
471 void MainWin::restoreButtonClicked()
473 new prerestorePage();
476 void MainWin::jobPlotButtonClicked()
481 new JobPlot(NULL, pass);
486 * The user just finished typing a line in the command line edit box
488 void MainWin::input_line()
490 QString cmdStr = lineEdit->text(); /* Get the text */
491 lineEdit->clear(); /* clear the lineEdit box */
492 if (m_currentConsole->is_connected()) {
493 /* Use consoleInput to allow typing anything */
494 m_currentConsole->consoleInput(cmdStr);
496 set_status(tr("Director not connected. Click on connect button."));
498 m_cmd_history.append(cmdStr);
500 if (treeWidget->currentItem() != getFromHash(m_currentConsole))
501 m_currentConsole->setCurrent();
505 void MainWin::about()
507 QMessageBox::about(this, tr("About bat"),
508 tr("<br><h2>bat %1 (%2), by Dirk H Bartley and Kern Sibbald</h2>"
509 "<p>Copyright © 2007-%3 Free Software Foundation Europe e.V."
510 "<p>The <b>bat</b> is an administrative console"
511 " interface to the Director.").arg(VERSION).arg(BDATE).arg(BYEAR));
516 Help::displayFile("index.html");
519 void MainWin::set_statusf(const char *fmt, ...)
524 va_start(arg_ptr, fmt);
525 len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
530 void MainWin::set_status_ready()
532 set_status(tr(" Ready"));
535 void MainWin::set_status(const QString &str)
537 statusBar()->showMessage(str);
540 void MainWin::set_status(const char *buf)
542 statusBar()->showMessage(buf);
546 * Function to respond to the button bar button to undock
548 void MainWin::undockWindowButton()
550 Pages* page = (Pages*)stackedWidget->currentWidget();
551 page->togglePageDocking();
555 * Function to respond to action on page selector context menu to toggle the
556 * dock status of the window associated with the page selectors current
559 void MainWin::toggleDockContextWindow()
561 QTreeWidgetItem *currentitem = treeWidget->currentItem();
563 /* Is this a page that has been inserted into the hash */
564 if (getFromHash(currentitem)) {
565 Pages* page = getFromHash(currentitem);
566 page->togglePageDocking();
571 * This function is called when the stack item is changed. Call
572 * the virtual function here. Avoids a window being undocked leaving
573 * a window at the top of the stack unpopulated.
575 void MainWin::stackItemChanged(int)
577 if (m_isClosing) return; /* if closing the application, do nothing here */
578 Pages* page = (Pages*)stackedWidget->currentWidget();
579 /* run the virtual function in case this class overrides it */
580 page->currentStackItem();
584 * Function to simplify insertion of QTreeWidgetItem <-> Page association
585 * into a double direction hash.
587 void MainWin::hashInsert(QTreeWidgetItem *item, Pages *page)
589 m_pagehash.insert(item, page);
590 m_widgethash.insert(page, item);
594 * Function to simplify removal of QTreeWidgetItem <-> Page association
595 * into a double direction hash.
597 void MainWin::hashRemove(QTreeWidgetItem *item, Pages *page)
599 /* I had all sorts of return status checking code here. Do we have a log
600 * level capability in bat. I would have left it in but it used printf's
601 * and it should really be some kind of log level facility ???
602 * ******FIXME********/
603 m_pagehash.remove(item);
604 m_widgethash.remove(page);
608 * Function to retrieve a Page* when the item in the page selector's tree is
611 Pages* MainWin::getFromHash(QTreeWidgetItem *item)
613 return m_pagehash.value(item);
617 * Function to retrieve the page selectors tree widget item when the page is
620 QTreeWidgetItem* MainWin::getFromHash(Pages *page)
622 return m_widgethash.value(page);
626 * Function to respond to action on page selector context menu to close the
629 void MainWin::closePage()
631 QTreeWidgetItem *currentitem = treeWidget->currentItem();
633 /* Is this a page that has been inserted into the hash */
634 if (getFromHash(currentitem)) {
635 Pages* page = getFromHash(currentitem);
636 if (page->isCloseable()) {
637 page->closeStackPage();
642 /* Quick function to return the current console */
643 Console *MainWin::currentConsole()
645 return m_currentConsole;
647 /* Quick function to return the tree item for the director */
648 QTreeWidgetItem *MainWin::currentTopItem()
650 return m_currentConsole->directorTreeItem();
653 /* Preferences menu item clicked */
654 void MainWin::setPreferences()
657 prefs.commDebug->setCheckState(m_commDebug ? Qt::Checked : Qt::Unchecked);
658 prefs.displayAll->setCheckState(m_displayAll ? Qt::Checked : Qt::Unchecked);
659 prefs.sqlDebug->setCheckState(m_sqlDebug ? Qt::Checked : Qt::Unchecked);
660 prefs.commandDebug->setCheckState(m_commandDebug ? Qt::Checked : Qt::Unchecked);
661 prefs.miscDebug->setCheckState(m_miscDebug ? Qt::Checked : Qt::Unchecked);
662 prefs.recordLimit->setCheckState(m_recordLimitCheck ? Qt::Checked : Qt::Unchecked);
663 prefs.recordSpinBox->setValue(m_recordLimitVal);
664 prefs.daysLimit->setCheckState(m_daysLimitCheck ? Qt::Checked : Qt::Unchecked);
665 prefs.daysSpinBox->setValue(m_daysLimitVal);
666 prefs.checkMessages->setCheckState(m_checkMessages ? Qt::Checked : Qt::Unchecked);
667 prefs.checkMessagesSpin->setValue(m_checkMessagesInterval);
668 prefs.refreshStatusDir->setCheckState(m_refreshStatusDir ? Qt::Checked : Qt::Unchecked);
669 prefs.refreshStatusDirSpin->setValue(m_refreshStatusDirInterval);
670 prefs.executeLongCheckBox->setCheckState(m_longList ? Qt::Checked : Qt::Unchecked);
671 prefs.rtPopDirCheckBox->setCheckState(m_rtPopDirDebug ? Qt::Checked : Qt::Unchecked);
672 prefs.rtDirCurICCheckBox->setCheckState(m_rtDirCurICDebug ? Qt::Checked : Qt::Unchecked);
673 prefs.rtDirICCheckBox->setCheckState(m_rtDirICDebug ? Qt::Checked : Qt::Unchecked);
674 prefs.rtFileTabICCheckBox->setCheckState(m_rtFileTabICDebug ? Qt::Checked : Qt::Unchecked);
675 prefs.rtVerTabICCheckBox->setCheckState(m_rtVerTabICDebug ? Qt::Checked : Qt::Unchecked);
676 prefs.rtUpdateFTCheckBox->setCheckState(m_rtUpdateFTDebug ? Qt::Checked : Qt::Unchecked);
677 prefs.rtUpdateVTCheckBox->setCheckState(m_rtUpdateVTDebug ? Qt::Checked : Qt::Unchecked);
678 prefs.rtChecksCheckBox->setCheckState(m_rtChecksDebug ? Qt::Checked : Qt::Unchecked);
679 prefs.rtIconStateCheckBox->setCheckState(m_rtIconStateDebug ? Qt::Checked : Qt::Unchecked);
680 prefs.rtRestore1CheckBox->setCheckState(m_rtRestore1Debug ? Qt::Checked : Qt::Unchecked);
681 prefs.rtRestore2CheckBox->setCheckState(m_rtRestore2Debug ? Qt::Checked : Qt::Unchecked);
682 prefs.rtRestore3CheckBox->setCheckState(m_rtRestore3Debug ? Qt::Checked : Qt::Unchecked);
683 switch (ItemFormatterBase::getBytesConversion()) {
684 case ItemFormatterBase::BYTES_CONVERSION_NONE:
685 prefs.radioConvertOff->setChecked(Qt::Checked);
687 case ItemFormatterBase::BYTES_CONVERSION_IEC:
688 prefs.radioConvertIEC->setChecked(Qt::Checked);
691 prefs.radioConvertStandard->setChecked(Qt::Checked);
694 prefs.openPlotCheckBox->setCheckState(m_openPlot ? Qt::Checked : Qt::Unchecked);
696 prefs.openPlotCheckBox->setVisible(false);
698 prefs.openBrowserCheckBox->setCheckState(m_openBrowser ? Qt::Checked : Qt::Unchecked);
699 prefs.openDirStatCheckBox->setCheckState(m_openDirStat ? Qt::Checked : Qt::Unchecked);
703 /* Preferences dialog */
704 prefsDialog::prefsDialog()
709 void prefsDialog::accept()
712 mainWin->m_commDebug = this->commDebug->checkState() == Qt::Checked;
713 mainWin->m_displayAll = this->displayAll->checkState() == Qt::Checked;
714 mainWin->m_sqlDebug = this->sqlDebug->checkState() == Qt::Checked;
715 mainWin->m_commandDebug = this->commandDebug->checkState() == Qt::Checked;
716 mainWin->m_miscDebug = this->miscDebug->checkState() == Qt::Checked;
717 mainWin->m_recordLimitCheck = this->recordLimit->checkState() == Qt::Checked;
718 mainWin->m_recordLimitVal = this->recordSpinBox->value();
719 mainWin->m_daysLimitCheck = this->daysLimit->checkState() == Qt::Checked;
720 mainWin->m_daysLimitVal = this->daysSpinBox->value();
721 mainWin->m_checkMessages = this->checkMessages->checkState() == Qt::Checked;
722 mainWin->m_checkMessagesInterval = this->checkMessagesSpin->value();
723 mainWin->m_refreshStatusDir = this->refreshStatusDir->checkState() == Qt::Checked;
724 mainWin->m_refreshStatusDirInterval = this->refreshStatusDirSpin->value();
725 mainWin->m_longList = this->executeLongCheckBox->checkState() == Qt::Checked;
727 mainWin->m_rtPopDirDebug = this->rtPopDirCheckBox->checkState() == Qt::Checked;
728 mainWin->m_rtDirCurICDebug = this->rtDirCurICCheckBox->checkState() == Qt::Checked;
729 mainWin->m_rtDirICDebug = this->rtDirICCheckBox->checkState() == Qt::Checked;
730 mainWin->m_rtFileTabICDebug = this->rtFileTabICCheckBox->checkState() == Qt::Checked;
731 mainWin->m_rtVerTabICDebug = this->rtVerTabICCheckBox->checkState() == Qt::Checked;
732 mainWin->m_rtUpdateFTDebug = this->rtUpdateFTCheckBox->checkState() == Qt::Checked;
733 mainWin->m_rtUpdateVTDebug = this->rtUpdateVTCheckBox->checkState() == Qt::Checked;
734 mainWin->m_rtChecksDebug = this->rtChecksCheckBox->checkState() == Qt::Checked;
735 mainWin->m_rtIconStateDebug = this->rtIconStateCheckBox->checkState() == Qt::Checked;
736 mainWin->m_rtRestore1Debug = this->rtRestore1CheckBox->checkState() == Qt::Checked;
737 mainWin->m_rtRestore2Debug = this->rtRestore2CheckBox->checkState() == Qt::Checked;
738 mainWin->m_rtRestore3Debug = this->rtRestore3CheckBox->checkState() == Qt::Checked;
739 if (this->radioConvertOff->isChecked()) {
740 ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_NONE);
741 } else if (this->radioConvertIEC->isChecked()){
742 ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_IEC);
744 ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_SI);
746 mainWin->m_openPlot = this->openPlotCheckBox->checkState() == Qt::Checked;
747 mainWin->m_openBrowser = this->openBrowserCheckBox->checkState() == Qt::Checked;
748 mainWin->m_openDirStat = this->openDirStatCheckBox->checkState() == Qt::Checked;
750 QSettings settings("www.bacula.org", "bat");
751 settings.beginGroup("Debug");
752 settings.setValue("commDebug", mainWin->m_commDebug);
753 settings.setValue("displayAll", mainWin->m_displayAll);
754 settings.setValue("sqlDebug", mainWin->m_sqlDebug);
755 settings.setValue("commandDebug", mainWin->m_commandDebug);
756 settings.setValue("miscDebug", mainWin->m_miscDebug);
758 settings.beginGroup("JobList");
759 settings.setValue("recordLimitCheck", mainWin->m_recordLimitCheck);
760 settings.setValue("recordLimitVal", mainWin->m_recordLimitVal);
761 settings.setValue("daysLimitCheck", mainWin->m_daysLimitCheck);
762 settings.setValue("daysLimitVal", mainWin->m_daysLimitVal);
764 settings.beginGroup("Timers");
765 settings.setValue("checkMessages", mainWin->m_checkMessages);
766 settings.setValue("checkMessagesInterval", mainWin->m_checkMessagesInterval);
767 settings.setValue("refreshStatusDir", mainWin->m_refreshStatusDir);
768 settings.setValue("refreshStatusDirInterval", mainWin->m_refreshStatusDirInterval);
770 settings.beginGroup("Misc");
771 settings.setValue("longList", mainWin->m_longList);
772 settings.setValue("byteConvert", ItemFormatterBase::getBytesConversion());
773 settings.setValue("openplot", mainWin->m_openPlot);
774 settings.setValue("openbrowser", mainWin->m_openBrowser);
775 settings.setValue("opendirstat", mainWin->m_openDirStat);
777 settings.beginGroup("RestoreTree");
778 settings.setValue("rtPopDirDebug", mainWin->m_rtPopDirDebug);
779 settings.setValue("rtDirCurICDebug", mainWin->m_rtDirCurICDebug);
780 settings.setValue("rtDirCurICRetDebug", mainWin->m_rtDirICDebug);
781 settings.setValue("rtFileTabICDebug", mainWin->m_rtFileTabICDebug);
782 settings.setValue("rtVerTabICDebug", mainWin->m_rtVerTabICDebug);
783 settings.setValue("rtUpdateFTDebug", mainWin->m_rtUpdateFTDebug);
784 settings.setValue("rtUpdateVTDebug", mainWin->m_rtUpdateVTDebug);
785 settings.setValue("rtChecksDebug", mainWin->m_rtChecksDebug);
786 settings.setValue("rtIconStateDebug", mainWin->m_rtIconStateDebug);
787 settings.setValue("rtRestore1Debug", mainWin->m_rtRestore1Debug);
788 settings.setValue("rtRestore2Debug", mainWin->m_rtRestore2Debug);
789 settings.setValue("rtRestore3Debug", mainWin->m_rtRestore3Debug);
791 foreach(Console *console, mainWin->m_consoleHash) {
792 console->startTimer();
796 void prefsDialog::reject()
799 mainWin->set_status(tr("Canceled"));
802 /* read preferences for the prefences dialog box */
803 void MainWin::readPreferences()
805 QSettings settings("www.bacula.org", "bat");
806 settings.beginGroup("Debug");
807 m_commDebug = settings.value("commDebug", false).toBool();
808 m_displayAll = settings.value("displayAll", false).toBool();
809 m_sqlDebug = settings.value("sqlDebug", false).toBool();
810 m_commandDebug = settings.value("commandDebug", false).toBool();
811 m_miscDebug = settings.value("miscDebug", false).toBool();
813 settings.beginGroup("JobList");
814 m_recordLimitCheck = settings.value("recordLimitCheck", true).toBool();
815 m_recordLimitVal = settings.value("recordLimitVal", 150).toInt();
816 m_daysLimitCheck = settings.value("daysLimitCheck", false).toBool();
817 m_daysLimitVal = settings.value("daysLimitVal", 28).toInt();
819 settings.beginGroup("Timers");
820 m_checkMessages = settings.value("checkMessages", false).toBool();
821 m_checkMessagesInterval = settings.value("checkMessagesInterval", 28).toInt();
822 m_refreshStatusDir = settings.value("refreshStatusDir", false).toBool();
823 m_refreshStatusDirInterval = settings.value("refreshStatusDirInterval", 28).toInt();
825 settings.beginGroup("Misc");
826 m_longList = settings.value("longList", false).toBool();
827 ItemFormatterBase::setBytesConversion(
828 (ItemFormatterBase::BYTES_CONVERSION) settings.value("byteConvert",
829 ItemFormatterBase::BYTES_CONVERSION_IEC).toInt());
830 m_openPlot = settings.value("openplot", false).toBool();
831 m_openBrowser = settings.value("openbrowser", false).toBool();
832 m_openDirStat = settings.value("opendirstat", false).toBool();
834 settings.beginGroup("RestoreTree");
835 m_rtPopDirDebug = settings.value("rtPopDirDebug", false).toBool();
836 m_rtDirCurICDebug = settings.value("rtDirCurICDebug", false).toBool();
837 m_rtDirICDebug = settings.value("rtDirCurICRetDebug", false).toBool();
838 m_rtFileTabICDebug = settings.value("rtFileTabICDebug", false).toBool();
839 m_rtVerTabICDebug = settings.value("rtVerTabICDebug", false).toBool();
840 m_rtUpdateFTDebug = settings.value("rtUpdateFTDebug", false).toBool();
841 m_rtUpdateVTDebug = settings.value("rtUpdateVTDebug", false).toBool();
842 m_rtChecksDebug = settings.value("rtChecksDebug", false).toBool();
843 m_rtIconStateDebug = settings.value("rtIconStateDebug", false).toBool();
844 m_rtRestore1Debug = settings.value("rtRestore1Debug", false).toBool();
845 m_rtRestore2Debug = settings.value("rtRestore2Debug", false).toBool();
846 m_rtRestore3Debug = settings.value("rtRestore3Debug", false).toBool();