From 8012eff21de6f19d7252ca5037baaf634d0e1266 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Wed, 28 Mar 2007 02:42:58 +0000 Subject: [PATCH] dhb Added lots of comments to batstack.cpp and .h Re-added virtual functions. Removing them broke the ability for medialist, and any future class that populates on click to populate. Could find another way if needed. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4443 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/batstack.cpp | 46 ++++++++++++++++++++++++++++++ bacula/src/qt-console/batstack.h | 16 +++++++++++ bacula/src/qt-console/mainwin.cpp | 4 +++ 3 files changed, 66 insertions(+) diff --git a/bacula/src/qt-console/batstack.cpp b/bacula/src/qt-console/batstack.cpp index dfd9067d96..437796d3d0 100644 --- a/bacula/src/qt-console/batstack.cpp +++ b/bacula/src/qt-console/batstack.cpp @@ -33,6 +33,12 @@ #include "batstack.h" +/* + * AddTostack + * This function is intended to be called from within the batstack class to pull + * a window from floating to in the stack widget. + */ + void BatStack::AddTostack() { /* These two lines are for making sure if it is being changed from a window @@ -48,6 +54,12 @@ void BatStack::AddTostack() m_stacked=true; } +/* + * AddTostack + * This function is intended to be called from within the batstack class to put + * a window from the stack widget to a floating window. + */ + void BatStack::RemoveFromstack() { /* Change from a stacked widget to a normal window */ @@ -58,6 +70,13 @@ void BatStack::RemoveFromstack() m_stacked=false; } +/* + * This function is intended to be called with the subclasses. When it is called + * the specific sublclass does not have to be known to BatStack. It is called + * it will take it from it's current state of floating or stacked and change it + * to the other. + */ + void BatStack::Togglestack() { if( m_stacked ){ @@ -67,12 +86,24 @@ void BatStack::Togglestack() } } +/* + * This function is because I wanted for some reason to keep it private but still + * give any subclasses the ability to find out if it is currently stacked or not. + */ bool BatStack::isStacked() { return m_stacked; } +/* + * When a window is closed, this slot is called. The idea is to put it back in the + * stack here, and it works. I wanted to get it to the top of the stack so that the + * user immediately sees where his window went. Also, if he floats the window, then + * closes it with the tree item highlighted, it may be confusing that the highlighted + * treewidgetitem is not the stack item in the front. + */ + void BatStack::closeEvent(QCloseEvent* /*event*/) { /* A Widget was closed, lets toggle it back into the window, and set it in front. */ @@ -90,7 +121,22 @@ void BatStack::closeEvent(QCloseEvent* /*event*/) #endif } +/* + * The next two are virtual functions. The idea here is that each subclass will have the + * built in virtual function to override if the programmer wants to populate the window + * when it it is first clicked. + */ +void BatStack::PgSeltreeWidgetClicked(){ +} +void BatStack::PgSeltreeWidgetDoubleClicked(){ +} +/* + * This function exists because I wanted to have an easy way for new programmers to understand + * exactly what values needed to be set in order to behave correctly in the interface. It can + * be called from the constructor, like with medialist or after being constructed, like with + * Console. + */ void BatStack::SetPassedValues(QStackedWidget* passedStackedWidget, QTreeWidgetItem* passedTreeItem, int indexseq ) { m_parent = passedStackedWidget; diff --git a/bacula/src/qt-console/batstack.h b/bacula/src/qt-console/batstack.h index d2e1417ed5..0885b057b6 100644 --- a/bacula/src/qt-console/batstack.h +++ b/bacula/src/qt-console/batstack.h @@ -36,6 +36,20 @@ #include #include +/* + * The BatStack Class + * + * This class is inherited by all widget windows which are on the stack + * It is for the purpos of having a conistant set of functions and properties + * in all of the subclasses to accomplish tasks such as pulling a window out + * of or into the stack. It also provides virtual functions placed called + * from in mainwin so that subclasses can contain functions to allow them + * to populate thier screens at the time of first viewing, (when clicked) as + * opposed to the first creation of the console connection. After all the + * console is not actually connected until after the page selector tree has been + * populated. + */ + class BatStack : public QWidget { public: @@ -46,6 +60,8 @@ public: QStackedWidget *m_parent; QTreeWidgetItem *m_treeItem; void SetPassedValues(QStackedWidget*, QTreeWidgetItem*, int ); + virtual void PgSeltreeWidgetClicked(); + virtual void PgSeltreeWidgetDoubleClicked(); public slots: /* closeEvent is a virtual function inherited from QWidget */ diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 044ff90f21..46551b987e 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -243,6 +243,8 @@ void MainWin::treeItemClicked(QTreeWidgetItem *item, int column) if( stackindex >= 0 ){ stackedWidget->setCurrentIndex(stackindex); } + /* run the virtual function in case this class overrides it */ + m_bstacklist[treeindex]->PgSeltreeWidgetClicked(); } /* @@ -266,6 +268,8 @@ void MainWin::treeItemDoubleClicked(QTreeWidgetItem *item, int column) /* Just pull it back in without prompting */ m_bstacklist[treeindex]->Togglestack(); } + /* Here is the virtual function so that different classes can do different things */ + m_bstacklist[treeindex]->PgSeltreeWidgetDoubleClicked(); } void MainWin::labelDialogClicked() -- 2.39.5