+}
+
+/*
+ * Function to respond to the button bar button to undock
+ */
+void MainWin::undockWindowButton()
+{
+ Pages* page = (Pages*)stackedWidget->currentWidget();
+ page->togglePageDocking();
+}
+
+/*
+ * Function to respond to action on page selector context menu to toggle the
+ * dock status of the window associated with the page selectors current
+ * tree widget item.
+ */
+void MainWin::toggleDockContextWindow()
+{
+ QTreeWidgetItem *currentitem = treeWidget->currentItem();
+
+ /* Is this a page that has been inserted into the hash */
+ if (getFromHash(currentitem)) {
+ Pages* page = getFromHash(currentitem);
+ page->togglePageDocking();
+ }
+}
+
+/*
+ * This function is called when the stack item is changed. Call
+ * the virtual function here. Avoids a window being undocked leaving
+ * a window at the top of the stack unpopulated.
+ */
+void MainWin::stackItemChanged(int)
+{
+ if (m_isClosing) return; /* if closing the application, do nothing here */
+ Pages* page = (Pages*)stackedWidget->currentWidget();
+ /* run the virtual function in case this class overrides it */
+ page->currentStackItem();
+}
+
+/*
+ * Function to simplify insertion of QTreeWidgetItem <-> Page association
+ * into a double direction hash.
+ */
+void MainWin::hashInsert(QTreeWidgetItem *item, Pages *page)
+{
+ m_pagehash.insert(item, page);
+ m_widgethash.insert(page, item);
+}
+
+/*
+ * Function to simplify removal of QTreeWidgetItem <-> Page association
+ * into a double direction hash.
+ */
+void MainWin::hashRemove(QTreeWidgetItem *item, Pages *page)
+{
+ /* I had all sorts of return status checking code here. Do we have a log
+ * level capability in bat. I would have left it in but it used printf's
+ * and it should really be some kind of log level facility ???
+ * ******FIXME********/
+ m_pagehash.remove(item);
+ m_widgethash.remove(page);
+}
+
+/*
+ * Function to retrieve a Page* when the item in the page selector's tree is
+ * known.
+ */
+Pages* MainWin::getFromHash(QTreeWidgetItem *item)
+{
+ return m_pagehash.value(item);
+}
+
+/*
+ * Function to retrieve the page selectors tree widget item when the page is
+ * known.
+ */
+QTreeWidgetItem* MainWin::getFromHash(Pages *page)
+{
+ return m_widgethash.value(page);
+}
+
+/*
+ * Function to respond to action on page selector context menu to close the
+ * current window.
+ */
+void MainWin::closePage()
+{
+ QTreeWidgetItem *currentitem = treeWidget->currentItem();
+
+ /* Is this a page that has been inserted into the hash */
+ if (getFromHash(currentitem)) {
+ Pages* page = getFromHash(currentitem);
+ if (page->isCloseable()) {
+ page->closeStackPage();
+ }
+ }
+}
+
+/* Quick function to return the current console */
+Console *MainWin::currentConsole()
+{
+ return m_currentConsole;
+}
+/* Quick function to return the tree item for the director */
+QTreeWidgetItem *MainWin::currentTopItem()
+{
+ return m_currentConsole->directorTreeItem();
+}
+
+/* Preferences menu item clicked */
+void MainWin::setPreferences()
+{
+ prefsDialog prefs;
+ prefs.commDebug->setCheckState(m_commDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.displayAll->setCheckState(m_displayAll ? Qt::Checked : Qt::Unchecked);
+ prefs.sqlDebug->setCheckState(m_sqlDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.commandDebug->setCheckState(m_commandDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.miscDebug->setCheckState(m_miscDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.recordLimit->setCheckState(m_recordLimitCheck ? Qt::Checked : Qt::Unchecked);
+ prefs.recordSpinBox->setValue(m_recordLimitVal);
+ prefs.daysLimit->setCheckState(m_daysLimitCheck ? Qt::Checked : Qt::Unchecked);
+ prefs.daysSpinBox->setValue(m_daysLimitVal);
+ prefs.checkMessages->setCheckState(m_checkMessages ? Qt::Checked : Qt::Unchecked);
+ prefs.checkMessagesSpin->setValue(m_checkMessagesInterval);
+ prefs.executeLongCheckBox->setCheckState(m_longList ? Qt::Checked : Qt::Unchecked);
+ prefs.rtPopDirCheckBox->setCheckState(m_rtPopDirDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtDirCurICCheckBox->setCheckState(m_rtDirCurICDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtDirICCheckBox->setCheckState(m_rtDirICDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtFileTabICCheckBox->setCheckState(m_rtFileTabICDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtVerTabICCheckBox->setCheckState(m_rtVerTabICDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtUpdateFTCheckBox->setCheckState(m_rtUpdateFTDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtUpdateVTCheckBox->setCheckState(m_rtUpdateVTDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtChecksCheckBox->setCheckState(m_rtChecksDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtIconStateCheckBox->setCheckState(m_rtIconStateDebug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtRestore1CheckBox->setCheckState(m_rtRestore1Debug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtRestore2CheckBox->setCheckState(m_rtRestore2Debug ? Qt::Checked : Qt::Unchecked);
+ prefs.rtRestore3CheckBox->setCheckState(m_rtRestore3Debug ? Qt::Checked : Qt::Unchecked);
+ prefs.exec();
+}
+
+/* Preferences dialog */
+prefsDialog::prefsDialog()
+{
+ setupUi(this);
+}
+
+void prefsDialog::accept()
+{
+ this->hide();
+ mainWin->m_commDebug = this->commDebug->checkState() == Qt::Checked;
+ mainWin->m_displayAll = this->displayAll->checkState() == Qt::Checked;
+ mainWin->m_sqlDebug = this->sqlDebug->checkState() == Qt::Checked;
+ mainWin->m_commandDebug = this->commandDebug->checkState() == Qt::Checked;
+ mainWin->m_miscDebug = this->miscDebug->checkState() == Qt::Checked;
+ mainWin->m_recordLimitCheck = this->recordLimit->checkState() == Qt::Checked;
+ mainWin->m_recordLimitVal = this->recordSpinBox->value();
+ mainWin->m_daysLimitCheck = this->daysLimit->checkState() == Qt::Checked;
+ mainWin->m_daysLimitVal = this->daysSpinBox->value();
+ mainWin->m_checkMessages = this->checkMessages->checkState() == Qt::Checked;
+ mainWin->m_checkMessagesInterval = this->checkMessagesSpin->value();
+ mainWin->m_longList = this->executeLongCheckBox->checkState() == Qt::Checked;
+
+ mainWin->m_rtPopDirDebug = this->rtPopDirCheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtDirCurICDebug = this->rtDirCurICCheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtDirICDebug = this->rtDirICCheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtFileTabICDebug = this->rtFileTabICCheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtVerTabICDebug = this->rtVerTabICCheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtUpdateFTDebug = this->rtUpdateFTCheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtUpdateVTDebug = this->rtUpdateVTCheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtChecksDebug = this->rtChecksCheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtIconStateDebug = this->rtIconStateCheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtRestore1Debug = this->rtRestore1CheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtRestore2Debug = this->rtRestore2CheckBox->checkState() == Qt::Checked;
+ mainWin->m_rtRestore3Debug = this->rtRestore3CheckBox->checkState() == Qt::Checked;
+
+ QSettings settings("www.bacula.org", "bat");
+ settings.beginGroup("Debug");
+ settings.setValue("commDebug", mainWin->m_commDebug);
+ settings.setValue("displayAll", mainWin->m_displayAll);
+ settings.setValue("sqlDebug", mainWin->m_sqlDebug);
+ settings.setValue("commandDebug", mainWin->m_commandDebug);
+ settings.setValue("miscDebug", mainWin->m_miscDebug);
+ settings.endGroup();
+ settings.beginGroup("JobList");
+ settings.setValue("recordLimitCheck", mainWin->m_recordLimitCheck);
+ settings.setValue("recordLimitVal", mainWin->m_recordLimitVal);
+ settings.setValue("daysLimitCheck", mainWin->m_daysLimitCheck);
+ settings.setValue("daysLimitVal", mainWin->m_daysLimitVal);
+ settings.endGroup();
+ settings.beginGroup("Messages");
+ settings.setValue("checkMessages", mainWin->m_checkMessages);
+ settings.setValue("checkMessagesInterval", mainWin->m_checkMessagesInterval);
+ settings.endGroup();
+ settings.beginGroup("Misc");
+ settings.setValue("longList", mainWin->m_longList);
+ settings.endGroup();
+ settings.beginGroup("RestoreTree");
+ settings.setValue("rtPopDirDebug", mainWin->m_rtPopDirDebug);
+ settings.setValue("rtDirCurICDebug", mainWin->m_rtDirCurICDebug);
+ settings.setValue("rtDirCurICRetDebug", mainWin->m_rtDirICDebug);
+ settings.setValue("rtFileTabICDebug", mainWin->m_rtFileTabICDebug);
+ settings.setValue("rtVerTabICDebug", mainWin->m_rtVerTabICDebug);
+ settings.setValue("rtUpdateFTDebug", mainWin->m_rtUpdateFTDebug);
+ settings.setValue("rtUpdateVTDebug", mainWin->m_rtUpdateVTDebug);
+ settings.setValue("rtChecksDebug", mainWin->m_rtChecksDebug);
+ settings.setValue("rtIconStateDebug", mainWin->m_rtIconStateDebug);
+ settings.setValue("rtRestore1Debug", mainWin->m_rtRestore1Debug);
+ settings.setValue("rtRestore2Debug", mainWin->m_rtRestore2Debug);
+ settings.setValue("rtRestore3Debug", mainWin->m_rtRestore3Debug);
+ settings.endGroup();
+ foreach(Console *console, mainWin->m_consoleHash) {
+ console->startTimer();
+ }
+}
+
+void prefsDialog::reject()
+{
+ this->hide();
+ mainWin->set_status("Canceled");
+}
+
+/* read preferences for the prefences dialog box */
+void MainWin::readPreferences()
+{
+ QSettings settings("www.bacula.org", "bat");
+ settings.beginGroup("Debug");
+ m_commDebug = settings.value("commDebug", false).toBool();
+ m_displayAll = settings.value("displayAll", false).toBool();
+ m_sqlDebug = settings.value("sqlDebug", false).toBool();
+ m_commandDebug = settings.value("commandDebug", false).toBool();
+ m_miscDebug = settings.value("miscDebug", false).toBool();
+ settings.endGroup();
+ settings.beginGroup("JobList");
+ m_recordLimitCheck = settings.value("recordLimitCheck", true).toBool();
+ m_recordLimitVal = settings.value("recordLimitVal", 150).toInt();
+ m_daysLimitCheck = settings.value("daysLimitCheck", false).toBool();
+ m_daysLimitVal = settings.value("daysLimitVal", 28).toInt();
+ settings.endGroup();
+ settings.beginGroup("Messages");
+ m_checkMessages = settings.value("checkMessages", false).toBool();
+ m_checkMessagesInterval = settings.value("checkMessagesInterval", 28).toInt();
+ settings.endGroup();
+ settings.beginGroup("Misc");
+ m_longList = settings.value("longList", false).toBool();
+ settings.endGroup();
+ settings.beginGroup("RestoreTree");
+ m_rtPopDirDebug = settings.value("rtPopDirDebug", false).toBool();
+ m_rtDirCurICDebug = settings.value("rtDirCurICDebug", false).toBool();
+ m_rtDirICDebug = settings.value("rtDirCurICRetDebug", false).toBool();
+ m_rtFileTabICDebug = settings.value("rtFileTabICDebug", false).toBool();
+ m_rtVerTabICDebug = settings.value("rtVerTabICDebug", false).toBool();
+ m_rtUpdateFTDebug = settings.value("rtUpdateFTDebug", false).toBool();
+ m_rtUpdateVTDebug = settings.value("rtUpdateVTDebug", false).toBool();
+ m_rtChecksDebug = settings.value("rtChecksDebug", false).toBool();
+ m_rtIconStateDebug = settings.value("rtIconStateDebug", false).toBool();
+ m_rtRestore1Debug = settings.value("rtRestore1Debug", false).toBool();
+ m_rtRestore2Debug = settings.value("rtRestore2Debug", false).toBool();
+ m_rtRestore3Debug = settings.value("rtRestore3Debug", false).toBool();
+ settings.endGroup();