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... | |
Private Types | |
typedef QPointer< QAction > | ActionPtr |
Action guarded pointer. More... | |
typedef QMap< int, ActionPtr > | ActionMap |
Actions map. More... | |
Private Slots | |
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... | |
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 |
|
private |
QtxActionMgr::QtxActionMgr | ( | QObject * | parent | ) |
parent | parent object |
|
virtual |
id | action ID |
References contains(), and myActions.
bool QtxActionMgr::contains | ( | const int | id | ) | const |
id | action ID |
true
if internal map contains action with such identifier References myActions.
int QtxActionMgr::count | ( | ) | const |
|
protected |
|
protectedvirtual |
This method is called by update() function and can be redefined in subclasses to customize update operation. Base implementation does nothing.
Reimplemented in QtxActionMenuMgr, QtxActionToolMgr, and QtxPopupMgr.
bool QtxActionMgr::isEmpty | ( | ) | const |
|
virtual |
bool QtxActionMgr::isUpdatesEnabled | ( | ) | const |
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, QtxPopupMgr, and QtxActionMenuMgr.
|
privateslot |
Calls virtual method updateContent() which can be redefined in the subclasses to customize the content update operation.
References updateContent().
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, and unRegisterAction().
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 qtxSeparatorActionCleanup().
|
virtual |
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 |
Does nothing if update is disabled.
References isUpdatesEnabled(), myUpdTimer, and onUpdateContent().
|
virtual |
id | action ID |
Reimplemented in QtxPopupMgr.
References contains(), and myActions.
void QtxActionMgr::update | ( | ) |
Calls virtual function internalUpdate to update the contents. Does nothing if update is disabled.
References internalUpdate(), isUpdatesEnabled(), and myUpdTimer.
|
protectedvirtual |
Called automatically by onUpdateContent() when the delayed update is triggered. Base implementation does nothing.
Reimplemented in QtxActionMenuMgr, and QtxActionToolMgr.
|
private |
|
private |
|
private |