From cbc99d9127c65838e89e615c8695fc0709af864e Mon Sep 17 00:00:00 2001 From: stv Date: Wed, 24 Oct 2007 06:56:19 +0000 Subject: [PATCH] no message --- src/Qtx/QtxDockAction.cxx | 36 ++++++++++++++++++++++++++---------- src/Qtx/QtxDockAction.h | 8 +++++--- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/Qtx/QtxDockAction.cxx b/src/Qtx/QtxDockAction.cxx index 1b25e280a..e94cf90db 100755 --- a/src/Qtx/QtxDockAction.cxx +++ b/src/Qtx/QtxDockAction.cxx @@ -535,7 +535,7 @@ void QtxDockAction::onVisibilityChanged( bool on ) a->blockSignals( block ); } - savePlaceInfo( dw ); + QApplication::postEvent( this, new QCustomEvent( (QEvent::Type)SaveGeom, dw ) ); } /*! @@ -549,25 +549,27 @@ void QtxDockAction::onDockWindowPositionChanged( QDockWindow* dw ) } /*! - Name: event [protected] + Name: customEvent [protected] Desc: Check consistency the popup content and internal datas. Synchronize internal data structures with popup content. */ -bool QtxDockAction::event( QEvent* e ) +void QtxDockAction::customEvent( QCustomEvent* e ) { - if ( e->type() == (int)AutoAdd ) + QDockWindow* dw = (QDockWindow*)e->data(); + switch ( e->type() ) { - QCustomEvent* ce = (QCustomEvent*)e; - QDockWindow* dw = (QDockWindow*)ce->data(); + case AutoAdd: if ( !myInfo.contains( dw ) ) { autoAddDockWindow( dw ); autoLoadPlaceInfo( dw ); } + break; + case SaveGeom: + savePlaceInfo( dw ); + break; } - - return QtxAction::event( e ); } /*! @@ -780,6 +782,10 @@ void QtxDockAction::updateInfo( QDockWindow* dw ) void QtxDockAction::savePlaceInfo( QDockWindow* dw ) { + QMainWindow* mw = mainWindow(); + if ( !mw ) + return; + if ( !myInfo.contains( dw ) ) return; @@ -789,8 +795,8 @@ void QtxDockAction::savePlaceInfo( QDockWindow* dw ) GeomInfo& inf = myGeom[myInfo[dw].name]; Dock dock; - inf.vis = dw->isVisibleTo( mainWindow() ); - mainWindow()->getLocation( dw, dock, inf.index, inf.newLine, inf.offset ); + inf.vis = dw->isVisibleTo( mw ); + mw->getLocation( dw, dock, inf.index, inf.newLine, inf.offset ); inf.place = dock; inf.x = dw->x(); @@ -928,8 +934,18 @@ void QtxDockAction::loadPlaceArea( const int place, QMainWindow* mw, QDockArea* if ( !area ) return; + bool aa = myAutoAdd; + bool ap = myAutoPlace; + + QtxDockAction* that = (QtxDockAction*)this; + + that->myAutoPlace = false; + qApp->processEvents(); + that->myAutoAdd = aa; + that->myAutoPlace = ap; + for ( QPtrListIterator itr( dockList ); itr.current(); ++itr ) { QDockWindow* dw = itr.current(); diff --git a/src/Qtx/QtxDockAction.h b/src/Qtx/QtxDockAction.h index a18d102fb..79e0c5799 100755 --- a/src/Qtx/QtxDockAction.h +++ b/src/Qtx/QtxDockAction.h @@ -27,6 +27,7 @@ #include #include #include +#include class QAction; class QDockArea; @@ -88,7 +89,7 @@ private slots: void onDockWindowPositionChanged( QDockWindow* ); protected: - virtual bool event( QEvent* ); + virtual void customEvent( QCustomEvent* ); private: QAction* action( QDockWindow* ) const; @@ -124,7 +125,8 @@ private: bool dockMainWindow( QMainWindow*, QObject* ) const; private: - enum { AutoAdd = QEvent::User, LoadArea }; + enum { AutoAdd = QEvent::User, SaveGeom }; + typedef QGuardedPtr MainWindow; typedef struct { bool vis, newLine; int place, index, offset; @@ -149,7 +151,7 @@ private: InfoMap myInfo; MenuMap myMenu; GeomMap myGeom; - QMainWindow* myMain; + MainWindow myMain; QStringList myNames; bool myAutoAdd; -- 2.39.2