}
/*!
- \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;
}
bool saveLog( const QString& );
void setMenuActions( const int );
- bool testMenuActions( const int ) const;
+ int menuActions() const;
protected slots:
void onSaveToFile();
}
/*!
- \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;
}
virtual void contextMenuPopup( QMenu* );
void setMenuActions( const int );
- bool testMenuActions( const int ) const;
+ int menuActions() const;
private:
void createActions();
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 );
}
/*!
- \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;
}
/*!
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;
void updateWindows();
private:
- int myFlags;
QtxWorkspace* myWorkspace;
};
}
/*!
- \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;
}
void setAccel( const int, const int );
void setMenuActions( const int );
- bool testMenuActions( const int ) const;
+ int menuActions() const;
void split( const int );
for ( QList<int>::const_iterator it = opList.begin(); it != opList.end(); ++it )
flags = flags | operationFlag( *it );
- myWorkspaceAction->setItems( flags );
+ myWorkspaceAction->setMenuActions( flags );
}
/*!
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,