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.
bool saveLog( const QString& );
void setMenuActions( const int );
+ bool testMenuActions( const int ) const;
protected slots:
void onSaveToFile();
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.
virtual void contextMenuPopup( QMenu* );
void setMenuActions( const int );
+ bool testMenuActions( const int ) const;
private:
void createActions();
}
/*!
- \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;
}
/*!
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
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 );