From d5caa43183fba79408d549ce356b000b13f5d8f9 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sun, 25 Mar 2007 15:05:08 +0000 Subject: [PATCH] dhb I have the issue of m_medialist and m_brestore resolved. The only one used was the m_medialist to populate after the console connected. So now I created a virtual function for clicked and double clicked in BatStack. All classes that want to do something based on a click in it's widget in the page selector can just use the virtual function. So in medialist, a single click will populate if not populated, and a double will repopulate from a clear. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4414 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/batstack.cpp | 6 ++++++ bacula/src/qt-console/batstack.h | 3 +++ bacula/src/qt-console/mainwin.cpp | 17 ++++++++--------- bacula/src/qt-console/mainwin.h | 4 ++-- bacula/src/qt-console/medialist/medialist.cpp | 16 ++++++++++++++++ bacula/src/qt-console/medialist/medialist.h | 3 +++ 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/bacula/src/qt-console/batstack.cpp b/bacula/src/qt-console/batstack.cpp index 67ef83973f..bbf9ad5a85 100644 --- a/bacula/src/qt-console/batstack.cpp +++ b/bacula/src/qt-console/batstack.cpp @@ -87,3 +87,9 @@ void BatStack::closeEvent(QCloseEvent* event){ }*/ } + +void BatStack::PgSeltreeWidgetClicked(){ +} + +void BatStack::PgSeltreeWidgetDoubleClicked(){ +} diff --git a/bacula/src/qt-console/batstack.h b/bacula/src/qt-console/batstack.h index f724a80ef7..0ae62023d4 100644 --- a/bacula/src/qt-console/batstack.h +++ b/bacula/src/qt-console/batstack.h @@ -46,8 +46,11 @@ public: bool isStacked(); QStackedWidget *m_parent; QTreeWidgetItem *m_treeItem; + virtual void PgSeltreeWidgetClicked(); + virtual void PgSeltreeWidgetDoubleClicked(); public slots: + /* closeEvent is a virtual function inherited from QWidget */ virtual void closeEvent(QCloseEvent* event); private: diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index f76e03b9b2..9722cc69a6 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -59,7 +59,6 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) readSettings(); m_console->connect(); - m_medialist->populateTree(); } void MainWin::createPages() @@ -69,7 +68,7 @@ void MainWin::createPages() /* Create console tree stacked widget item */ m_console = new Console(stackedWidget); - /* Console is special needs director*/ + /* Console is special -> needs director*/ /* Just take the first Director */ LockRes(); dir = (DIRRES *)GetNextRes(R_DIRECTOR, NULL); @@ -92,17 +91,15 @@ void MainWin::createPages() /* All should be * 1. create tree widget item * 2. create object passing pointer to tree widget item (modified constructors to pass QTreeWidget pointers) - * 3. append to stacklist */ + * 3. append to stacklist + * And it can even be done in one line. + * */ /* brestore */ - item = createPage("brestore", topItem); - m_brestore = new bRestore(stackedWidget,item); - m_bstacklist.append(m_brestore); + m_bstacklist.append(new bRestore( stackedWidget, createPage("brestore", topItem) )); /* lastly for now, the medialist */ - item = createPage("Storage Tree", topItem ); - m_medialist = new MediaList(stackedWidget, m_console, item); - m_bstacklist.append(m_medialist); + m_bstacklist.append(new MediaList(stackedWidget, m_console, createPage("Storage Tree", topItem ))); /* Iterate through and add to the stack */ for ( QList::iterator bstackItem = m_bstacklist.begin(); bstackItem != m_bstacklist.end(); ++bstackItem ) { @@ -232,6 +229,7 @@ void MainWin::treeItemClicked(QTreeWidgetItem *item, int column) if( stackindex >= 0 ){ stackedWidget->setCurrentIndex(stackindex); } + (*bstackItem)->PgSeltreeWidgetClicked(); } ++bstackItem; } @@ -256,6 +254,7 @@ void MainWin::treeItemDoubleClicked(QTreeWidgetItem *item, int column) } else { (*bstackItem)->Togglestack(); } + (*bstackItem)->PgSeltreeWidgetDoubleClicked(); } ++bstackItem; } diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 815f610eb4..72f0744312 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -84,8 +84,8 @@ private: private: QString m_UserInput; Console *m_console; - bRestore *m_brestore; - MediaList *m_medialist; +// bRestore *m_brestore; +// MediaList *m_medialist; BatStack *m_bstackpophold; QList m_bstacklist; QStringList m_cmd_history; diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index ad8af3950a..87da469923 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -55,6 +55,7 @@ MediaList::MediaList(QStackedWidget *parent, Console *console, QTreeWidgetItem * m_treeItem = treeItem; createConnections(); m_popupmedia=""; + m_populated=false; } void MediaList::populateTree() @@ -174,3 +175,18 @@ void MediaList::showJobs() JobList* joblist = new JobList(m_console, m_popupmedia); joblist->show(); } + +void MediaList::PgSeltreeWidgetClicked() +{ + printf("PgSeltreeWidgetClicked\n"); + if( ! m_populated ){ + populateTree(); + m_populated=true; + } +} + +void MediaList::PgSeltreeWidgetDoubleClicked() +{ + printf("PgSeltreeWidgetDoubleClicked\n"); + populateTree(); +} diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index bb01cab5bf..5aaa3a571b 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -46,6 +46,8 @@ class MediaList : public BatStack, public Ui::MediaListForm public: MediaList(QStackedWidget *parent,Console *console, QTreeWidgetItem *treeItem); void populateTree(); + virtual void PgSeltreeWidgetClicked(); + virtual void PgSeltreeWidgetDoubleClicked(); public slots: void treeItemClicked(QTreeWidgetItem *item, int column); @@ -61,6 +63,7 @@ private: QTreeWidget *m_treeWidget; QStringList *m_poollist; QString m_popupmedia; + bool m_populated; //QStackedWidget *m_parent; }; -- 2.39.5