ContextMenu Class Reference

Provides access to customize a context menu for one or more session items. More...

#include <ContextMenu.h>

List of all members.

Public Member Functions

virtual const std::vector
< SessionItem * > & 
getSessionItems () const =0
template<typename T>
std::vector< T * > getSessionItems () const
virtual const QPoint & getMouseLocation () const =0
virtual QObject * getActionParent () const =0
virtual bool addAction (const ContextMenuAction &menuAction)=0
virtual bool addAction (QAction *pAction, const std::string &id)=0
virtual bool addActionBefore (QAction *pAction, const std::string &id, const std::string &beforeId)=0
virtual bool addActionAfter (QAction *pAction, const std::string &id, const std::string &afterId)=0
virtual void removeAction (const std::string &id)=0

Static Public Member Functions

static bool getSettingLogActions ()
static bool hasSettingLogActions ()
static void setSettingLogActions (bool newValue, bool setIfSame=false)
static std::string getSettingLogActionsKey ()

Protected Member Functions

virtual ~ContextMenu ()


Detailed Description

Provides access to customize a context menu for one or more session items.

A ContextMenu is created by objects that display a context menu to the user for one or more session items. An object usually creates the menu before it emits a signal that allows attached object to add actions to the menu or to remove one or more of the default actions.

Actions can be added to or removed from the menu using ContextMenuAction objects, which gives all objects that need to modify the actions a chance to add or remove actions. The actual list of actions that are displayed to the user is not created until the menu is shown.

See also:
Customizing context menus

Definition at line 40 of file ContextMenu.h.


Constructor & Destructor Documentation

virtual ContextMenu::~ContextMenu (  )  [protected, virtual]

This object does not need to be destroyed directly.

It will be deleted by the object that creates and displays the context menu.

Definition at line 263 of file ContextMenu.h.


Member Function Documentation

static bool ContextMenu::getSettingLogActions (  )  [static]

Returns the current value for this setting.

If this setting does not exist in ConfigurationSettings, a verification error will be logged to the message log and potentially a verification error message box will be displayed to the user.

Please see Settings Macros for more details

Returns:
the current value for this setting.

Definition at line 53 of file ContextMenu.h.

static bool ContextMenu::hasSettingLogActions (  )  [static]

Returns true if this setting exists and has a value in ConfigurationSettings.

Please see Settings Macros for more details

Returns:
true if this setting exists, false otherwise.

Definition at line 60 of file ContextMenu.h.

static void ContextMenu::setSettingLogActions ( bool  newValue,
bool  setIfSame = false 
) [static]

Changes the current value of this setting to the new value.

Please see Settings Macros for more details

Parameters:
newValue the new value for this setting.
setIfSame If true, the value will be set into ConfigurationSettings even if the newValue and existing value are the same. This has the side-effect of making the value a per-user setting and stored in the user's configuration file. If false, this value will only be set if the newValue and existing value are different. Therefore the value will only be stored in the user's configuration file if the newValue is unique to the user.

Definition at line 76 of file ContextMenu.h.

static std::string ContextMenu::getSettingLogActionsKey (  )  [static]

Returns the key for this setting that could be passed to ConfigurationSettings::getSetting() or ConfigurationSettings::setSetting().

Please see Settings Macros for more details

Returns:
the key used for this setting.

Definition at line 84 of file ContextMenu.h.

virtual const std::vector<SessionItem*>& ContextMenu::getSessionItems (  )  const [pure virtual]

Returns the session items for which the context menu will display actions.

Returns:
The session items for which the context menu has been requested.

template<typename T>
std::vector<T*> ContextMenu::getSessionItems (  )  const

Returns only the session items of a specified type for which the context menu will display actions.

This is a convenience method that gets all session items for which the context menu has been requested filters the returned items based on the specified type.

Returns:
The session items of the specified type for which the context menu has been requested. If the returned vector is empty, no session items of the specified type are included in those items for which the context menu is requested. The pointers in the returned vector are guaranteed to be non-NULL.
See also:
getSessionItems()

Definition at line 112 of file ContextMenu.h.

virtual const QPoint& ContextMenu::getMouseLocation (  )  const [pure virtual]

Returns the context menu mouse click location.

Returns:
The mouse click location for the context menu in global coordinates.

virtual QObject* ContextMenu::getActionParent (  )  const [pure virtual]

Returns a pointer to an object that can be used as a parent for a menu action.

This method provides a QObject that can optionally be used as the parent for a menu action. By using this object as a parent, the action will automatically be deleted when the context menu itself is deleted.

Returns:
A pointer to the object that can be used as a parent object for menu actions.
Warning:
Actions created with the returned object as a parent should not be stored, since the action will automatically be deleted when the context menu is deleted.

virtual bool ContextMenu::addAction ( const ContextMenuAction menuAction  )  [pure virtual]

Adds an action to a context menu.

Parameters:
menuAction The action to add to the context menu.
Returns:
Returns true if the action was successfully added to the menu. Returns false if the given action has already been added to the menu.
See also:
ContextMenuAction, addAction(QAction*, const std::string&), addActionBefore(), addActionAfter(), removeAction()

virtual bool ContextMenu::addAction ( QAction *  pAction,
const std::string &  id 
) [pure virtual]

Adds an action to a context menu.

This is a convenience method that creates a ContextMenuAction to append the given action to the list of actions that will be displayed in the context menu and calls addAction(const ContextMenuAction&).

Parameters:
pAction The action to add to the context menu.
id The unique identifier for the action.
Returns:
Returns true if the action was successfully added to the menu. Returns false if the given action has already been added to the menu, if pAction is NULL, or if id is empty.
See also:
addActionBefore(), addActionAfter(), removeAction()

virtual bool ContextMenu::addActionBefore ( QAction *  pAction,
const std::string &  id,
const std::string &  beforeId 
) [pure virtual]

Inserts an action into a context menu before another action.

This is a convenience method that creates a ContextMenuAction to add the given action to the list of actions that will be displayed in the context menu, sets the placement of the action to appear before the given action, and calls addAction(const ContextMenuAction&).

Parameters:
pAction The action to add to the context menu.
id The unique identifier for the action to add.
beforeId The unique identifier for the action that should appear below the added action. If beforeId is empty, this method is identical to addAction(QAction*, const std::string&).
Returns:
Returns true if the action was successfully added to the menu. Returns false if the given action has already been added to the menu, if pAction is NULL, or if id is empty.
See also:
addActionAfter(), removeAction()

virtual bool ContextMenu::addActionAfter ( QAction *  pAction,
const std::string &  id,
const std::string &  afterId 
) [pure virtual]

Inserts an action into a context menu after another action.

This is a convenience method that creates a ContextMenuAction to add the given action to the list of actions that will be displayed in the context menu, sets the placement of the action to appear after the given action, and calls addAction(const ContextMenuAction&).

Parameters:
pAction The action to add to the context menu.
id The unique identifier for the action to add.
afterId The unique identifier for the action that should appear above the added action. If afterId is empty, this method is identical to addAction(QAction*, const std::string&).
Returns:
Returns true if the action was successfully added to the menu. Returns false if the given action has already been added to the menu, if pAction is NULL, or if id is empty.
See also:
addActionBefore(), removeAction()

virtual void ContextMenu::removeAction ( const std::string &  id  )  [pure virtual]

Removes an action from the context menu.

This method registers the given action to be removed from the context menu. The action is not removed until all slot methods that are connected to the about-to-show context menu signal are called. This allows for correct placement of all actions in the menu before any actions are removed.

Parameters:
id The unique identifier for the action to remove from the menu.
See also:
addAction(const ContextMenuAction&)


Software Development Kit - Opticks 4.9.0 Build 16218