From: vsr Date: Wed, 16 May 2007 14:17:31 +0000 (+0000) Subject: Porting to Qt4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1618c3f53dc5cb451175c57ce64695b57c872b30;p=modules%2Fgui.git Porting to Qt4 --- diff --git a/src/LogWindow/LogWindow.cxx b/src/LogWindow/LogWindow.cxx index 7c4104db2..cf6758c3a 100755 --- a/src/LogWindow/LogWindow.cxx +++ b/src/LogWindow/LogWindow.cxx @@ -410,6 +410,22 @@ void LogWindow::setMenuActions( const int flags ) myActions[SaveToFileId]->setVisible( flags & SaveToFileId ); } +/*! + \brief Test menu action. + \param flags ORed together actions flags + \return \c true if all specified actions are visible and + \c false if at least one specified action is not visible +*/ +bool LogWindow::testMenuActions( const int flags ) const +{ + bool ret = true; + ret = ret && ( !( flags & CopyId ) || myActions[CopyId]->isVisible() ); + ret = ret && ( !( flags & ClearId ) || myActions[ClearId]->isVisible() ); + ret = ret && ( !( flags & SelectAllId ) || myActions[SelectAllId]->isVisible() ); + ret = ret && ( !( flags & SaveToFileId ) || myActions[SaveToFileId]->isVisible() ); + return ret; +} + /*! \fn virtual QString LogWindow::popupClientType() const; \brief Get popup client symbolic name, used in popup menu management system. diff --git a/src/LogWindow/LogWindow.h b/src/LogWindow/LogWindow.h index 0b6a3d285..bbce2eedc 100755 --- a/src/LogWindow/LogWindow.h +++ b/src/LogWindow/LogWindow.h @@ -97,6 +97,7 @@ public: bool saveLog( const QString& ); void setMenuActions( const int ); + bool testMenuActions( const int ) const; protected slots: void onSaveToFile(); diff --git a/src/PyConsole/PyConsole_Console.cxx b/src/PyConsole/PyConsole_Console.cxx index 3e84dd477..3ac59946f 100644 --- a/src/PyConsole/PyConsole_Console.cxx +++ b/src/PyConsole/PyConsole_Console.cxx @@ -205,6 +205,22 @@ void PyConsole_Console::setMenuActions( const int flags ) myActions[SelectAllId]->setVisible( flags & SelectAllId ); } +/*! + \brief Test menu action. + \param flags ORed together actions flags + \return \c true if all specified actions are visible and + \c false if at least one specified action is not visible +*/ +bool PyConsole_Console::testMenuActions( const int flags ) const +{ + bool ret = true; + ret = ret && ( !( flags & CopyId ) || myActions[CopyId]->isVisible() ); + ret = ret && ( !( flags & PasteId ) || myActions[PasteId]->isVisible() ); + ret = ret && ( !( flags & ClearId ) || myActions[ClearId]->isVisible() ); + ret = ret && ( !( flags & SelectAllId ) || myActions[SelectAllId]->isVisible() ); + return ret; +} + /*! \brief Create menu actions. diff --git a/src/PyConsole/PyConsole_Console.h b/src/PyConsole/PyConsole_Console.h index c8b8677fe..f31383471 100644 --- a/src/PyConsole/PyConsole_Console.h +++ b/src/PyConsole/PyConsole_Console.h @@ -69,6 +69,7 @@ public: virtual void contextMenuPopup( QMenu* ); void setMenuActions( const int ); + bool testMenuActions( const int ) const; private: void createActions(); diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 4884ceaa1..6f76b2412 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -1775,27 +1775,35 @@ int QtxWorkstack::accel( const int id ) const } /*! - \brief Check if the action is enabled. - \param id action ID - \return \c true if action is enabled + \brief Set actions to be visible in the context popup menu. + + Actions, which IDs are set in \a flags parameter, will be shown in the + context popup menu. Other actions will not be shown. + + \param flags ORed together actions flags */ -bool QtxWorkstack::isActionEnabled( const int id ) const +void QtxWorkstack::setMenuActions( const int flags ) { - bool res = false; - if ( myActionsMap.contains( id ) ) - res = myActionsMap[id]->isEnabled(); - return res; + myActionsMap[SplitVertical]->setVisible( flags & SplitVertical ); + myActionsMap[SplitHorizontal]->setVisible( flags & SplitHorizontal ); + myActionsMap[Close]->setVisible( flags & Close ); + myActionsMap[Rename]->setVisible( flags & Rename ); } /*! - \brief Enable/disable action. - \param id action ID - \param on if \c true, enable the action, else disable it + \brief Test menu action. + \param flags ORed together actions flags + \return \c true if all specified actions are visible and + \c false if at least one specified action is not visible */ -void QtxWorkstack::setActionEnabled( const int id, const bool on ) +bool QtxWorkstack::testMenuActions( const int flags ) const { - if ( myActionsMap.contains( id ) ) - myActionsMap[id]->setEnabled( on ); + bool ret = true; + ret = ret && ( !( flags & SplitVertical ) || myActionsMap[SplitVertical]->isVisible() ); + ret = ret && ( !( flags & SplitHorizontal ) || myActionsMap[SplitHorizontal]->isVisible() ); + ret = ret && ( !( flags & Close ) || myActionsMap[Close]->isVisible() ); + ret = ret && ( !( flags & Rename ) || myActionsMap[Rename]->isVisible() ); + return ret; } /*! diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index 6d472325e..e2caf914f 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -51,10 +51,12 @@ class QTX_EXPORT QtxWorkstack : public QWidget public: //! Workstack actions (context menu items) - enum { SplitVertical, //!< "Split vertically" menu item - SplitHorizontal, //!< "Split horizontally" menu item - Close, //!< "Close" menu item - Rename //!< "Rename" menu item + enum { SplitVertical = 0x01, //!< "Split vertically" menu item + SplitHorizontal = 0x02, //!< "Split horizontally" menu item + Close = 0x04, //!< "Close" menu item + Rename = 0x08, //!< "Rename" menu item + All = SplitVertical | SplitHorizontal | + Close | Rename //!< all menu items }; //! Workstack splitting type @@ -77,8 +79,8 @@ public: int accel( const int ) const; void setAccel( const int, const int ); - bool isActionEnabled( const int ) const; - void setActionEnabled( const int, const bool ); + void setMenuActions( const int ); + bool testMenuActions( const int ) const; void split( const int );