From: vsr Date: Mon, 27 Feb 2006 14:50:17 +0000 (+0000) Subject: Dynamic menus in Python: X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b768df29d629777117acfc0537b3ab9e23fee627;p=modules%2Fgui.git Dynamic menus in Python: * add methods to check if action is already used in menu/toolbars --- diff --git a/src/Qtx/QtxActionMenuMgr.cxx b/src/Qtx/QtxActionMenuMgr.cxx index 58604de7b..e570f7365 100644 --- a/src/Qtx/QtxActionMenuMgr.cxx +++ b/src/Qtx/QtxActionMenuMgr.cxx @@ -680,12 +680,12 @@ 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 ) +bool QtxActionMenuMgr::contains( const QString& title, const int id, const int pid ) const { return (bool)find( title, id, pid ); } -bool QtxActionMenuMgr::contains( const int id, const int pid ) +bool QtxActionMenuMgr::contains( const int id, const int pid ) const { return (bool)find( id, pid ); } diff --git a/src/Qtx/QtxActionMenuMgr.h b/src/Qtx/QtxActionMenuMgr.h index 77470d5be..bb10da10f 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 ); - bool contains( const int, const int ); + bool contains( const QString&, const int, const int ) const; + bool contains( const int, const int ) const; private slots: diff --git a/src/Qtx/QtxActionToolMgr.cxx b/src/Qtx/QtxActionToolMgr.cxx index f797306f0..33fff1607 100644 --- a/src/Qtx/QtxActionToolMgr.cxx +++ b/src/Qtx/QtxActionToolMgr.cxx @@ -227,6 +227,20 @@ bool QtxActionToolMgr::hasToolBar( const QString& tname ) const return find( tname ) != -1; } +bool QtxActionToolMgr::contains( const int id, const int tid ) const +{ + for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end(); ++it ) + { + if ( tid == -1 || it.key() == tid ) { + const NodeList& list = it.data().nodes; + for ( NodeList::const_iterator nit = list.begin(); nit != list.end(); ++nit ) + if ( (*nit).id == id ) + return true; + } + } + return false; +} + void QtxActionToolMgr::onToolBarDestroyed() { myToolBars.remove( find( (QToolBar*)sender() ) ); diff --git a/src/Qtx/QtxActionToolMgr.h b/src/Qtx/QtxActionToolMgr.h index 31c02209d..e9d6e4e40 100644 --- a/src/Qtx/QtxActionToolMgr.h +++ b/src/Qtx/QtxActionToolMgr.h @@ -95,6 +95,8 @@ public: bool hasToolBar( const int ) const; bool hasToolBar( const QString& ) const; + bool contains( const int, const int = -1 ) const; + virtual bool load( const QString&, QtxActionMgr::Reader& ); protected slots: