]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/mainwin.cpp
Change copyright as per agreement with FSFE
[bacula/bacula] / bacula / src / qt-console / mainwin.cpp
index be3fbce36fee2ae2637d9a8a550a5dd12c047c45..27d477d9b1091ac709608a09136fd36de2a3e87e 100644 (file)
@@ -1,33 +1,23 @@
 /*
-   Bacula® - The Network Backup Solution
-
-   Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
-
-   The main author of Bacula is Kern Sibbald, with contributions from
-   many others, a complete list can be found in the file AUTHORS.
-   This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
-   License as published by the Free Software Foundation and included
-   in the file LICENSE.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Bacula® is a registered trademark of Kern Sibbald.
-   The licensor of Bacula is the Free Software Foundation Europe
-   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
-   Switzerland, email:ftf@fsfeurope.org.
+   Bacula(R) - The Network Backup Solution
+
+   Copyright (C) 2000-2016 Kern Sibbald
+
+   The original author of Bacula is Kern Sibbald, with contributions
+   from many others, a complete list can be found in the file AUTHORS.
+
+   You may use this file and others of this release according to the
+   license defined in the LICENSE file, which includes the Affero General
+   Public License, v3.0 ("AGPLv3") and some additional permissions and
+   terms pursuant to its AGPLv3 Section 7.
+
+   This notice must be preserved when any source code is 
+   conveyed and/or propagated.
+
+   Bacula(R) is a registered trademark of Kern Sibbald.
 */
 
 /*
- *   Version $Id$
  *
  *  Main Window control for bat (qt-console)
  *
@@ -50,6 +40,7 @@
 #include "restore/restoretree.h"
 #include "help/help.h"
 #include "jobs/jobs.h"
+#include "medialist/mediaview.h"
 #ifdef HAVE_QWT
 #include "jobgraphs/jobplot.h"
 #endif
@@ -66,7 +57,11 @@ void message_callback(int /* type */, char *msg)
 
 MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
 {
+   app->setOverrideCursor(QCursor(Qt::WaitCursor));
    m_isClosing = false;
+   m_waitState = false;
+   m_doConnect = false;
+   m_treeStackTrap = false;
    m_dtformat = "yyyy-MM-dd HH:mm:ss";
    mainWin = this;
    setupUi(this);                     /* Setup UI defined by main.ui (designer) */
@@ -76,12 +71,10 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
    treeWidget->setColumnCount(1);
    treeWidget->setHeaderLabel( tr("Select Page") );
    treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
-
+   tabWidget->setTabsClosable(true);  /* wait for QT 4.5 */
    createPages();
 
-   resetFocus();
-
-   connectSignals();
+   resetFocus(); /* lineEdit->setFocus() */
 
 #ifndef HAVE_QWT
    actionJobPlot->setEnabled(false);
@@ -95,14 +88,35 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
    foreach(Console *console, m_consoleHash) {
       console->connect_dir();
    }
+   /* 
+    * Note, the notifier is now a global flag, although each notifier
+    *  can be individually turned on and off at a socket level.  Once
+    *  the notifier is turned off, we don't accept anything from anyone
+    *  this prevents unwanted messages from getting into the input
+    *  dialogs such as restore that read from the director and "know"
+    *  what to expect.
+    */
+   m_notify = true;
    m_currentConsole = (Console*)getFromHash(m_firstItem);
-   m_currentConsole->setCurrent();
-   connectConsoleSignals();
+   QTimer::singleShot(2000, this, SLOT(popLists()));
    if (m_miscDebug) {
       QString directoryResourceName;
       m_currentConsole->getDirResName(directoryResourceName);
       Pmsg1(100, "Setting initial window to %s\n", directoryResourceName.toUtf8().data());
    }
+   app->restoreOverrideCursor();
+}
+
+void MainWin::popLists()
+{
+   foreach(Console *console, m_consoleHash) {
+      console->populateLists(true);
+   }
+   m_doConnect = true;
+   connectConsoleSignals();
+   connectSignals();
+   app->restoreOverrideCursor();
+   m_currentConsole->setCurrent();
 }
 
 void MainWin::createPages()
@@ -115,7 +129,7 @@ void MainWin::createPages()
    foreach_res(dir, R_DIRECTOR) {
 
       /* Create console tree stacked widget item */
-      m_currentConsole = new Console(stackedWidget);
+      m_currentConsole = new Console(tabWidget);
       m_currentConsole->setDirRes(dir);
       m_currentConsole->readSettings();
 
@@ -137,19 +151,19 @@ void MainWin::createPages()
 
       /* insert the cosole and tree widget item into the hashes */
       hashInsert(item, m_currentConsole);
+      m_currentConsole->dockPage();
 
       /* Set Color of treeWidgetItem for the console
       * It will be set to green in the console class if the connection is made.
       */
       QBrush redBrush(Qt::red);
       item->setForeground(0, redBrush);
-      m_currentConsole->dockPage();
 
       /*
        * Create instances in alphabetic order of the rest 
        *  of the classes that will by default exist under each Director.  
        */
-//      new bRestore();
+      new bRestore();
       new Clients();
       new FileSet();
       new Jobs();
@@ -161,14 +175,16 @@ void MainWin::createPages()
          new JobPlot(NULL, pass);
 #endif
       new MediaList();
+      new MediaView();
       new Storage();
-      if (m_openBrowser)
-         new restoreTree();
-      if (m_openDirStat)
+//    if (m_openBrowser) {
+//       new restoreTree();
+//    }
+      if (m_openDirStat) {
          new DirStat();
-
+      }
       treeWidget->expandItem(topItem);
-      stackedWidget->setCurrentWidget(m_currentConsole);
+      tabWidget->setCurrentWidget(m_currentConsole);
    }
    UnlockRes();
 }
@@ -238,8 +254,9 @@ void MainWin::connectSignals()
    connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about()));
    connect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help()));
    connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
-   connect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
-   connect(stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
+   connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+   connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
+   connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closePage(int)));
    connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
    connect(actionLabel, SIGNAL(triggered()), this,  SLOT(labelButtonClicked()));
    connect(actionRun, SIGNAL(triggered()), this,  SLOT(runButtonClicked()));
@@ -252,8 +269,10 @@ void MainWin::connectSignals()
    connect(actionRestore, SIGNAL(triggered()), this,  SLOT(restoreButtonClicked()));
    connect(actionUndock, SIGNAL(triggered()), this,  SLOT(undockWindowButton()));
    connect(actionToggleDock, SIGNAL(triggered()), this,  SLOT(toggleDockContextWindow()));
-   connect(actionClosePage, SIGNAL(triggered()), this,  SLOT(closePage()));
+   connect(actionClosePage, SIGNAL(triggered()), this,  SLOT(closeCurrentPage()));
    connect(actionPreferences, SIGNAL(triggered()), this,  SLOT(setPreferences()));
+   connect(actionRepopLists, SIGNAL(triggered()), this,  SLOT(repopLists()));
+   connect(actionReloadRepop, SIGNAL(triggered()), this,  SLOT(reloadRepopLists()));
 }
 
 void MainWin::disconnectSignals()
@@ -264,7 +283,8 @@ void MainWin::disconnectSignals()
    disconnect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help()));
    disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
    disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
-   disconnect(stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
+   disconnect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
+   disconnect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closePage(int)));
    disconnect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
    disconnect(actionLabel, SIGNAL(triggered()), this,  SLOT(labelButtonClicked()));
    disconnect(actionRun, SIGNAL(triggered()), this,  SLOT(runButtonClicked()));
@@ -277,8 +297,10 @@ void MainWin::disconnectSignals()
    disconnect(actionRestore, SIGNAL(triggered()), this,  SLOT(restoreButtonClicked()));
    disconnect(actionUndock, SIGNAL(triggered()), this,  SLOT(undockWindowButton()));
    disconnect(actionToggleDock, SIGNAL(triggered()), this,  SLOT(toggleDockContextWindow()));
-   disconnect(actionClosePage, SIGNAL(triggered()), this,  SLOT(closePage()));
+   disconnect(actionClosePage, SIGNAL(triggered()), this,  SLOT(closeCurrentPage()));
    disconnect(actionPreferences, SIGNAL(triggered()), this,  SLOT(setPreferences()));
+   disconnect(actionRepopLists, SIGNAL(triggered()), this,  SLOT(repopLists()));
+   disconnect(actionReloadRepop, SIGNAL(triggered()), this,  SLOT(reloadRepopLists()));
 }
 
 /*
@@ -286,8 +308,15 @@ void MainWin::disconnectSignals()
  */
 void MainWin::waitEnter()
 {
+   if (m_waitState || m_isClosing) { 
+      return;
+   }
+   m_waitState = true;
+   if (mainWin->m_connDebug) Pmsg0(000, "Entering Wait State\n");
    app->setOverrideCursor(QCursor(Qt::WaitCursor));
    disconnectSignals();
+   disconnectConsoleSignals(m_currentConsole);
+   m_waitTreeItem = treeWidget->currentItem();
 }
 
 /*
@@ -295,26 +324,51 @@ void MainWin::waitEnter()
  */
 void MainWin::waitExit()
 {
+   if (!m_waitState || m_isClosing) {
+      return;
+   }
+   if (mainWin->m_connDebug) Pmsg0(000, "Exiting Wait State\n");
+   if (m_waitTreeItem && (m_waitTreeItem != treeWidget->currentItem())) {
+      treeWidget->setCurrentItem(m_waitTreeItem);
+   }
+   if (m_doConnect) {
+      connectSignals();
+      connectConsoleSignals();
+   }
    app->restoreOverrideCursor();
-   connectSignals();
+   m_waitState = false;
 }
 
 void MainWin::connectConsoleSignals()
 {
    connect(actionConnect, SIGNAL(triggered()), m_currentConsole, SLOT(connect_dir()));
    connect(actionSelectFont, SIGNAL(triggered()), m_currentConsole, SLOT(set_font()));
-   connect(actionStatusDir, SIGNAL(triggered()), m_currentConsole, SLOT(status_dir()));
    connect(actionMessages, SIGNAL(triggered()), m_currentConsole, SLOT(messages()));
 }
 
 void MainWin::disconnectConsoleSignals(Console *console)
 {
    disconnect(actionConnect, SIGNAL(triggered()), console, SLOT(connect_dir()));
-   disconnect(actionStatusDir, SIGNAL(triggered()), console, SLOT(status_dir()));
    disconnect(actionMessages, SIGNAL(triggered()), console, SLOT(messages()));
    disconnect(actionSelectFont, SIGNAL(triggered()), console, SLOT(set_font()));
 }
 
+
+/* 
+ * Two functions to respond to menu items to repop lists and execute reload and repopulate
+ * the lists for jobs, clients, filesets .. ..
+ */
+void MainWin::repopLists()
+{
+   m_currentConsole->populateLists(false);
+}
+void MainWin::reloadRepopLists()
+{
+   QString cmd = "reload";
+   m_currentConsole->consoleCommand(cmd);
+   m_currentConsole->populateLists(false);
+}
+
 /* 
  * Reimplementation of QWidget closeEvent virtual function   
  */
@@ -322,6 +376,13 @@ void MainWin::closeEvent(QCloseEvent *event)
 {
    m_isClosing = true;
    writeSettings();
+   /* Remove all groups from settings for OpenOnExit so that we can start some of the status windows */
+   foreach(Console *console, m_consoleHash){
+      QSettings settings(console->m_dir->name(), "bat");
+      settings.beginGroup("OpenOnExit");
+      settings.remove("");
+      settings.endGroup();
+   }
    /* close all non console pages, this will call settings in destructors */
    while (m_consoleHash.count() < m_pagehash.count()) {
       foreach(Pages *page, m_pagehash) {
@@ -351,6 +412,7 @@ void MainWin::writeSettings()
    settings.setValue("winPos", pos());
    settings.setValue("state", saveState());
    settings.endGroup();
+
 }
 
 void MainWin::readSettings()
@@ -371,15 +433,18 @@ void MainWin::readSettings()
 void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/)
 {
    /* Is this a page that has been inserted into the hash  */
-   if (getFromHash(item)) {
-      Pages* page = getFromHash(item);
-      int stackindex=stackedWidget->indexOf(page);
+   Pages* page = getFromHash(item);
+   if (page) {
+      int stackindex = tabWidget->indexOf(page);
 
       if (stackindex >= 0) {
-         stackedWidget->setCurrentWidget(page);
+         tabWidget->setCurrentWidget(page);
       }
+      page->dockPage();
       /* run the virtual function in case this class overrides it */
       page->PgSeltreeWidgetClicked();
+   } else {
+      Dmsg0(000, "Page not in hash");
    }
 }
 
@@ -421,6 +486,9 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre
 
    /* this condition prevents a segfault.  The first time there is no previousitem*/
    if (previousitem) {
+      if (m_treeStackTrap == false) { /* keep track of previous items for going Back */
+         m_treeWidgetStack.append(previousitem);
+      }
       /* knowing the treeWidgetItem, get the page from the hash */
       previousPage = getFromHash(previousitem);
       previousConsole = m_consoleHash.value(previousitem);
@@ -454,12 +522,13 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre
          dirItem->setBackground(0, magentaBrush);
       }
       /* set the value for the currently active console */
-      int stackindex = stackedWidget->indexOf(nextPage);
+      int stackindex = tabWidget->indexOf(nextPage);
+      nextPage->firstUseDock();
    
       /* Is this page currently on the stack or is it undocked */
       if (stackindex >= 0) {
          /* put this page on the top of the stack */
-         stackedWidget->setCurrentIndex(stackindex);
+         tabWidget->setCurrentIndex(stackindex);
       } else {
          /* it is undocked, raise it to the front */
          nextPage->raise();
@@ -495,7 +564,7 @@ void MainWin::estimateButtonClicked()
 
 void MainWin::browseButtonClicked() 
 {
-   new restoreTree();
+//   new restoreTree();
 }
 
 void MainWin::statusPageButtonClicked()
@@ -510,13 +579,15 @@ void MainWin::statusPageButtonClicked()
          }
       }
    }
-   if (!found)
+   if (!found) {
       new DirStat();
+   }
 }
 
 void MainWin::restoreButtonClicked() 
 {
    new prerestorePage();
+   if (mainWin->m_miscDebug) Pmsg0(000, "in restoreButtonClicked after prerestorePage\n");
 }
 
 void MainWin::jobPlotButtonClicked()
@@ -533,11 +604,16 @@ void MainWin::jobPlotButtonClicked()
  */
 void MainWin::input_line()
 {
+   int conn;
    QString cmdStr = lineEdit->text();    /* Get the text */
    lineEdit->clear();                    /* clear the lineEdit box */
    if (m_currentConsole->is_connected()) {
-      /* Use consoleInput to allow typing anything */
-      m_currentConsole->consoleInput(cmdStr);
+      if (m_currentConsole->findDirComm(conn)) {
+         m_currentConsole->consoleCommand(cmdStr, conn);
+      } else {
+         /* Use consoleCommand to allow typing anything */
+         m_currentConsole->consoleCommand(cmdStr);
+      }
    } else {
       set_status(tr("Director not connected. Click on connect button."));
    }
@@ -551,8 +627,8 @@ void MainWin::input_line()
 void MainWin::about()
 {
    QMessageBox::about(this, tr("About bat"),
-      tr("<br><h2>bat %1 (%2), by Dirk H Bartley and Kern Sibbald</h2>"
-         "<p>Copyright &copy; 2007-%3 Free Software Foundation Europe e.V."
+      tr("<br><h2>Bacula Bat %1 (%2)</h2>"
+         "<p>Copyright &copy; 2007-%3 Kern Sibbald"
          "<p>The <b>bat</b> is an administrative console"
          " interface to the Director.").arg(VERSION).arg(BDATE).arg(BYEAR));
 }
@@ -566,9 +642,8 @@ void MainWin::set_statusf(const char *fmt, ...)
 {
    va_list arg_ptr;
    char buf[1000];
-   int len;
    va_start(arg_ptr, fmt);
-   len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
+   bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
    va_end(arg_ptr);
    set_status(buf);
 }
@@ -593,8 +668,10 @@ void MainWin::set_status(const char *buf)
  */
 void MainWin::undockWindowButton()
 {
-   Pages* page = (Pages*)stackedWidget->currentWidget();
-   page->togglePageDocking();
+   Pages* page = (Pages*)tabWidget->currentWidget();
+   if (page) {
+      page->togglePageDocking();
+   }
 }
 
 /*
@@ -609,7 +686,9 @@ void MainWin::toggleDockContextWindow()
    /* Is this a page that has been inserted into the hash  */
    if (getFromHash(currentitem)) {
       Pages* page = getFromHash(currentitem);
-      page->togglePageDocking();
+      if (page) {
+         page->togglePageDocking();
+      }
    }
 }
 
@@ -621,9 +700,18 @@ void MainWin::toggleDockContextWindow()
 void MainWin::stackItemChanged(int)
 {
    if (m_isClosing) return; /* if closing the application, do nothing here */
-   Pages* page = (Pages*)stackedWidget->currentWidget();
+   Pages* page = (Pages*)tabWidget->currentWidget();
    /* run the virtual function in case this class overrides it */
-   page->currentStackItem();
+   if (page) {
+      page->currentStackItem();
+   }
+   if (!m_waitState) {
+      disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+      disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+      treeWidget->setCurrentItem(getFromHash(page));
+      connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+      connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+   }
 }
 
 /*
@@ -668,19 +756,35 @@ QTreeWidgetItem* MainWin::getFromHash(Pages *page)
    return m_widgethash.value(page);
 }
 
+void MainWin::closeCurrentPage()
+{
+   closePage(-1);
+}
+
 /*
  * Function to respond to action on page selector context menu to close the
  * current window.
  */
-void MainWin::closePage()
+void MainWin::closePage(int item)
 {
-   QTreeWidgetItem *currentitem = treeWidget->currentItem();
+   QTreeWidgetItem *currentitem;
+   Pages *page = NULL;
+
+   if (item >= 0) {
+     page = (Pages *)tabWidget->widget(item);
+   } else {
+      currentitem = treeWidget->currentItem();
+      /* Is this a page that has been inserted into the hash  */
+      if (getFromHash(currentitem)) {
+         page = getFromHash(currentitem);
+      }
+   }   
    
-   /* Is this a page that has been inserted into the hash  */
-   if (getFromHash(currentitem)) {
-      Pages* page = getFromHash(currentitem);
+   if (page) {
       if (page->isCloseable()) {
          page->closeStackPage();
+      } else {
+         page->hidePage();
       }
    }
 }
@@ -690,6 +794,7 @@ Console *MainWin::currentConsole()
 {
    return m_currentConsole;
 }
+
 /* Quick function to return the tree item for the director */
 QTreeWidgetItem *MainWin::currentTopItem()
 {
@@ -712,8 +817,6 @@ void MainWin::setPreferences()
    prefs.daysSpinBox->setValue(m_daysLimitVal);
    prefs.checkMessages->setCheckState(m_checkMessages ? Qt::Checked : Qt::Unchecked);
    prefs.checkMessagesSpin->setValue(m_checkMessagesInterval);
-   prefs.refreshStatusDir->setCheckState(m_refreshStatusDir ? Qt::Checked : Qt::Unchecked);
-   prefs.refreshStatusDirSpin->setValue(m_refreshStatusDirInterval);
    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);
@@ -748,7 +851,7 @@ void MainWin::setPreferences()
 }
 
 /* Preferences dialog */
-prefsDialog::prefsDialog()
+prefsDialog::prefsDialog() : QDialog()
 {
    setupUi(this);
 }
@@ -768,8 +871,6 @@ void prefsDialog::accept()
    mainWin->m_daysLimitVal = this->daysSpinBox->value();
    mainWin->m_checkMessages = this->checkMessages->checkState() == Qt::Checked;
    mainWin->m_checkMessagesInterval = this->checkMessagesSpin->value();
-   mainWin->m_refreshStatusDir = this->refreshStatusDir->checkState() == Qt::Checked;
-   mainWin->m_refreshStatusDirInterval = this->refreshStatusDirSpin->value();
    mainWin->m_longList = this->executeLongCheckBox->checkState() == Qt::Checked;
 
    mainWin->m_rtPopDirDebug = this->rtPopDirCheckBox->checkState() == Qt::Checked;
@@ -813,8 +914,6 @@ void prefsDialog::accept()
    settings.beginGroup("Timers");
    settings.setValue("checkMessages", mainWin->m_checkMessages);
    settings.setValue("checkMessagesInterval", mainWin->m_checkMessagesInterval);
-   settings.setValue("refreshStatusDir", mainWin->m_refreshStatusDir);
-   settings.setValue("refreshStatusDirInterval", mainWin->m_refreshStatusDirInterval);
    settings.endGroup();
    settings.beginGroup("Misc");
    settings.setValue("longList", mainWin->m_longList);
@@ -859,15 +958,13 @@ void MainWin::readPreferences()
    settings.endGroup();
    settings.beginGroup("JobList");
    m_recordLimitCheck = settings.value("recordLimitCheck", true).toBool();
-   m_recordLimitVal = settings.value("recordLimitVal", 150).toInt();
+   m_recordLimitVal = settings.value("recordLimitVal", 50).toInt();
    m_daysLimitCheck = settings.value("daysLimitCheck", false).toBool();
    m_daysLimitVal = settings.value("daysLimitVal", 28).toInt();
    settings.endGroup();
    settings.beginGroup("Timers");
    m_checkMessages = settings.value("checkMessages", false).toBool();
    m_checkMessagesInterval = settings.value("checkMessagesInterval", 28).toInt();
-   m_refreshStatusDir = settings.value("refreshStatusDir", false).toBool();
-   m_refreshStatusDirInterval = settings.value("refreshStatusDirInterval", 28).toInt();
    settings.endGroup();
    settings.beginGroup("Misc");
    m_longList = settings.value("longList", false).toBool();
@@ -901,3 +998,30 @@ void MainWin::setMessageIcon()
    else
       actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-new.png")));
 }
+
+void MainWin::goToPreviousPage()
+{
+   m_treeStackTrap = true;
+   bool done = false;
+   while (!done) {
+      /* If stack list is emtpty, then done */
+      if (m_treeWidgetStack.isEmpty()) {
+         done = true;
+      } else {
+         QTreeWidgetItem* testItem = m_treeWidgetStack.takeLast();
+         QTreeWidgetItemIterator it(treeWidget);
+         /* lets avoid a segfault by setting an item current that no longer exists */
+         while (*it) {
+            if (*it == testItem) {
+               if (testItem != treeWidget->currentItem()) {
+                  treeWidget->setCurrentItem(testItem);
+                  done = true;
+               }
+               break;
+            }
+            ++it;
+         }
+      }
+   }
+   m_treeStackTrap = false;
+}