From: vsr Date: Thu, 2 Mar 2006 13:25:51 +0000 (+0000) Subject: * process menu highlighting X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bbebdf382f4a04b980bcf370cc776da6e657a8e8;p=modules%2Fgui.git * process menu highlighting * add method to check action presence --- diff --git a/src/Qtx/QtxActionMenuMgr.cxx b/src/Qtx/QtxActionMenuMgr.cxx index e570f7365..2d09b2d09 100644 --- a/src/Qtx/QtxActionMenuMgr.cxx +++ b/src/Qtx/QtxActionMenuMgr.cxx @@ -321,7 +321,7 @@ void QtxActionMenuMgr::remove( const int id ) void QtxActionMenuMgr::remove( const int id, const int pId, const int group ) { - MenuNode* pNode = find( pId ); + MenuNode* pNode = pId == -1 ? &myRoot : find( pId ); if ( !pNode ) return; @@ -396,8 +396,13 @@ void QtxActionMenuMgr::onHighlighted( int id ) } if ( pid ) { realId = findId( id, pid ); - if ( realId != -1 ) + if ( realId != -1 ) { + bool updatesEnabled = isUpdatesEnabled(); + setUpdatesEnabled( false ); emit menuHighlighted( pid, realId ); + setUpdatesEnabled( updatesEnabled ); + updateMenu( find( realId ) ); + } } } @@ -415,12 +420,12 @@ void QtxActionMenuMgr::setWidget( QWidget* mw ) connect( myMenu, SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) ); } -QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int actId, const int pId ) const +QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int actId, const int pId, const bool rec ) const { - return find( actId, find( pId ) ); + return find( actId, find( pId ), rec ); } -QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int id, MenuNode* startNode ) const +QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int id, MenuNode* startNode, const bool rec ) const { MenuNode* node = 0; MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot; @@ -428,8 +433,8 @@ QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int id, MenuNode* star { if ( it.current()->id == id ) node = it.current(); - else - node = find( id, it.current() ); + else if ( rec ) + node = find( id, it.current(), rec ); } return node; } @@ -447,12 +452,12 @@ bool QtxActionMenuMgr::find( const int id, NodeList& lst, MenuNode* startNode ) return !lst.isEmpty(); } -QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, const int id, const int pId ) const +QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, const int pId, const bool rec ) const { - return find( title, id, find( pId ) ); + return find( title, find( pId ), rec ); } -bool QtxActionMenuMgr::find( const QString& title, const int id, NodeList& lst, MenuNode* startNode ) const +bool QtxActionMenuMgr::find( const QString& title, NodeList& lst, MenuNode* startNode ) const { MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot; for ( NodeListIterator it( start->children ); it.current(); ++it ) @@ -460,16 +465,15 @@ bool QtxActionMenuMgr::find( const QString& title, const int id, NodeList& lst, QAction* a = itemAction( it.current()->id ); if ( !a ) a = menuAction( it.current()->id ); - if ( a && clearTitle( a->text() ) == clearTitle( title ) && - ( it.current()->id == id || id == -1 ) ) + if ( a && clearTitle( a->menuText() ) == clearTitle( title ) ) lst.prepend( it.current() ); - find( title, id, lst, it.current() ); + find( title, lst, it.current() ); } return !lst.isEmpty(); } -QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, const int id, MenuNode* startNode ) const +QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, MenuNode* startNode, const bool rec ) const { MenuNode* node = 0; MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot; @@ -478,11 +482,10 @@ QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, const QAction* a = itemAction( it.current()->id ); if ( !a ) a = menuAction( it.current()->id ); - if ( a && clearTitle( a->text() ) == clearTitle( title ) && - ( it.current()->id == id || id == -1 ) ) + if ( a && clearTitle( a->menuText() ) == clearTitle( title ) ) node = it.current(); - if ( !node ) - node = find( title, id, it.current() ); + if ( !node && rec ) + node = find( title, it.current(), rec ); } return node; } @@ -680,14 +683,14 @@ bool QtxActionMenuMgr::load( const QString& fname, QtxActionMgr::Reader& r ) return r.read( fname, cr ); } -bool QtxActionMenuMgr::contains( const QString& title, const int id, const int pid ) const +bool QtxActionMenuMgr::containsMenu( const QString& title, const int pid ) const { - return (bool)find( title, id, pid ); + return (bool)find( title, pid, false ); } -bool QtxActionMenuMgr::contains( const int id, const int pid ) const +bool QtxActionMenuMgr::containsMenu( const int id, const int pid ) const { - return (bool)find( id, pid ); + return (bool)find( id, pid, false ); } /*! diff --git a/src/Qtx/QtxActionMenuMgr.h b/src/Qtx/QtxActionMenuMgr.h index bb10da10f..f06ff9d3b 100644 --- a/src/Qtx/QtxActionMenuMgr.h +++ b/src/Qtx/QtxActionMenuMgr.h @@ -103,8 +103,8 @@ public: virtual bool load( const QString&, QtxActionMgr::Reader& ); - bool contains( const QString&, const int, const int ) const; - bool contains( const int, const int ) const; + bool containsMenu( const QString&, const int ) const; + bool containsMenu( const int, const int ) const; private slots: @@ -116,12 +116,12 @@ signals: protected: void setWidget( QWidget* ); - MenuNode* find( const int, const int ) const; - MenuNode* find( const int, MenuNode* = 0 ) const; + MenuNode* find( const int, const int, const bool = true ) const; + MenuNode* find( const int, MenuNode* = 0, const bool = true ) const; bool find( const int, NodeList&, MenuNode* = 0 ) const; - MenuNode* find( const QString&, const int, const int ) const; - MenuNode* find( const QString&, const int, MenuNode* = 0 ) const; - bool find( const QString&, const int, NodeList&, MenuNode* = 0 ) const; + MenuNode* find( const QString&, const int, const bool = true ) const; + MenuNode* find( const QString&, MenuNode* = 0, const bool = true ) const; + bool find( const QString&, NodeList&, MenuNode* = 0 ) const; int findId( const int, const int = -1 ) const; void removeMenu( const int, MenuNode* ); diff --git a/src/Qtx/QtxActionToolMgr.cxx b/src/Qtx/QtxActionToolMgr.cxx index 33fff1607..b9ff56c8f 100644 --- a/src/Qtx/QtxActionToolMgr.cxx +++ b/src/Qtx/QtxActionToolMgr.cxx @@ -227,7 +227,7 @@ bool QtxActionToolMgr::hasToolBar( const QString& tname ) const return find( tname ) != -1; } -bool QtxActionToolMgr::contains( const int id, const int tid ) const +bool QtxActionToolMgr::containsAction( const int id, const int tid ) const { for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end(); ++it ) { diff --git a/src/Qtx/QtxActionToolMgr.h b/src/Qtx/QtxActionToolMgr.h index e9d6e4e40..48a722785 100644 --- a/src/Qtx/QtxActionToolMgr.h +++ b/src/Qtx/QtxActionToolMgr.h @@ -95,7 +95,7 @@ public: bool hasToolBar( const int ) const; bool hasToolBar( const QString& ) const; - bool contains( const int, const int = -1 ) const; + bool containsAction( const int, const int = -1 ) const; virtual bool load( const QString&, QtxActionMgr::Reader& );