Version: 6.3.1
Signals | Public Member Functions | Protected Member Functions | Private Types | Private Slots | Private Member Functions | Private Attributes

QtxActionSet Class Reference

An action class which is represented in the menu bar (or toolbar) as a group of items (which can be customized). More...

#include <QtxActionSet.h>

Inheritance diagram for QtxActionSet:
Inheritance graph

Signals

void triggered (int)
 Emitted when some child action is activated by the user.
void triggered (QAction *)
 Emitted when some child action is activated by the user.

Public Member Functions

 QtxActionSet (QObject *=0)
 Constructor.
virtual ~QtxActionSet ()
 Destructor.
QList< QAction * > actions () const
 Get list of child actions.
void setActions (const QList< QAction * > &)
 Assign child actions.
void insertActions (const QList< QAction * > &, const int=-1)
 Insert actions at the specified position.
int insertAction (QAction *, const int id=-1, const int=-1)
 Insert action at the specified position.
int insertAction (const QString &, const int id=-1, const int=-1)
 Insert action at the specified position.
int insertAction (const QString &, const QIcon &, const int id=-1, const int=-1)
 Insert action at the specified position.
void removeAction (QAction *)
 Remove specified action.
void removeAction (const int)
 Remove specified action.
void clear ()
 Remove all actions.
virtual bool eventFilter (QObject *, QEvent *)
 Customize action events.
QString shortcutActionName () const
 Return shortcut action name for the action.
void setShortcutActionName (const QString &)
 Set shortcut action name to the action.

Protected Member Functions

virtual void addedTo (QWidget *)
 Called when this action set is added to the menu bar (or toolbar).
virtual void removedFrom (QWidget *)
 Called when this action set is removed from the menu bar (or toolbar).
virtual void actionAdded (QAction *)
 Notify that action was added.
virtual void actionRemoved (QAction *)
 Notify that action was removed.
QActionaction (int) const
 Get action by specified identifier.
int actionId (QAction *) const
 Get action identifier for the action.
void setActionId (QAction *, const int)
 Set action identifier for the action.
virtual bool isEmptyAction () const
 Check if the action itself should be invisible (only child action are shown)
virtual void updateAction ()
 Update action set.
virtual void updateAction (QWidget *)
 Update action set for the specified widget.
virtual void customEvent (QEvent *)
 Process notification events.

Private Types

typedef QList< QAction * > ActionList

Private Slots

void onChanged ()
 Called when action is changed.
void onActionTriggered (bool=false)
 Called when some action is activated by the user.

Private Member Functions

int generateId () const
 Getneration unique action identifier.

Private Attributes

ActionList mySet
 actions list

Detailed Description

Example: Window menu in the MDI application with menu items:


Member Typedef Documentation

typedef QList<QAction*> QtxActionSet.ActionList [private]

Constructor & Destructor Documentation

QtxActionSet::QtxActionSet ( QObject parent = 0)
Parameters:
parentparent object

References onChanged().

QtxActionSet::~QtxActionSet ( ) [virtual]

Member Function Documentation

QList< QAction * > QtxActionSet::actions ( ) const
Returns:
list of assigned actions

References mySet.

void QtxActionSet::setActions ( const QList< QAction * > &  lst)
Parameters:
lstlist of actions

References insertActions(), and mySet.

void QtxActionSet::insertActions ( const QList< QAction * > &  lst,
const int  index = -1 
)
Parameters:
lstlist of actions
indexposition in the action list (if < 0, items are appended to the end of list)

References test_table.a, generateId(), mySet, onActionTriggered(), triggered(), and updateAction().

int QtxActionSet::insertAction ( QAction a,
const int  id = -1,
const int  index = -1 
)

If id < 0, it is generated automatically.

Parameters:
aaction being inserted
idaction ID
indexposition in the action list (if < 0, item is appended to the end of list)
Returns:
action identifier

References actionAdded(), generateId(), mySet, onActionTriggered(), triggered(), and updateAction().

int QtxActionSet::insertAction ( const QString &  txt,
const int  id = -1,
const int  index = -1 
)

If id < 0, it is generated automatically.

Parameters:
txtaction text
idaction ID
indexposition in the action list (if < 0, item is appended to the end of list)
Returns:
action identifier

References insertAction(), and QtxAction.QtxAction().

