From: vsr Date: Mon, 21 May 2007 10:55:01 +0000 (+0000) Subject: Porting to Qt 4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0fec4f2306a5b6d40ba456db926387308f04169b;p=modules%2Fgui.git Porting to Qt 4 --- diff --git a/src/LogWindow/LogWindow.cxx b/src/LogWindow/LogWindow.cxx index cf6758c3a..c0f6bbcb4 100755 --- a/src/LogWindow/LogWindow.cxx +++ b/src/LogWindow/LogWindow.cxx @@ -411,18 +411,17 @@ void LogWindow::setMenuActions( const int flags ) } /*! - \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 + \brief Get menu actions which are currently visible in the context popup menu. + \return ORed together actions flags + \sa setMenuActions() */ -bool LogWindow::testMenuActions( const int flags ) const +int LogWindow::menuActions() 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() ); + int ret = 0; + ret = ret | ( myActions[CopyId]->isVisible() ? CopyId : 0 ); + ret = ret | ( myActions[ClearId]->isVisible() ? ClearId : 0 ); + ret = ret | ( myActions[SelectAllId]->isVisible() ? SelectAllId : 0 ); + ret = ret | ( myActions[SaveToFileId]->isVisible() ? SaveToFileId : 0 ); return ret; } diff --git a/src/LogWindow/LogWindow.h b/src/LogWindow/LogWindow.h index bbce2eedc..b1816f8c8 100755 --- a/src/LogWindow/LogWindow.h +++ b/src/LogWindow/LogWindow.h @@ -97,7 +97,7 @@ public: bool saveLog( const QString& ); void setMenuActions( const int ); - bool testMenuActions( const int ) const; + int menuActions() const; protected slots: void onSaveToFile(); diff --git a/src/PyConsole/PyConsole_Console.cxx b/src/PyConsole/PyConsole_Console.cxx index 3ac59946f..4334b24e9 100644 --- a/src/PyConsole/PyConsole_Console.cxx +++ b/src/PyConsole/PyConsole_Console.cxx @@ -206,18 +206,17 @@ void PyConsole_Console::setMenuActions( const int flags ) } /*! - \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 + \brief Get menu actions which are currently visible in the context popup menu. + \return ORed together actions flags + \sa setMenuActions() */ -bool PyConsole_Console::testMenuActions( const int flags ) const +int PyConsole_Console::menuActions() 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() ); + int ret = 0; + ret = ret | ( myActions[CopyId]->isVisible() ? CopyId : 0 ); + ret = ret | ( myActions[PasteId]->isVisible() ? PasteId : 0 ); + ret = ret | ( myActions[ClearId]->isVisible() ? ClearId : 0 ); + ret = ret | ( myActions[SelectAllId]->isVisible() ? SelectAllId : 0 ); return ret; } diff --git a/src/PyConsole/PyConsole_Console.h b/src/PyConsole/PyConsole_Console.h index f31383471..32448c38c 100644 --- a/src/PyConsole/PyConsole_Console.h +++ b/src/PyConsole/PyConsole_Console.h @@ -69,7 +69,7 @@ public: virtual void contextMenuPopup( QMenu* ); void setMenuActions( const int ); - bool testMenuActions( const int ) const; + int menuActions() const; private: void createActions(); diff --git a/src/Qtx/QtxWorkspaceAction.cxx b/src/Qtx/QtxWorkspaceAction.cxx index 7a163d590..d0d208102 100644 --- a/src/Qtx/QtxWorkspaceAction.cxx +++ b/src/Qtx/QtxWorkspaceAction.cxx @@ -31,9 +31,8 @@ Constructor */ QtxWorkspaceAction::QtxWorkspaceAction( QtxWorkspace* ws, QObject* parent ) -: QtxActionSet( parent ), -myFlags( 0 ), -myWorkspace( ws ) +: QtxActionSet( parent ) + myWorkspace( ws ) { insertAction( new QtxAction( tr( "Arranges the windows as overlapping tiles" ), tr( "Cascade" ), 0, this ), Cascade ); @@ -65,40 +64,36 @@ QtxWorkspace* QtxWorkspaceAction::workspace() const } /*! - \return set of action flags -*/ -int QtxWorkspaceAction::items() const -{ - return myFlags; -} + \brief Set actions to be visible in the menu. + + Actions, which IDs are set in \a flags parameter, will be shown in the + menu bar. Other actions will not be shown. -/*! - Sets action flags - \param flags - new set of flags + \param flags ORed together actions flags */ -void QtxWorkspaceAction::setItems( const int flags ) +void QtxWorkspaceAction::setMenuActions( const int flags ) { - if ( flags == myFlags ) - return; - - myFlags = flags; - - uint f = Windows; - while ( f ) - { - if ( action( f ) ) - action( f )->setVisible( myFlags & f ); - f = f >> 1; - } + action( Cascade )->setVisible( flags & Cascade ); + action( Tile )->setVisible( flags & Tile ); + action( VTile )->setVisible( flags & VTile ); + action( HTile )->setVisible( flags & HTile ); + action( Windows )->setVisible( flags & Windows ); } /*! - \return true if action contains all flags - \param flags - new set of flags + \brief Get menu actions which are currently visible in the menu bar. + \return ORed together actions flags + \sa setMenuActions() */ -bool QtxWorkspaceAction::hasItems( const int flags ) const +int QtxWorkspaceAction::menuActions() const { - return ( myFlags & flags ) == flags; + int ret = 0; + ret = ret | ( action( Cascade )->isVisible() ? Cascade : 0 ); + ret = ret | ( action( Tile )->isVisible() ? Tile : 0 ); + ret = ret | ( action( VTile )->isVisible() ? VTile : 0 ); + ret = ret | ( action( HTile )->isVisible() ? HTile : 0 ); + ret = ret | ( action( Windows )->isVisible() ? Windows : 0 ); + return ret; } /*! diff --git a/src/Qtx/QtxWorkspaceAction.h b/src/Qtx/QtxWorkspaceAction.h index 1b3c92a7c..203b95cd8 100644 --- a/src/Qtx/QtxWorkspaceAction.h +++ b/src/Qtx/QtxWorkspaceAction.h @@ -51,9 +51,8 @@ public: QtxWorkspace* workspace() const; - int items() const; - void setItems( const int ); - bool hasItems( const int ) const; + void setMenuActions( const int ); + int menuActions() const; QIcon icon( const int ) const; QString text( const int ) const; @@ -87,7 +86,6 @@ private: void updateWindows(); private: - int myFlags; QtxWorkspace* myWorkspace; }; diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 6f76b2412..0d72eb2ec 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -1791,18 +1791,20 @@ void QtxWorkstack::setMenuActions( const int flags ) } /*! - \brief Test menu action. + \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 - \return \c true if all specified actions are visible and - \c false if at least one specified action is not visible */ -bool QtxWorkstack::testMenuActions( const int flags ) const +int QtxWorkstack::menuActions() const { - 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() ); + int ret = 0; + ret = ret | ( myActionsMap[SplitVertical]->isVisible() ? SplitVertical : 0 ); + ret = ret | ( myActionsMap[SplitHorizontal]->isVisible() ? SplitHorizontal : 0 ); + ret = ret | ( myActionsMap[Close]->isVisible() ? Close : 0 ); + ret = ret | ( myActionsMap[Rename]->isVisible() ? Rename : 0 ); return ret; } diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index e2caf914f..17adf9428 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -80,7 +80,7 @@ public: void setAccel( const int, const int ); void setMenuActions( const int ); - bool testMenuActions( const int ) const; + int menuActions() const; void split( const int ); diff --git a/src/STD/STD_MDIDesktop.cxx b/src/STD/STD_MDIDesktop.cxx index 5eb434840..7fc268671 100755 --- a/src/STD/STD_MDIDesktop.cxx +++ b/src/STD/STD_MDIDesktop.cxx @@ -137,7 +137,7 @@ void STD_MDIDesktop::setWindowOperations( const QList& opList ) for ( QList::const_iterator it = opList.begin(); it != opList.end(); ++it ) flags = flags | operationFlag( *it ); - myWorkspaceAction->setItems( flags ); + myWorkspaceAction->setMenuActions( flags ); } /*! @@ -171,9 +171,9 @@ void STD_MDIDesktop::createActions() myWorkspaceAction = new QtxWorkspaceAction( workspace(), this ); - myWorkspaceAction->setItems( QtxWorkspaceAction::Cascade | QtxWorkspaceAction::Tile | - QtxWorkspaceAction::HTile | QtxWorkspaceAction::VTile | - QtxWorkspaceAction::Windows ); + myWorkspaceAction->setMenuActions( QtxWorkspaceAction::Cascade | QtxWorkspaceAction::Tile | + QtxWorkspaceAction::HTile | QtxWorkspaceAction::VTile | + QtxWorkspaceAction::Windows ); // Cascade myWorkspaceAction->setIcon( QtxWorkspaceAction::Cascade,