From 7ebc48bb63225a4a48a52185e37eac1ee473ff59 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Thu, 12 Apr 2007 02:02:30 +0000 Subject: [PATCH] dhb Succeeded at fixing the FIXME that gave me heartache. When an undocked window is closed, it will be visible on the top of the stack and the page selector item that represents it will become active. If a page selector item becomes active and the window is not docked, it will be raised to the front. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4536 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/mainwin.cpp | 16 ++++---- bacula/src/qt-console/pages.cpp | 67 ++++++++++++++----------------- 2 files changed, 39 insertions(+), 44 deletions(-) diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 7f5260bad4..0a509c44c6 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -116,7 +116,7 @@ void MainWin::createPages() page->dockPage(); treeWidget->expandItem(topItem); - stackedWidget->setCurrentIndex(0); + stackedWidget->setCurrentWidget(m_console); } /* Create a root Tree Widget */ @@ -245,13 +245,12 @@ void MainWin::readSettings() */ void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/) { - /* Is this one of the first level pages */ + /* Is this a page that has been inserted into the hash */ if( getFromHash(item) ){ Pages* page = getFromHash(item); int stackindex=stackedWidget->indexOf(page); if( stackindex >= 0 ){ - stackedWidget->setCurrentIndex(0); stackedWidget->setCurrentWidget(page); } /* run the virtual function in case this class overrides it */ @@ -275,7 +274,7 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre /* The Previous item */ if ( previousitem ){ - /* Is this one of the first level pages */ + /* Is this a page that has been inserted into the hash */ if( getFromHash(previousitem) ){ Pages* page = getFromHash(previousitem); treeWidget->removeAction(actionToggleDock); @@ -285,7 +284,7 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre } } - /* Is this one of the first level pages */ + /* Is this a page that has been inserted into the hash */ if( getFromHash(currentitem) ){ Pages* page = getFromHash(currentitem); int stackindex = stackedWidget->indexOf(page); @@ -294,6 +293,9 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre if( stackindex >= 0 ){ /* put this page on the top of the stack */ stackedWidget->setCurrentIndex(stackindex); + } else { + /* it is undocked, raise it to the front */ + page->raise(); } setContextMenuDockText(page, currentitem); @@ -390,7 +392,7 @@ void MainWin::toggleDockContextWindow() { QTreeWidgetItem *currentitem = treeWidget->currentItem(); - /* Is this one of the first level pages */ + /* Is this a page that has been inserted into the hash */ if( getFromHash(currentitem) ){ Pages* page = getFromHash(currentitem); page->togglePageDocking(); @@ -413,7 +415,7 @@ void MainWin::setContextMenuDockText() { QTreeWidgetItem *currentitem = treeWidget->currentItem(); - /* Is this one of the first level pages */ + /* Is this a page that has been inserted into the hash */ if( getFromHash(currentitem) ){ Pages* page = getFromHash(currentitem); setContextMenuDockText(page, currentitem); diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 7516473214..76eab6a205 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -46,7 +46,7 @@ void Pages::dockPage() * that it has the proper window flag and parent. */ setWindowFlags(Qt::Widget); - setParent(m_parent); +// setParent(m_parent); /* This was being done already */ m_parent->addWidget(this); @@ -72,10 +72,10 @@ void Pages::undockPage() } /* - * This function is intended to be called with the subclasses. When it is called - * the specific sublclass does not have to be known to Pages. It is called - * it will take it from it's current state of floating or stacked and change it - * to the other. + * This function is intended to be called with the subclasses. When it is + * called the specific sublclass does not have to be known to Pages. When it + * is called this function will change the page from it's current state of being + * docked or undocked and change it to the other. */ void Pages::togglePageDocking() @@ -105,40 +105,31 @@ bool Pages::isDocked() * treewidgetitem is not the stack item in the front. */ -void Pages::closeEvent(QCloseEvent* /*event*/) +void Pages::closeEvent(QCloseEvent* event) { /* A Widget was closed, lets toggle it back into the window, and set it in front. */ dockPage(); - /* in case the current widget is the one which represents this, lets set the context - * menu to undock */ - mainWin->setContextMenuDockText(); - /* in case the current widget is not the one which represents this, lets set the - * color back to black */ - mainWin->setTreeWidgetItemDockColor(this); - -#ifdef xxx - /* FIXME Really having problems getting it to the front, - toggles back into the stack fine though */ - int stackindex=m_parent->indexOf( this ); -printf("In Pages closeEvent a\n"); - if( stackindex >= 0 ){ -printf("In Pages closeEvent b\n"); - m_parent->setCurrentIndex(0); - m_parent->setCurrentWidget(this); - show(); - //m_parent->setCurrentIndex(stackindex); -// m_parent->setCurrentWidget(this); -/* m_parent->update(); - update(); - setUpdatesEnabled(true); - setVisible(true); - m_parent->show(); - show(); - m_parent->repaint();*/ - repaint(); - raise(); - } -#endif + + /* is the tree widget item for "this" the current widget item */ + if( mainWin->treeWidget->currentItem() == mainWin->getFromHash(this) ) + /* in case the current widget is the one which represents this, lets set the context + * menu to undock */ + mainWin->setContextMenuDockText(); + else + /* in case the current widget is not the one which represents this, lets set the + * color back to black */ + mainWin->setTreeWidgetItemDockColor(this); + + /* this fixes my woes of getting the widget to show up on top when closed */ + event->ignore(); + + /* put this widget on the top of the stack widget */ + m_parent->setCurrentWidget(this); + + /* Set the current tree widget item in the Page Selector window to the item + * which represents "this" */ + QTreeWidgetItem *item= mainWin->getFromHash(this); + mainWin->treeWidget->setCurrentItem(item); } /* @@ -155,7 +146,9 @@ void Pages::PgSeltreeWidgetDoubleClicked() } /* - * * Virtual function which is called when this page is visible on the stack + * Virtual function which is called when this page is visible on the stack. + * This will be overridden by classes that want to populate if they are on the + * top. */ void Pages::currentStackItem() { -- 2.39.5