Version: 6.3.1
Data Structures | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Slots | Private Attributes

QtxActionMgr Class Reference

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

#include <QtxActionMgr.h>

Inheritance diagram for QtxActionMgr:
Inheritance graph

Data Structures

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.
virtual ~QtxActionMgr ()
 Destructor.
virtual int registerAction (QAction *, const int=-1)
 Register an action in the internal map.
virtual void unRegisterAction (const int)
 Unregister action from internal map.
QActionaction (const int) const
 Get action by specified identifier.
int actionId (const QAction *) const
 Get action identifier.
bool contains (const int) const
 Check if an action with given id is registered in the action manager.
int count () const
 Get total number of registered actions.
bool isEmpty () const
 Check if there are no actions registered in the action manager.
QIntList idList () const
 Get all registered actions identifiers.
bool isUpdatesEnabled () const
 Check if update is enabled.
virtual void setUpdatesEnabled (const bool)
 Enable/disable update operation.
virtual bool isVisible (const int, const int) const
 Check if an action with actId identifier is visible to the parent action with place identifier.
virtual void setVisible (const int, const int, const bool)
 Set action's visibility flag.
void update ()
 Update actions.
virtual bool isEnabled (const int) const
 Check is action with given id is enabled.
virtual void setEnabled (const int, const bool)

Static Public Member Functions

static QActionseparator (const bool=false)
 Create new separator action.

Protected Member Functions

virtual void internalUpdate ()
 Internal update.
int generateId () const
 Generate unique action identifier.
void triggerUpdate ()
 Perform delayed update.
virtual void updateContent ()
 Internal content update operation.

Private Types

typedef QPointer< QActionActionPtr
 Action guarded pointer.
typedef QMap< int, ActionPtrActionMap
 Actions map.

Private Slots

void onUpdateContent ()
 Called when delayed update is performed (via timer event).

Private Attributes

bool myUpdate
 update flag
ActionMap myActions
 actions map
QTimer * myUpdTimer
 update timer

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 QPointer<QAction> QtxActionMgr.ActionPtr [private]
typedef QMap<int, ActionPtr> QtxActionMgr.ActionMap [private]

Constructor & Destructor Documentation

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

Member Function Documentation

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().

void QtxActionMgr::unRegisterAction ( const int  id) [virtual]
Parameters:
idaction ID
See also:
registerAction()

Reimplemented in QtxPopupMgr.

References contains(), and myActions.

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 test_table.a, and 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.

bool QtxActionMgr::isEmpty ( ) const
Returns:
true if internal map is empty
See also:
count()

References myActions.

QIntList QtxActionMgr::idList ( ) const
Returns:
list of actions identifiers

References myActions.

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

References myUpdate.

void QtxActionMgr::setUpdatesEnabled ( const bool  upd) [virtual]
Parameters:
updnew state
See also:
isUpdatesEnabled(), 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 QtxActionMenuMgr, QtxActionToolMgr, and QtxPopupMgr.

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 QtxActionMenuMgr, and QtxActionToolMgr.

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.

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

References test_table.a, and action().

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

Enable/disable action with given id.

Parameters:
idaction ID
enablenew state

References test_table.a, and action().

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 test_table.a, and qtxSeparatorActionCleanup().

void QtxActionMgr::internalUpdate ( ) [protected, virtual]

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.

int QtxActionMgr::generateId ( ) const [protected]
Returns:
new ID
void QtxActionMgr::triggerUpdate ( ) [protected]

Does nothing if update is disabled.

See also:
isUpdatesEnabled(), setUpdatesEnabled(), update()

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

void QtxActionMgr::updateContent ( ) [protected, virtual]

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

See also:
triggerUpdate(), onUpdateContent()

Reimplemented in QtxActionMenuMgr, and QtxActionToolMgr.

void QtxActionMgr::onUpdateContent ( ) [private, slot]

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

References updateContent().


Field Documentation

bool QtxActionMgr.myUpdate [private]
QTimer* QtxActionMgr.myUpdTimer [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS