From c21fece420e33349fd59e10ee04f8297d38bd564 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 9 Mar 2011 15:06:13 +0000 Subject: [PATCH] Issue 0021166: EDF 1745 GUI: Expand and collapse objects of the object browser from Python GUI --- src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 38 +++++++++++++++++++++-- src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 2 ++ src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index f466eb966..202f4a4b2 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -46,12 +46,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -144,6 +146,7 @@ SALOME_Selection::SALOME_Selection( QObject* p ) : QObject( 0 ), mySelMgr( 0 ) connect( mySelMgr, SIGNAL( destroyed() ), this, SLOT ( onSelMgrDestroyed() ) ); } } + /*! \brief Destructor. */ @@ -305,7 +308,7 @@ QMenuBar* SalomePyQt::getMainMenuBar() } /*! - QMenu* SalomePyQt::getPopupMenu( const MenuName menu ); + \fn QMenu* SalomePyQt::getPopupMenu( const MenuName menu ); \brief Get main menu's child popup submenu by its identifier. This function is obsolete. @@ -316,7 +319,7 @@ QMenuBar* SalomePyQt::getMainMenuBar() */ /*! - QMenu* SalomePyQt::getPopupMenu( const QString& menu ); + \fn QMenu* SalomePyQt::getPopupMenu( const QString& menu ); \brief Get main menu's child popup submenu by its name. The function creates menu if it does not exist. @@ -342,6 +345,12 @@ public: } }; +/*! + \brief Get menu item title + \internal + \param menuId menu identifier + \return menu title (localized) +*/ static QString getMenuName( const QString& menuId ) { QStringList contexts; @@ -379,6 +388,31 @@ QMenu* SalomePyQt::getPopupMenu( const QString& menu ) return ProcessEvent( new TGetPopupMenuEvent( menu ) ); } +/*! + \fn QTreeView* SalomePyQt::getObjectBrowser(); + \brief Get object browser + \return object browser for the active study or 0 in case of error +*/ + +class TGetObjectBrowserEvent: public SALOME_Event +{ +public: + typedef QTreeView* TResult; + TResult myResult; + TGetObjectBrowserEvent() : myResult( 0 ) {} + virtual void Execute() + { + LightApp_Application* anApp = getApplication(); + if ( anApp ) { + myResult = anApp->objectBrowser()->treeView(); + } + } +}; +QTreeView* SalomePyQt::getObjectBrowser() +{ + return ProcessEvent( new TGetObjectBrowserEvent() ); +} + /*! \fn int SalomePyQt::getStudyId(); \brief Get active study's identifier. diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 885b708db..ddec49f74 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -39,6 +39,7 @@ class QMenuBar; class QMenu; class QWidget; class QAction; +class QTreeView; class QtxActionGroup; class SALOME_Selection : public QObject @@ -121,6 +122,7 @@ public: static QMenuBar* getMainMenuBar(); static QMenu* getPopupMenu( const MenuName ); static QMenu* getPopupMenu( const QString& ); + static QTreeView* getObjectBrowser(); static SALOME_Selection* getSelection(); static int getStudyId(); static void putInfo( const QString&, const int = 0 ); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index 229c82736..9833e01a7 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -208,6 +208,7 @@ public: static QMenuBar* getMainMenuBar() /ReleaseGIL/ ; static QMenu* getPopupMenu( const MenuName ) /ReleaseGIL/ ; static QMenu* getPopupMenu( const QString& ) /ReleaseGIL/ ; + static QTreeView* getObjectBrowser() /ReleaseGIL/ ; static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ; static int getStudyId() /ReleaseGIL/ ; static void putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ; -- 2.39.2