Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QtxActionMgr Class Reference

Manages a set of actions accessible by unique identifier. More...

#include <QtxActionMgr.h>

Inheritance diagram for QtxActionMgr:
Inheritance graph

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...
 
QActionaction (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 QActionseparator (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< QActionActionPtr
 Action guarded pointer. More...
 
typedef QMap< int, ActionPtrActionMap
 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...
 

Detailed Description

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.

Member Typedef Documentation

typedef QMap<int, ActionPtr> QtxActionMgr::ActionMap
private
typedef QPointer<QAction> QtxActionMgr::ActionPtr
private

Constructor & Destructor Documentation

QtxActionMgr::QtxActionMgr ( QObject parent)
Parameters
parentparent object
QtxActionMgr::~QtxActionMgr ( )
virtual

Member Function Documentation

QAction * QtxActionMgr::action ( const int  id) const
Parameters
idaction ID
Returns
action (or 0 if id is invalid)
See Also
actionId()

References contains(), and myActions.

int QtxActionMgr::actionId ( const QAction a) const
Parameters
aaction
Returns
action ID (or -1 if action is not found)
See Also
action()

References myActions.

bool QtxActionMgr::contains ( const int  id) const
Parameters
idaction ID
Returns
true if internal map contains action with such identifier

References myActions.

int QtxActionMgr::count ( ) const
Returns
number of actions in the internal map
See Also
isEmpty()

References myActions.

int QtxActionMgr::generateId ( ) const
protected
Returns
new ID
QIntList QtxActionMgr::idList ( ) const
Returns
list of actions identifiers

References myActions.

void QtxActionMgr::internalUpdate ( )
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
Returns
true if internal map is empty
See Also
count()

References myActions.

bool QtxActionMgr::isEnabled ( const int  id) const
virtual
Parameters
idaction ID
Returns
true if action is enabled

References action().

bool QtxActionMgr::isUpdatesEnabled ( ) const
Returns
true if update is enabled
See Also
setUpdatesEnabled(), update()

References myUpdate.

bool QtxActionMgr::isVisible ( const int  ,
const int   
) const
virtual

This method can be redefined in subclasses. Base implementatin always returns true.

Parameters
actIdaction ID
placesome parent action ID
Returns
true if an action is visible to the parent
See Also
setVisible()

Reimplemented in QtxActionToolMgr, QtxPopupMgr, and QtxActionMenuMgr.

void QtxActionMgr::onUpdateContent ( )
privateslot

Calls virtual method updateContent() which can be redefined in the subclasses to customize the content update operation.

References updateContent().

int QtxActionMgr::registerAction ( QAction a,
const int  userId = -1 
)
virtual

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.

Parameters
aaction to be registered
userIdaction ID
Returns
action ID (the same as userId or generated one)
See Also
unRegisterAction()

References actionId(), contains(), generateId(), myActions, and unRegisterAction().

QAction * QtxActionMgr::separator ( const bool  own = false)
static

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.

Parameters
ownownership flag
Returns
new separator action

References qtxSeparatorActionCleanup().

void QtxActionMgr::setEnabled ( const int  id,
const bool  enable 
)
virtual

Enable/disable action with given id.

Parameters
idaction ID
enablenew state

References action().

void QtxActionMgr::setUpdatesEnabled ( const bool  upd)
virtual
Parameters
updnew state
See Also
isUpdatesEnabled(), update()

References myUpdate.

void QtxActionMgr::setVisible ( const int  ,
const int  ,
const bool   
)
virtual

This method can be redefined in subclasses. Base implementatin does nothing.

Parameters
actIdaction ID
placesome parent action ID
vnew visibility state
See Also
isVisible()

Reimplemented in QtxActionToolMgr, and QtxActionMenuMgr.

void QtxActionMgr::triggerUpdate ( )
protected

Does nothing if update is disabled.

See Also
isUpdatesEnabled(), setUpdatesEnabled(), update()

References isUpdatesEnabled(), myUpdTimer, and onUpdateContent().

void QtxActionMgr::unRegisterAction ( const int  id)
virtual
Parameters
idaction ID
See Also
registerAction()

Reimplemented in QtxPopupMgr.

References contains(), and myActions.

void QtxActionMgr::update ( )

Calls virtual function internalUpdate to update the contents. Does nothing if update is disabled.

See Also
setUpdatesEnabled(), isUpdatesEnabled(), internalUpdate()

References internalUpdate(), isUpdatesEnabled(), and myUpdTimer.

void QtxActionMgr::updateContent ( )
protectedvirtual

Called automatically by onUpdateContent() when the delayed update is triggered. Base implementation does nothing.

See Also
triggerUpdate(), onUpdateContent()

Reimplemented in QtxActionMenuMgr, and QtxActionToolMgr.

Member Data Documentation

ActionMap QtxActionMgr::myActions
private
bool QtxActionMgr::myUpdate
private
QTimer* QtxActionMgr::myUpdTimer
private

The documentation for this class was generated from the following files: