]> git.sur5r.net Git - bacula/bacula/commitdiff
Add a previous page button to the button bar.
authorDirk H Bartley <dbartley@schupan.com>
Sat, 13 Jun 2009 23:33:00 +0000 (23:33 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Sat, 13 Jun 2009 23:33:00 +0000 (23:33 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8898 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/main.qrc
bacula/src/qt-console/main.ui
bacula/src/qt-console/mainwin.cpp
bacula/src/qt-console/mainwin.h

index 16266bb2710ed5972985cc2db644f59aef4f0eb1..18e2c7b534ee7c2d9fe342327bd088a270c34a3a 100644 (file)
@@ -47,5 +47,6 @@
         <file>images/utilities-terminal.png</file>
         <file>images/view-refresh.png</file>
         <file>images/weather-severe-alert.png</file>
+        <file>images/go-jump.png</file>
     </qresource>
 </RCC>
index 0cd9ae5787b3025000aa6243f157aa2a7274a68b..9f8315045e5a1e19e15b97c4826f2ca6847f4da1 100644 (file)
@@ -81,7 +81,7 @@
      <x>0</x>
      <y>0</y>
      <width>882</width>
-     <height>24</height>
+     <height>22</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuEdit" >
    <addaction name="actionBrowse" />
    <addaction name="actionJobPlot" />
    <addaction name="actionUndock" />
+   <addaction name="actionBack" />
   </widget>
   <widget class="QDockWidget" name="dockWidget" >
    <property name="sizePolicy" >
     <string>Reload and Repop</string>
    </property>
   </action>
+  <action name="actionBack" >
+   <property name="icon" >
+    <iconset resource="main.qrc" >:/images/go-jump.png</iconset>
+   </property>
+   <property name="text" >
+    <string>back</string>
+   </property>
+   <property name="toolTip" >
+    <string>Previous Page</string>
+   </property>
+   <property name="statusTip" >
+    <string>Previous Page</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="main.qrc" />
index 1d5975d7327fbb7695ba502094983d4211e47096..083964da8e861c4a009c37d38c9c2107007bd792 100644 (file)
@@ -70,6 +70,7 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
    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) */
@@ -248,7 +249,7 @@ 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(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
    connect(stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
    connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
    connect(actionLabel, SIGNAL(triggered()), this,  SLOT(labelButtonClicked()));
@@ -266,6 +267,7 @@ void MainWin::connectSignals()
    connect(actionPreferences, SIGNAL(triggered()), this,  SLOT(setPreferences()));
    connect(actionRepopLists, SIGNAL(triggered()), this,  SLOT(repopLists()));
    connect(actionReloadRepop, SIGNAL(triggered()), this,  SLOT(reloadRepopLists()));
+   connect(actionBack, SIGNAL(triggered()), this,  SLOT(goToPreviousPage()));
 }
 
 void MainWin::disconnectSignals()
@@ -293,6 +295,7 @@ void MainWin::disconnectSignals()
    disconnect(actionPreferences, SIGNAL(triggered()), this,  SLOT(setPreferences()));
    disconnect(actionRepopLists, SIGNAL(triggered()), this,  SLOT(repopLists()));
    disconnect(actionReloadRepop, SIGNAL(triggered()), this,  SLOT(reloadRepopLists()));
+   disconnect(actionBack, SIGNAL(triggered()), this,  SLOT(goToPreviousPage()));
 }
 
 /*
@@ -477,6 +480,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);
@@ -950,3 +956,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;
+}
index 1d3fab3934a6b2971d762ea9cb8d450532975926..baeb32c4b114d6b433b55fcb824c3e2640c3c231 100644 (file)
@@ -128,6 +128,7 @@ public slots:
    void repopLists();
    void reloadRepopLists();
    void popLists();
+   void goToPreviousPage();
 
 protected:
    void closeEvent(QCloseEvent *event);
@@ -151,6 +152,8 @@ private:
    bool m_isClosing;
    bool m_waitState;
    bool m_doConnect;
+   QList<QTreeWidgetItem *> m_treeWidgetStack;
+   bool m_treeStackTrap;
 };
 
 #include "ui_prefs.h"