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"
59 * Daemon message callback
61 void message_callback(int /* type */, char *msg)
63 QMessageBox::warning(mainWin, "Bat", msg, QMessageBox::Ok);
66 MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
69 m_dtformat = "yyyy-MM-dd HH:mm:ss";
71 setupUi(this); /* Setup UI defined by main.ui (designer) */
72 register_message_callback(message_callback);
75 treeWidget->setColumnCount(1);
76 treeWidget->setHeaderLabel("Select Page");
77 treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
89 foreach(Console *console, m_consoleHash) {
90 console->connect_dir();
92 m_currentConsole = (Console*)getFromHash(m_firstItem);
93 m_currentConsole->setCurrent();
95 QString directoryResourceName;
96 m_currentConsole->getDirResName(directoryResourceName);
97 Pmsg1(000, "Setting initial window to %s\n", directoryResourceName.toUtf8().data());
101 void MainWin::createPages()
104 QTreeWidgetItem *item, *topItem;
108 foreach_res(dir, R_DIRECTOR) {
110 /* Create console tree stacked widget item */
111 m_currentConsole = new Console(stackedWidget);
112 m_currentConsole->setDirRes(dir);
113 m_currentConsole->readSettings();
115 /* The top tree item representing the director */
116 topItem = new QTreeWidgetItem(treeWidget);
117 topItem->setText(0, dir->name());
118 topItem->setIcon(0, QIcon(":images/server.png"));
119 /* Set background to grey for ease of identification of inactive Director */
120 QBrush greyBrush(Qt::lightGray);
121 topItem->setBackground(0, greyBrush);
122 m_currentConsole->setDirectorTreeItem(topItem);
123 m_consoleHash.insert(topItem, m_currentConsole);
125 /* Create Tree Widget Item */
126 item = new QTreeWidgetItem(topItem);
127 item->setText(0, "Console");
128 if (!m_firstItem){ m_firstItem = item; }
129 item->setIcon(0,QIcon(QString::fromUtf8(":images/utilities-terminal.png")));
131 /* insert the cosole and tree widget item into the hashes */
132 hashInsert(item, m_currentConsole);
134 /* Set Color of treeWidgetItem for the console
135 * It will be set to green in the console class if the connection is made.
137 QBrush redBrush(Qt::red);
138 item->setForeground(0, redBrush);
139 m_currentConsole->dockPage();
142 * Create instances in alphabetic order of the rest
143 * of the classes that will by default exist under each Director.
149 createPageJobList("", "", "", "", NULL);
154 new JobPlot(NULL, pass);
163 treeWidget->expandItem(topItem);
164 stackedWidget->setCurrentWidget(m_currentConsole);
170 * create an instance of the the joblist class on the stack
172 void MainWin::createPageJobList(const QString &media, const QString &client,
173 const QString &job, const QString &fileset, QTreeWidgetItem *parentTreeWidgetItem)
175 QTreeWidgetItem *holdItem;
177 /* save current tree widget item in case query produces no results */
178 holdItem = treeWidget->currentItem();
179 JobList* joblist = new JobList(media, client, job, fileset, parentTreeWidgetItem);
180 /* If this is a query of jobs on a specific media */
181 if ((media != "") || (client != "") || (job != "") || (fileset != "")) {
182 joblist->setCurrent();
183 /* did query produce results, if not close window and set back to hold */
184 if (joblist->m_resultCount == 0) {
185 joblist->closeStackPage();
186 treeWidget->setCurrentItem(holdItem);
192 * Handle up and down arrow keys for the command line
195 void MainWin::keyPressEvent(QKeyEvent *event)
197 if (m_cmd_history.size() == 0) {
201 switch (event->key()) {
203 if (m_cmd_last < 0 || m_cmd_last >= (m_cmd_history.size()-1)) {
210 if (m_cmd_last == 0) {
214 if (m_cmd_last < 0 || m_cmd_last > (m_cmd_history.size()-1)) {
215 m_cmd_last = m_cmd_history.size() - 1;
224 lineEdit->setText(m_cmd_history[m_cmd_last]);
227 void MainWin::createConnections()
229 /* Connect signals to slots */
230 connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
231 connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about()));
232 connect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help()));
233 connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this,
234 SLOT(treeItemClicked(QTreeWidgetItem *, int)));
235 connect(treeWidget, SIGNAL(
236 currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
237 this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
238 connect(stackedWidget, SIGNAL(currentChanged(int)),
239 this, SLOT(stackItemChanged(int)));
240 connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
241 connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked()));
242 connect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked()));
243 connect(actionEstimate, SIGNAL(triggered()), this, SLOT(estimateButtonClicked()));
244 connect(actionBrowse, SIGNAL(triggered()), this, SLOT(browseButtonClicked()));
245 connect(actionStatusDirPage, SIGNAL(triggered()), this, SLOT(statusPageButtonClicked()));
247 connect(actionJobPlot, SIGNAL(triggered()), this, SLOT(jobPlotButtonClicked()));
249 connect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked()));
250 connect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton()));
251 connect(actionToggleDock, SIGNAL(triggered()), this, SLOT(toggleDockContextWindow()));
252 connect(actionClosePage, SIGNAL(triggered()), this, SLOT(closePage()));
253 connect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences()));
257 * Reimplementation of QWidget closeEvent virtual function
259 void MainWin::closeEvent(QCloseEvent *event)
263 /* foreach(Console *console, m_consoleHash){
264 console->writeSettings();
265 console->terminate();
266 console->closeStackPage();
268 /* close all non console pages, this will call settings in destructors */
269 while (m_consoleHash.count() < m_pagehash.count()) {
270 foreach(Pages *page, m_pagehash) {
271 if (page != page->console()) {
272 QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(page);
273 if (pageSelectorTreeWidgetItem->childCount() == 0) {
274 page->console()->setCurrent();
275 page->closeStackPage();
280 foreach(Console *console, m_consoleHash){
281 console->writeSettings();
282 console->terminate();
283 console->closeStackPage();
288 void MainWin::writeSettings()
290 QSettings settings("bacula.org", "bat");
292 settings.beginGroup("MainWin");
293 settings.setValue("winSize", size());
294 settings.setValue("winPos", pos());
295 settings.setValue("state", saveState());
299 void MainWin::readSettings()
301 QSettings settings("bacula.org", "bat");
303 settings.beginGroup("MainWin");
304 resize(settings.value("winSize", QSize(1041, 801)).toSize());
305 move(settings.value("winPos", QPoint(200, 150)).toPoint());
306 restoreState(settings.value("state").toByteArray());
311 * This subroutine is called with an item in the Page Selection window
314 void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/)
316 /* Is this a page that has been inserted into the hash */
317 if (getFromHash(item)) {
318 Pages* page = getFromHash(item);
319 int stackindex=stackedWidget->indexOf(page);
321 if (stackindex >= 0) {
322 stackedWidget->setCurrentWidget(page);
324 /* run the virtual function in case this class overrides it */
325 page->PgSeltreeWidgetClicked();
330 * Called with a change of the highlighed tree widget item in the page selector.
332 void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *previousitem)
334 if (m_isClosing) return; /* if closing the application, do nothing here */
336 Pages *previousPage, *nextPage;
337 Console *previousConsole = NULL;
338 Console *nextConsole;
340 /* remove all actions before adding actions appropriate for new page */
341 foreach(QAction* pageAction, treeWidget->actions()) {
342 treeWidget->removeAction(pageAction);
345 /* first determine the next item */
347 /* knowing the treeWidgetItem, get the page from the hash */
348 nextPage = getFromHash(currentitem);
349 nextConsole = m_consoleHash.value(currentitem);
350 /* Is this a page that has been inserted into the hash */
352 nextConsole = nextPage->console();
353 /* then is it a treeWidgetItem representing a director */
354 } else if (nextConsole) {
355 /* let the next page BE the console */
356 nextPage = nextConsole;
358 /* Should never get here */
363 /* The Previous item */
365 /* this condition prevents a segfault. The first time there is no previousitem*/
367 /* knowing the treeWidgetItem, get the page from the hash */
368 previousPage = getFromHash(previousitem);
369 previousConsole = m_consoleHash.value(previousitem);
371 previousConsole = previousPage->console();
372 } else if (previousConsole) {
373 previousPage = previousConsole;
375 if ((previousPage) || (previousConsole)) {
376 if (nextConsole != previousConsole) {
377 /* remove connections to the current console */
378 disconnect(actionConnect, SIGNAL(triggered()), previousConsole, SLOT(connect_dir()));
379 disconnect(actionStatusDir, SIGNAL(triggered()), previousConsole, SLOT(status_dir()));
380 disconnect(actionMessages, SIGNAL(triggered()), previousConsole, SLOT(messages()));
381 disconnect(actionSelectFont, SIGNAL(triggered()), previousConsole, SLOT(set_font()));
382 QTreeWidgetItem *dirItem = previousConsole->directorTreeItem();
383 QBrush greyBrush(Qt::lightGray);
384 dirItem->setBackground(0, greyBrush);
389 /* process the current (next) item */
391 if ((nextPage) || (nextConsole)) {
392 if (nextConsole != previousConsole) {
393 /* make connections to the current console */
394 m_currentConsole = nextConsole;
395 connect(actionConnect, SIGNAL(triggered()), m_currentConsole, SLOT(connect_dir()));
396 connect(actionSelectFont, SIGNAL(triggered()), m_currentConsole, SLOT(set_font()));
397 connect(actionStatusDir, SIGNAL(triggered()), m_currentConsole, SLOT(status_dir()));
398 connect(actionMessages, SIGNAL(triggered()), m_currentConsole, SLOT(messages()));
399 /* Set director's tree widget background to magenta for ease of identification */
400 QTreeWidgetItem *dirItem = m_currentConsole->directorTreeItem();
401 QBrush magentaBrush(Qt::magenta);
402 dirItem->setBackground(0, magentaBrush);
404 /* set the value for the currently active console */
405 int stackindex = stackedWidget->indexOf(nextPage);
407 /* Is this page currently on the stack or is it undocked */
408 if (stackindex >= 0) {
409 /* put this page on the top of the stack */
410 stackedWidget->setCurrentIndex(stackindex);
412 /* it is undocked, raise it to the front */
415 /* for the page selectors menu action to dock or undock, set the text */
416 nextPage->setContextMenuDockText();
418 treeWidget->addAction(actionToggleDock);
419 /* if this page is closeable, and it has no childern, then add that action */
420 if ((nextPage->isCloseable()) && (currentitem->child(0) == NULL))
421 treeWidget->addAction(actionClosePage);
423 /* Add the actions to the Page Selectors tree widget that are part of the
424 * current items list of desired actions regardless of whether on top of stack*/
425 treeWidget->addActions(nextPage->m_contextActions);
429 void MainWin::labelButtonClicked()
434 void MainWin::runButtonClicked()
439 void MainWin::estimateButtonClicked()
444 void MainWin::browseButtonClicked()
449 void MainWin::statusPageButtonClicked()
451 /* if one exists, then just set it current */
453 foreach(Pages *page, m_pagehash) {
454 if (m_currentConsole == page->console()) {
455 if (page->name() == "Director Status") {
465 void MainWin::restoreButtonClicked()
467 new prerestorePage();
471 void MainWin::jobPlotButtonClicked()
475 new JobPlot(NULL, pass);
480 * The user just finished typing a line in the command line edit box
482 void MainWin::input_line()
484 QString cmdStr = lineEdit->text(); /* Get the text */
485 lineEdit->clear(); /* clear the lineEdit box */
486 if (m_currentConsole->is_connected()) {
487 /* Use consoleInput to allow typing anything */
488 m_currentConsole->consoleInput(cmdStr);
490 set_status(tr("Director not connected. Click on connect button."));
492 m_cmd_history.append(cmdStr);
494 if (treeWidget->currentItem() != getFromHash(m_currentConsole))
495 m_currentConsole->setCurrent();
499 void MainWin::about()
501 QMessageBox::about(this, tr("About bat"),
502 tr("<br><h2>bat " VERSION "(" BDATE "), by Dirk H Bartley and Kern Sibbald</h2>"
503 "<p>Copyright © 2007-" BYEAR " Free Software Foundation Europe e.V."
504 "<p>The <b>bat</b> is an administrative console"
505 " interface to the Director."));
510 Help::displayFile("index.html");
513 void MainWin::set_statusf(const char *fmt, ...)
518 va_start(arg_ptr, fmt);
519 len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
524 void MainWin::set_status_ready()
526 set_status(tr(" Ready"));
529 void MainWin::set_status(const QString &str)
531 statusBar()->showMessage(str);
534 void MainWin::set_status(const char *buf)
536 statusBar()->showMessage(buf);
540 * Function to respond to the button bar button to undock
542 void MainWin::undockWindowButton()
544 Pages* page = (Pages*)stackedWidget->currentWidget();
545 page->togglePageDocking();
549 * Function to respond to action on page selector context menu to toggle the
550 * dock status of the window associated with the page selectors current
553 void MainWin::toggleDockContextWindow()
555 QTreeWidgetItem *currentitem = treeWidget->currentItem();
557 /* Is this a page that has been inserted into the hash */
558 if (getFromHash(currentitem)) {
559 Pages* page = getFromHash(currentitem);
560 page->togglePageDocking();
565 * This function is called when the stack item is changed. Call
566 * the virtual function here. Avoids a window being undocked leaving
567 * a window at the top of the stack unpopulated.
569 void MainWin::stackItemChanged(int)
571 if (m_isClosing) return; /* if closing the application, do nothing here */
572 Pages* page = (Pages*)stackedWidget->currentWidget();
573 /* run the virtual function in case this class overrides it */
574 page->currentStackItem();
578 * Function to simplify insertion of QTreeWidgetItem <-> Page association
579 * into a double direction hash.
581 void MainWin::hashInsert(QTreeWidgetItem *item, Pages *page)
583 m_pagehash.insert(item, page);
584 m_widgethash.insert(page, item);
588 * Function to simplify removal of QTreeWidgetItem <-> Page association
589 * into a double direction hash.
591 void MainWin::hashRemove(QTreeWidgetItem *item, Pages *page)
593 /* I had all sorts of return status checking code here. Do we have a log
594 * level capability in bat. I would have left it in but it used printf's
595 * and it should really be some kind of log level facility ???
596 * ******FIXME********/
597 m_pagehash.remove(item);
598 m_widgethash.remove(page);
602 * Function to retrieve a Page* when the item in the page selector's tree is
605 Pages* MainWin::getFromHash(QTreeWidgetItem *item)
607 return m_pagehash.value(item);
611 * Function to retrieve the page selectors tree widget item when the page is
614 QTreeWidgetItem* MainWin::getFromHash(Pages *page)
616 return m_widgethash.value(page);
620 * Function to respond to action on page selector context menu to close the
623 void MainWin::closePage()
625 QTreeWidgetItem *currentitem = treeWidget->currentItem();
627 /* Is this a page that has been inserted into the hash */
628 if (getFromHash(currentitem)) {
629 Pages* page = getFromHash(currentitem);
630 if (page->isCloseable()) {
631 page->closeStackPage();
636 /* Quick function to return the current console */
637 Console *MainWin::currentConsole()
639 return m_currentConsole;
641 /* Quick function to return the tree item for the director */
642 QTreeWidgetItem *MainWin::currentTopItem()
644 return m_currentConsole->directorTreeItem();
647 /* Preferences menu item clicked */
648 void MainWin::setPreferences()
651 prefs.commDebug->setCheckState(m_commDebug ? Qt::Checked : Qt::Unchecked);
652 prefs.displayAll->setCheckState(m_displayAll ? Qt::Checked : Qt::Unchecked);
653 prefs.sqlDebug->setCheckState(m_sqlDebug ? Qt::Checked : Qt::Unchecked);
654 prefs.commandDebug->setCheckState(m_commandDebug ? Qt::Checked : Qt::Unchecked);
655 prefs.miscDebug->setCheckState(m_miscDebug ? Qt::Checked : Qt::Unchecked);
656 prefs.recordLimit->setCheckState(m_recordLimitCheck ? Qt::Checked : Qt::Unchecked);
657 prefs.recordSpinBox->setValue(m_recordLimitVal);
658 prefs.daysLimit->setCheckState(m_daysLimitCheck ? Qt::Checked : Qt::Unchecked);
659 prefs.daysSpinBox->setValue(m_daysLimitVal);
660 prefs.checkMessages->setCheckState(m_checkMessages ? Qt::Checked : Qt::Unchecked);
661 prefs.checkMessagesSpin->setValue(m_checkMessagesInterval);
662 prefs.refreshStatusDir->setCheckState(m_refreshStatusDir ? Qt::Checked : Qt::Unchecked);
663 prefs.refreshStatusDirSpin->setValue(m_refreshStatusDirInterval);
664 prefs.executeLongCheckBox->setCheckState(m_longList ? Qt::Checked : Qt::Unchecked);
665 prefs.rtPopDirCheckBox->setCheckState(m_rtPopDirDebug ? Qt::Checked : Qt::Unchecked);
666 prefs.rtDirCurICCheckBox->setCheckState(m_rtDirCurICDebug ? Qt::Checked : Qt::Unchecked);
667 prefs.rtDirICCheckBox->setCheckState(m_rtDirICDebug ? Qt::Checked : Qt::Unchecked);
668 prefs.rtFileTabICCheckBox->setCheckState(m_rtFileTabICDebug ? Qt::Checked : Qt::Unchecked);
669 prefs.rtVerTabICCheckBox->setCheckState(m_rtVerTabICDebug ? Qt::Checked : Qt::Unchecked);
670 prefs.rtUpdateFTCheckBox->setCheckState(m_rtUpdateFTDebug ? Qt::Checked : Qt::Unchecked);
671 prefs.rtUpdateVTCheckBox->setCheckState(m_rtUpdateVTDebug ? Qt::Checked : Qt::Unchecked);
672 prefs.rtChecksCheckBox->setCheckState(m_rtChecksDebug ? Qt::Checked : Qt::Unchecked);
673 prefs.rtIconStateCheckBox->setCheckState(m_rtIconStateDebug ? Qt::Checked : Qt::Unchecked);
674 prefs.rtRestore1CheckBox->setCheckState(m_rtRestore1Debug ? Qt::Checked : Qt::Unchecked);
675 prefs.rtRestore2CheckBox->setCheckState(m_rtRestore2Debug ? Qt::Checked : Qt::Unchecked);
676 prefs.rtRestore3CheckBox->setCheckState(m_rtRestore3Debug ? Qt::Checked : Qt::Unchecked);
677 if (m_radioConvert == 0) {
678 prefs.radioConvertOff->setChecked(Qt::Checked);
679 } else if (m_radioConvert == 1){
680 prefs.radioConvertIEC->setChecked(Qt::Checked);
683 prefs.radioConvertStandard->setChecked(Qt::Checked);
685 prefs.openPlotCheckBox->setCheckState(m_openPlot ? Qt::Checked : Qt::Unchecked);
686 prefs.openBrowserCheckBox->setCheckState(m_openBrowser ? Qt::Checked : Qt::Unchecked);
687 prefs.openDirStatCheckBox->setCheckState(m_openDirStat ? Qt::Checked : Qt::Unchecked);
691 /* Preferences dialog */
692 prefsDialog::prefsDialog()
697 void prefsDialog::accept()
700 mainWin->m_commDebug = this->commDebug->checkState() == Qt::Checked;
701 mainWin->m_displayAll = this->displayAll->checkState() == Qt::Checked;
702 mainWin->m_sqlDebug = this->sqlDebug->checkState() == Qt::Checked;
703 mainWin->m_commandDebug = this->commandDebug->checkState() == Qt::Checked;
704 mainWin->m_miscDebug = this->miscDebug->checkState() == Qt::Checked;
705 mainWin->m_recordLimitCheck = this->recordLimit->checkState() == Qt::Checked;
706 mainWin->m_recordLimitVal = this->recordSpinBox->value();
707 mainWin->m_daysLimitCheck = this->daysLimit->checkState() == Qt::Checked;
708 mainWin->m_daysLimitVal = this->daysSpinBox->value();
709 mainWin->m_checkMessages = this->checkMessages->checkState() == Qt::Checked;
710 mainWin->m_checkMessagesInterval = this->checkMessagesSpin->value();
711 mainWin->m_refreshStatusDir = this->refreshStatusDir->checkState() == Qt::Checked;
712 mainWin->m_refreshStatusDirInterval = this->refreshStatusDirSpin->value();
713 mainWin->m_longList = this->executeLongCheckBox->checkState() == Qt::Checked;
715 mainWin->m_rtPopDirDebug = this->rtPopDirCheckBox->checkState() == Qt::Checked;
716 mainWin->m_rtDirCurICDebug = this->rtDirCurICCheckBox->checkState() == Qt::Checked;
717 mainWin->m_rtDirICDebug = this->rtDirICCheckBox->checkState() == Qt::Checked;
718 mainWin->m_rtFileTabICDebug = this->rtFileTabICCheckBox->checkState() == Qt::Checked;
719 mainWin->m_rtVerTabICDebug = this->rtVerTabICCheckBox->checkState() == Qt::Checked;
720 mainWin->m_rtUpdateFTDebug = this->rtUpdateFTCheckBox->checkState() == Qt::Checked;
721 mainWin->m_rtUpdateVTDebug = this->rtUpdateVTCheckBox->checkState() == Qt::Checked;
722 mainWin->m_rtChecksDebug = this->rtChecksCheckBox->checkState() == Qt::Checked;
723 mainWin->m_rtIconStateDebug = this->rtIconStateCheckBox->checkState() == Qt::Checked;
724 mainWin->m_rtRestore1Debug = this->rtRestore1CheckBox->checkState() == Qt::Checked;
725 mainWin->m_rtRestore2Debug = this->rtRestore2CheckBox->checkState() == Qt::Checked;
726 mainWin->m_rtRestore3Debug = this->rtRestore3CheckBox->checkState() == Qt::Checked;
727 if (this->radioConvertOff->isChecked()) {
728 mainWin->m_radioConvert = 0;
729 } else if (this->radioConvertIEC->isChecked()){
730 mainWin->m_radioConvert = 1;
732 mainWin->m_radioConvert = 2;
734 mainWin->m_openPlot = this->openPlotCheckBox->checkState() == Qt::Checked;
735 mainWin->m_openBrowser = this->openBrowserCheckBox->checkState() == Qt::Checked;
736 mainWin->m_openDirStat = this->openDirStatCheckBox->checkState() == Qt::Checked;
738 QSettings settings("www.bacula.org", "bat");
739 settings.beginGroup("Debug");
740 settings.setValue("commDebug", mainWin->m_commDebug);
741 settings.setValue("displayAll", mainWin->m_displayAll);
742 settings.setValue("sqlDebug", mainWin->m_sqlDebug);
743 settings.setValue("commandDebug", mainWin->m_commandDebug);
744 settings.setValue("miscDebug", mainWin->m_miscDebug);
746 settings.beginGroup("JobList");
747 settings.setValue("recordLimitCheck", mainWin->m_recordLimitCheck);
748 settings.setValue("recordLimitVal", mainWin->m_recordLimitVal);
749 settings.setValue("daysLimitCheck", mainWin->m_daysLimitCheck);
750 settings.setValue("daysLimitVal", mainWin->m_daysLimitVal);
752 settings.beginGroup("Timers");
753 settings.setValue("checkMessages", mainWin->m_checkMessages);
754 settings.setValue("checkMessagesInterval", mainWin->m_checkMessagesInterval);
755 settings.setValue("refreshStatusDir", mainWin->m_refreshStatusDir);
756 settings.setValue("refreshStatusDirInterval", mainWin->m_refreshStatusDirInterval);
758 settings.beginGroup("Misc");
759 settings.setValue("longList", mainWin->m_longList);
760 settings.setValue("byteConvert", mainWin->m_radioConvert);
761 settings.setValue("openplot", mainWin->m_openPlot);
762 settings.setValue("openbrowser", mainWin->m_openBrowser);
763 settings.setValue("opendirstat", mainWin->m_openDirStat);
765 settings.beginGroup("RestoreTree");
766 settings.setValue("rtPopDirDebug", mainWin->m_rtPopDirDebug);
767 settings.setValue("rtDirCurICDebug", mainWin->m_rtDirCurICDebug);
768 settings.setValue("rtDirCurICRetDebug", mainWin->m_rtDirICDebug);
769 settings.setValue("rtFileTabICDebug", mainWin->m_rtFileTabICDebug);
770 settings.setValue("rtVerTabICDebug", mainWin->m_rtVerTabICDebug);
771 settings.setValue("rtUpdateFTDebug", mainWin->m_rtUpdateFTDebug);
772 settings.setValue("rtUpdateVTDebug", mainWin->m_rtUpdateVTDebug);
773 settings.setValue("rtChecksDebug", mainWin->m_rtChecksDebug);
774 settings.setValue("rtIconStateDebug", mainWin->m_rtIconStateDebug);
775 settings.setValue("rtRestore1Debug", mainWin->m_rtRestore1Debug);
776 settings.setValue("rtRestore2Debug", mainWin->m_rtRestore2Debug);
777 settings.setValue("rtRestore3Debug", mainWin->m_rtRestore3Debug);
779 foreach(Console *console, mainWin->m_consoleHash) {
780 console->startTimer();
784 void prefsDialog::reject()
787 mainWin->set_status(tr("Canceled"));
790 /* read preferences for the prefences dialog box */
791 void MainWin::readPreferences()
793 QSettings settings("www.bacula.org", "bat");
794 settings.beginGroup("Debug");
795 m_commDebug = settings.value("commDebug", false).toBool();
796 m_displayAll = settings.value("displayAll", false).toBool();
797 m_sqlDebug = settings.value("sqlDebug", false).toBool();
798 m_commandDebug = settings.value("commandDebug", false).toBool();
799 m_miscDebug = settings.value("miscDebug", false).toBool();
801 settings.beginGroup("JobList");
802 m_recordLimitCheck = settings.value("recordLimitCheck", true).toBool();
803 m_recordLimitVal = settings.value("recordLimitVal", 150).toInt();
804 m_daysLimitCheck = settings.value("daysLimitCheck", false).toBool();
805 m_daysLimitVal = settings.value("daysLimitVal", 28).toInt();
807 settings.beginGroup("Timers");
808 m_checkMessages = settings.value("checkMessages", false).toBool();
809 m_checkMessagesInterval = settings.value("checkMessagesInterval", 28).toInt();
810 m_refreshStatusDir = settings.value("refreshStatusDir", false).toBool();
811 m_refreshStatusDirInterval = settings.value("refreshStatusDirInterval", 28).toInt();
813 settings.beginGroup("Misc");
814 m_longList = settings.value("longList", false).toBool();
815 m_radioConvert = settings.value("byteConvert", false).toInt();
816 m_openPlot = settings.value("openplot", false).toBool();
817 m_openBrowser = settings.value("openbrowser", false).toBool();
818 m_openDirStat = settings.value("opendirstat", false).toBool();
820 settings.beginGroup("RestoreTree");
821 m_rtPopDirDebug = settings.value("rtPopDirDebug", false).toBool();
822 m_rtDirCurICDebug = settings.value("rtDirCurICDebug", false).toBool();
823 m_rtDirICDebug = settings.value("rtDirCurICRetDebug", false).toBool();
824 m_rtFileTabICDebug = settings.value("rtFileTabICDebug", false).toBool();
825 m_rtVerTabICDebug = settings.value("rtVerTabICDebug", false).toBool();
826 m_rtUpdateFTDebug = settings.value("rtUpdateFTDebug", false).toBool();
827 m_rtUpdateVTDebug = settings.value("rtUpdateVTDebug", false).toBool();
828 m_rtChecksDebug = settings.value("rtChecksDebug", false).toBool();
829 m_rtIconStateDebug = settings.value("rtIconStateDebug", false).toBool();
830 m_rtRestore1Debug = settings.value("rtRestore1Debug", false).toBool();
831 m_rtRestore2Debug = settings.value("rtRestore2Debug", false).toBool();
832 m_rtRestore3Debug = settings.value("rtRestore3Debug", false).toBool();
836 void MainWin::hrConvert(QString &ret, qlonglong &inval)
842 if (m_radioConvert == 0) {
843 ret = QString("%1").arg(inval);
845 } else if (m_radioConvert == 1){
847 suflist = (QStringList() << "B" << "KiB" << "MiB" << "GiB" << "TiB" << "PiB" << "EiB" << "ZiB");
850 suflist = (QStringList() << "B" << "KB" << "MB" << "GB" << "TB" << "PB" << "EB" << "ZB");
852 qlonglong running = base;
855 while (done == false) {
856 QString test1 = QString("%1").arg(inval);
857 QString test2 = QString("%1").arg(running);
858 if (float(inval) < (float)(running)) {
860 ret = suflist[count - 1];
861 net = (float)inval / (float)(running/base);
864 if (count > suflist.count()) done = true;
869 ret = QString("%1 %2")
870 .arg(net, 0, format, 2, QLatin1Char(' '))
875 void MainWin::hrConvertSeconds(QString &ret, qlonglong &inval)
878 QList<qlonglong> durations;
880 durations.append(60);
881 durations.append(3600);
882 durations.append(86400);
883 durations.append(2592000);
884 durations.append(31536000);
885 QStringList abbrlist = (QStringList() << "Sec" << "Min" << "Hrs" << "Days" << "Mnth" << "Yrs");
888 while (done == false) {
889 QString test1 = QString("%1").arg(inval);
890 QString test2 = QString("%1").arg(durations[count]);
891 if ((inval < durations[count]) || (count >= abbrlist.count() - 1)) {
893 net = (float)inval / (float)(durations[count - 1]);
895 ret = QString("%1 %2")
896 .arg(net, 0, 'f', 2, QLatin1Char(' '))
897 .arg(abbrlist[count - 1]);