From: stv Date: Wed, 19 Oct 2005 11:54:50 +0000 (+0000) Subject: Update of the currently added menu items during action menu text or property "isSepar... X-Git-Tag: ForTest2_3_1_0a2~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5bdc93b7902509c5ed1010c7dedf106cf499cba6;p=modules%2Fgui.git Update of the currently added menu items during action menu text or property "isSeparated" changing. --- diff --git a/src/Qtx/QtxDockAction.cxx b/src/Qtx/QtxDockAction.cxx index 2c88abb4f..f126120ed 100755 --- a/src/Qtx/QtxDockAction.cxx +++ b/src/Qtx/QtxDockAction.cxx @@ -150,7 +150,11 @@ bool QtxDockAction::isSeparate() const void QtxDockAction::setSeparate( const bool on ) { + if ( mySeparate == on ) + return; + mySeparate = on; + updateMenus(); } /*! @@ -232,6 +236,15 @@ bool QtxDockAction::removeFrom( QWidget* wid ) return QtxAction::removeFrom( wid ); } +void QtxDockAction::setMenuText( const QString& txt ) +{ + if ( menuText() == txt ) + return; + + QtxAction::setMenuText( txt ); + updateMenus(); +} + /*! Name: addDockWindow [public] Desc: Add dock window to internal data structures. Action will be include all added @@ -1167,3 +1180,43 @@ void QtxDockAction::collectNames( const int place, QStringList& lst ) const lst.append( name ); } } + +void QtxDockAction::updateMenus() +{ + for ( MenuMap::Iterator it = myMenu.begin(); it != myMenu.end(); ++it ) + { + QPopupMenu* pm = it.key(); + MenuInfo& inf = it.data(); + + int toolId = findId( pm, inf.tool ); + int dockId = findId( pm, inf.dock ); + + int index = pm->indexOf( dockId ); + + if ( isSeparate() && !inf.tool ) + inf.tool = new QPopupMenu( pm ); + + pm->removeItem( dockId ); + pm->removeItem( toolId ); + + if ( !isSeparate() && inf.tool ) + { + delete inf.tool; + inf.tool = 0; + } + + QString dock, tool; + splitMenuText( dock, tool ); + + if ( inf.dock ) + iconSet().isNull() ? pm->insertItem ( dock, inf.dock, -1, index ) : + pm->insertItem ( iconSet(), dock, inf.dock, -1, index ); + + if ( index >= 0 ) + index++; + + if ( inf.tool ) + iconSet().isNull() ? pm->insertItem ( tool, inf.tool, -1, index ) : + pm->insertItem ( iconSet(), tool, inf.tool, -1, index ); + } +} diff --git a/src/Qtx/QtxDockAction.h b/src/Qtx/QtxDockAction.h index 8e443be9a..154e4db2a 100755 --- a/src/Qtx/QtxDockAction.h +++ b/src/Qtx/QtxDockAction.h @@ -48,6 +48,7 @@ public: virtual bool addTo( QWidget* ); virtual bool addTo( QWidget*, const int ); virtual bool removeFrom( QWidget* ); + virtual void setMenuText( const QString& ); bool addDockWindow( QDockWindow* ); bool removeDockWindow( QDockWindow* ); @@ -100,6 +101,8 @@ private: void collectNames( const int, QStringList& ) const; + void updateMenus(); + private: enum { AutoAdd = QEvent::User, LoadArea };