int QtxActionSet::insertAction ( const QString &  txt,
const QIcon &  icon,
const int  id = -1,
const int  index = -1 
)

If id < 0, it is generated automatically.

Parameters:
txtaction text
iconaction icon
idaction ID
indexposition in the action list (if < 0, item is appended to the end of list)
Returns:
action identifier

References insertAction(), and QtxAction.QtxAction().

void QtxActionSet::removeAction ( QAction a)

An action is removed from the action list and destroyed.

Parameters:
aaction to be removed.

References test_table.a, actionRemoved(), and mySet.

void QtxActionSet::removeAction ( const int  id)

An action is removed from the action list and destroyed.

Parameters:
idaction identifier

References action(), and removeAction().

void QtxActionSet::clear ( )

An actions list is cleared and all actions are destroyed.

References mySet, and updateAction().

void QtxActionSet::triggered ( int  id) [signal]
Parameters:
actionID
void QtxActionSet::triggered ( QAction a) [signal]
Parameters:
aaction being activated
void QtxActionSet::onChanged ( ) [private, slot]

Update action state.

References isEmptyAction().

void QtxActionSet::onActionTriggered ( bool  = false) [private, slot]
Parameters:
ontoggled state (not used)

References test_table.a, actionId(), and triggered().

void QtxActionSet::addedTo ( QWidget w) [protected, virtual]
Parameters:
wwidget this action set is added to

Reimplemented from QtxAction.

Reimplemented in QtxWorkspaceAction, and QtxWorkstackAction.

References updateAction().

void QtxActionSet::removedFrom ( QWidget w) [protected, virtual]
Parameters:
wwidget this action set is removed from

Reimplemented from QtxAction.

Reimplemented in QtxWorkspaceAction, and QtxWorkstackAction.

References updateAction().

void QtxActionSet::actionAdded ( QAction ) [protected, virtual]

Reimplemented in QtxActionGroup, and QtxMultiAction.

void QtxActionSet::actionRemoved ( QAction ) [protected, virtual]

Reimplemented in QtxActionGroup, and QtxMultiAction.

QAction * QtxActionSet::action ( int  id) const [protected]
Parameters:
idaction ID
Returns:
action or 0 if it is not found

References test_table.a, actionId(), and mySet.

int QtxActionSet::actionId ( QAction a) const [protected]
Parameters:
aaction
Returns:
action ID or -1 if it is not found
void QtxActionSet::setActionId ( QAction a,
const int  id 
) [protected]
Parameters:
aaction
idnew action ID
bool QtxActionSet::isEmptyAction ( ) const [protected, virtual]
Returns:
true if the action itself should be visible

Reimplemented in QtxActionGroup, and QtxMultiAction.

void QtxActionSet::updateAction ( ) [protected, virtual]

Reimplemented in QtxMultiAction.

void QtxActionSet::updateAction ( QWidget w) [protected, virtual]
Parameters:
wa widget this action is added to

Reimplemented in QtxActionGroup, and QtxMultiAction.

References test_table.a, and mySet.

int QtxActionSet::generateId ( ) const [private]
Returns:
generation action ID

References mySet.

bool QtxAction::eventFilter ( QObject o,
QEvent e 
) [virtual, inherited]

Sends a notification event to the action when it is added to the widget or removed from it in order to perform custom processing.

Parameters:
oobject
eevent
Returns:
true if further event processing should be stopped
See also:
customEvent(), addedTo(), removedFrom()
QString QtxAction::shortcutActionName ( ) const [inherited]
Returns:
shortcut action name
See also:
setShortcutActionName()

References QtxAction.myShortcutActionName.

void QtxAction::setShortcutActionName ( const QString &  shortcutAction) [inherited]

Shortcut action name is used for shortcuts customization.

Parameters:
shortcutActionshortcut action name
See also:
shortcutActionName()

References QtxAction.myShortcutActionName.

void QtxAction::customEvent ( QEvent e) [protected, virtual, inherited]

Calls addedTo() method when the action is added to the widget and removedFrom() when it is removed from the widget in order to perform custom processing.

Parameters:
enoification event
See also:
eventFilter(), addedTo(), removedFrom()

References QtxAction.addedTo(), QtxAction.ActionNotify.isAdded(), QtxAction.removedFrom(), and QtxAction.ActionNotify.widget().


Field Documentation

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