Manages a set of actions accessible by unique identifier. More...
#include <QtxActionMgr.h>

Classes | |
| class | Creator |
| Generic actions creator class. More... | |
| class | Reader |
| Generic actions description files reader class. More... | |
| class | SeparatorAction |
| Separator action class. More... | |
| class | XMLReader |
| XML file reader. More... | |
Public Member Functions | |
| QtxActionMgr (QObject *parent) | |
| Constructor. More... | |
| virtual | ~QtxActionMgr () |
| Destructor. More... | |
| virtual int | registerAction (QAction *, const int=-1) |
| Register an action in the internal map. More... | |
| virtual void | unRegisterAction (const int) |
| Unregister action from internal map. More... | |
| QAction * | action (const int) const |
| Get action by specified identifier. More... | |
| int | actionId (const QAction *) const |
| Get action identifier. More... | |
| bool | contains (const int) const |
| Check if an action with given id is registered in the action manager. More... | |
| int | count () const |
| Get total number of registered actions. More... | |
| bool | isEmpty () const |
| Check if there are no actions registered in the action manager. More... | |
| QIntList | idList () const |
| Get all registered actions identifiers. More... | |
| bool | isUpdatesEnabled () const |
| Check if update is enabled. More... | |
| virtual void | setUpdatesEnabled (const bool) |
| Enable/disable update operation. More... | |
| virtual bool | isVisible (const int, const int) const |
| Check if an action with actId identifier is visible to the parent action with place identifier. More... | |
| virtual void | setVisible (const int, const int, const bool) |
| Set action's visibility flag. More... | |
| void | update () |
| Update actions. More... | |
| virtual bool | isEnabled (const int) const |
| Check is action with given id is enabled. More... | |
| virtual void | setEnabled (const int, const bool) |
Static Public Member Functions | |
| static QAction * | separator (const bool=false) |
| Create new separator action. More... | |
Protected Member Functions | |
| virtual void | internalUpdate () |
| Internal update. More... | |
| int | generateId () const |
| Generate unique action identifier. More... | |
| void | triggerUpdate () |
| Perform delayed update. More... | |
| virtual void | updateContent () |
| Internal content update operation. More... | |
| virtual void | actionChanged (int) |
| Internal action changing response operation. More... | |
Private Types | |
| typedef QPointer< QAction > | ActionPtr |
| Action guarded pointer. More... | |
| typedef QMap< int, ActionPtr > | ActionMap |
| Actions map. More... | |
Private Slots | |
| void | onActionChanged () |
| Called when one of the registered actions changed. More... | |
| void | onUpdateContent () |
| Called when delayed update is performed (via timer event). More... | |
Private Attributes | |
| bool | myUpdate |
| update flag More... | |
| ActionMap | myActions |
| actions map More... | |
| QTimer * | myUpdTimer |
| update timer More... | |
Manages a set of actions accessible by unique identifier.
Base class for menu, toolbar actions containers and popup menu creators.
Actions are registered in the manager with the registerAction() method and unregistered from it with the unRegisterAction() method.
Functions action() and actionId() allow getting action by its identifier and vice versa. Method contains() returns true if the action with the specified identifier is already registered.
To get total number of the registered actions can be retrieved by the method count(). Function isEmpty() returns true if manager does not contains any actions. The list of all actions identifiers can be retrieved with the idList() function.
The method separator() allows creating a separator action which can be used in the menus or toolbars to separate logical groups of actions.
To enable/disable any action by its identifier, use setEnabled() method.
|
private |
Actions map.
|
private |
Action guarded pointer.
| QtxActionMgr::QtxActionMgr | ( | QObject * | parent | ) |
Constructor.
| parent | parent object |
|
virtual |
Destructor.
| QAction * QtxActionMgr::action | ( | const int | id | ) | const |
Get action by specified identifier.
| id | action ID |
References contains(), and myActions.
|
protectedvirtual |
Internal action changing response operation.
Reimplemented in QtxActionMenuMgr.
| int QtxActionMgr::actionId | ( | const QAction * | a | ) | const |
| bool QtxActionMgr::contains | ( | const int | id | ) | const |
Check if an action with given id is registered in the action manager.
| id | action ID |
true if internal map contains action with such identifier References myActions.
| int QtxActionMgr::count | ( | ) | const |
|
protected |
Generate unique action identifier.
| QIntList QtxActionMgr::idList | ( | ) | const |
|
protectedvirtual |
Internal update.
This method is called by update() function and can be redefined in subclasses to customize update operation. Base implementation does nothing.
Reimplemented in QtxPopupMgr, QtxActionToolMgr, and QtxActionMenuMgr.
| bool QtxActionMgr::isEmpty | ( | ) | const |
|
virtual |
Check is action with given id is enabled.
| id | action ID |
true if action is enabled References action().
| bool QtxActionMgr::isUpdatesEnabled | ( | ) | const |
Check if update is enabled.
true if update is enabled References myUpdate.
|
virtual |
Check if an action with actId identifier is visible to the parent action with place identifier.
This method can be redefined in subclasses. Base implementatin always returns true.
| actId | action ID |
| place | some parent action ID |
true if an action is visible to the parent Reimplemented in QtxActionToolMgr, QtxActionMenuMgr, and QtxPopupMgr.
|
privateslot |
Called when one of the registered actions changed.
Calls virtual method actionChanged() which can be redefined in the subclasses to customize reaction on this.
References actionChanged(), and actionId().
|
privateslot |
Called when delayed update is performed (via timer event).
Calls virtual method updateContent() which can be redefined in the subclasses to customize the content update operation.
References updateContent().
|
virtual |
Register an action in the internal map.
If userId is less than 0, the identifier for the action is generated automatically. If action with given userId is already registered, it will be re-registered.
| a | action to be registered |
| userId | action ID |
References actionId(), contains(), generateId(), myActions, onActionChanged(), and unRegisterAction().
|
static |
Create new separator action.
If own is true, then the caller is responsible for the action destroying. If own is false, new separator action will be owned by the action manager which will destroy it on application exit.
| own | ownership flag |
References qtx_separator_actions, and qtxSeparatorActionCleanup().
|
virtual |
|
virtual |
Enable/disable update operation.
| upd | new state |
References myUpdate.
|
virtual |
Set action's visibility flag.
This method can be redefined in subclasses. Base implementatin does nothing.
| actId | action ID |
| place | some parent action ID |
| v | new visibility state |
Reimplemented in QtxActionToolMgr, and QtxActionMenuMgr.
|
protected |
Perform delayed update.
Does nothing if update is disabled.
References isUpdatesEnabled(), myUpdTimer, and onUpdateContent().
|
virtual |
Unregister action from internal map.
| id | action ID |
Reimplemented in QtxPopupMgr.
References contains(), myActions, and onActionChanged().
| void QtxActionMgr::update | ( | ) |
Update actions.
Calls virtual function internalUpdate to update the contents. Does nothing if update is disabled.
References internalUpdate(), isUpdatesEnabled(), and myUpdTimer.
|
protectedvirtual |
Internal content update operation.
Called automatically by onUpdateContent() when the delayed update is triggered. Base implementation does nothing.
Reimplemented in QtxActionToolMgr, and QtxActionMenuMgr.
|
private |
actions map
|
private |
update flag
|
private |
update timer