From: Dirk H Bartley Date: Sat, 13 Jun 2009 23:33:00 +0000 (+0000) Subject: Add a previous page button to the button bar. X-Git-Tag: Release-3.0.2~168 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f2721da421d0a6022f8adc8a0e4ce1d8586f2522;p=bacula%2Fbacula Add a previous page button to the button bar. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8898 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/main.qrc b/bacula/src/qt-console/main.qrc index 16266bb271..18e2c7b534 100644 --- a/bacula/src/qt-console/main.qrc +++ b/bacula/src/qt-console/main.qrc @@ -47,5 +47,6 @@ images/utilities-terminal.png images/view-refresh.png images/weather-severe-alert.png + images/go-jump.png diff --git a/bacula/src/qt-console/main.ui b/bacula/src/qt-console/main.ui index 0cd9ae5787..9f8315045e 100644 --- a/bacula/src/qt-console/main.ui +++ b/bacula/src/qt-console/main.ui @@ -81,7 +81,7 @@ 0 0 882 - 24 + 22 @@ -159,6 +159,7 @@ + @@ -652,6 +653,20 @@ Reload and Repop + + + :/images/go-jump.png + + + back + + + Previous Page + + + Previous Page + + diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 1d5975d732..083964da8e 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -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; +} diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 1d3fab3934..baeb32c4b1 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -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 m_treeWidgetStack; + bool m_treeStackTrap; }; #include "ui_prefs.h"