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

QtxActionGroup Class Reference

The QtxActionGroup class groups actions together. More...

#include <QtxActionGroup.h>

Inheritance diagram for QtxActionGroup:
Inheritance graph

Public Slots

void setExclusive (const bool)
 Set/clear the action group exclusiveness.
void setUsesDropDown (const bool)
 Defines a way how the group's actions should be displayed in parent widget action group is added to - as a group of actions or in a subwidget (e.g. in the combo box).

Signals

void selected (QAction *)
 Emitted when some child action is toggled by the user.
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

 QtxActionGroup (QObject *=0)
 Constructor.
 QtxActionGroup (QObject *, const bool)
 Constructor.
virtual ~QtxActionGroup ()
 Destructor.
bool isExclusive () const
 Check if the action group is exclusive.
bool usesDropDown () const
 Check if action group should appear in a subwidget of parent widget.
void add (QAction *)
 Append the specified action into group. action action to be added to the action group.
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 updateAction (QWidget *)
 Update action group for the specified widget.
virtual void updateAction (QtxComboBox *)
 Update action group for the specified combo box.
virtual QWidgetcreateWidget (QWidget *)
 Create widget representing action group in the widget this action group is added to.
virtual bool isEmptyAction () const
 Check if the action itself should be invisible (only child action are shown)
virtual void actionAdded (QAction *)
 Called when action is added to the action group.
virtual void actionRemoved (QAction *)
 Called when action is removed from the action group.
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).
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 void updateAction ()
 Update action set.
virtual void customEvent (QEvent *)
 Process notification events.

Private Slots

void onActivated (int)
 Called when some subwidget item is activated by the user.
void onTriggered (QAction *)
 Called when some action owned by this action group is activated by the user.

Private Member Functions

void updateType ()
 Internal update.
QtxComboBoxcreatedWidget (QWidget *)
 Get combo box created by this action group for the specified widget.

Private Attributes

bool myDropDown
QActionGroup * myActionGroup

Detailed Description

QtxActionGroup class operates with a list of actions in the similar way as it does QActionGroup class. But in contrast to the Qt 4's class, QtxActrionGroup behaves rather like it was in Qt series 3x. For example, it automatically shows exclusive combo box widget when action group is added to the toolbar and if usesDropDown and exclusive flags are both set to true.

The setExclusive() function is used to ensure that only one action is active at any moment: it should be used with actions which have their checkable state set to true.

Action group actions appear as individual menu options and toolbar buttons. For exclusive action groups use setUsesDropDown() to display the actions in a subwidget of the toolbar or menu the action group is added on.

Actions can be added to the action group using add() function. Add the action group to the menu or toolbar in the same way as for single action - using addAction() method of QMenu or QToolbar class.


Constructor & Destructor Documentation

QtxActionGroup::QtxActionGroup ( QObject parent = 0)

The created action group is exclusive by default.

Parameters:
parentowner object
See also:
setExclusive()

References myActionGroup, onTriggered(), and QtxActionSet.triggered().

QtxActionGroup::QtxActionGroup ( QObject parent,
const bool  exclusive 
)
Parameters:
parentowner object
exclusiveif true only one action in the group will ever be active
See also:
setExclusive()

References myActionGroup, selected(), and QtxActionSet.triggered().

QtxActionGroup::~QtxActionGroup ( ) [virtual]

Member Function Documentation

bool QtxActionGroup::isExclusive ( ) const
Returns:
true if the action group is exclusive and false otherwise
See also:
setExclusive(), setUsesDropDown()

References myActionGroup.

bool QtxActionGroup::usesDropDown ( ) const

Note: for this option to take into effect, the exclusive flag should be also set to true

Returns:
true if the action group is shown in subwidget
See also:
setUsesDropDown(), setExclusive()

References myDropDown.

void QtxActionGroup::add ( QAction a)
void QtxActionGroup::setExclusive ( const bool  on) [slot]
Parameters:
onif true the action group will be exclusive
See also:
isExclusive(), setUsesDropDown()

References isEmptyAction(), myActionGroup, and updateType().

void QtxActionGroup::setUsesDropDown ( const bool  on) [slot]
Parameters:
onif true, action group will be shown in the subwidget
See also:
usesDropDown(), setExclusive()

References isEmptyAction(), myDropDown, and updateType().

void QtxActionGroup::selected ( QAction a) [signal]
Parameters:
aaction being toggled
void QtxActionGroup::onActivated ( int  id) [private, slot]
Parameters:
iditem identifier

References test_table.a, QtxActionSet.action(), and QtxComboBox.setCurrentId().

void QtxActionGroup::onTriggered ( QAction a) [private, slot]
Parameters:
aaction being activated

References QtxActionSet.actionId(), selected(), and QtxComboBox.setCurrentId().

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

Reimplemented from QtxActionSet.

References QtxActionSet.actions(), createdWidget(), QtxActionSet.updateAction(), and usesDropDown().

void QtxActionGroup::updateAction ( QtxComboBox cb) [protected, virtual]
Parameters:
cba combo box this action group is added to

References test_table.a, QtxActionSet.actionId(), QtxActionSet.actions(), QtxComboBox.setCleared(), QtxComboBox.setCurrentId(), and QtxComboBox.setId().

QWidget * QtxActionGroup::createWidget ( QWidget p) [protected, virtual]
Parameters:
pwidget this action group is being added to
Returns:
new widget representing this action group

References isEmptyAction(), and onActivated().

bool QtxActionGroup::isEmptyAction ( ) const [protected, virtual]
Returns:
true if the action itself should be visible

Reimplemented from QtxActionSet.

References isExclusive(), and usesDropDown().

void QtxActionGroup::actionAdded ( QAction a) [protected, virtual]
Parameters:
aaction being added to the action group

Reimplemented from QtxActionSet.

References myActionGroup.

void QtxActionGroup::actionRemoved ( QAction a) [protected, virtual]
Parameters:
aaction being removed from the action group

Reimplemented from QtxActionSet.

References myActionGroup.

void QtxActionGroup::updateType ( ) [private]

References isEmptyAction().

QtxComboBox * QtxActionGroup::createdWidget ( QWidget p) [private]
Parameters:
pwidget this action group is added to
Returns:
combo box if it was created for the specified widget or 0 otherwise
QList< QAction * > QtxActionSet::actions ( ) const [inherited]
Returns:
list of assigned actions

References QtxActionSet.mySet.

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

References QtxActionSet.insertActions(), and QtxActionSet.mySet.

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

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

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

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 QtxActionSet.actionAdded(), QtxActionSet.generateId(), QtxActionSet.mySet, QtxActionSet.onActionTriggered(), QtxActionSet.triggered(), and QtxActionSet.updateAction().

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

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 QtxActionSet.insertAction(), and QtxAction.QtxAction().

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

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 QtxActionSet.insertAction(), and QtxAction.QtxAction().

void QtxActionSet::removeAction ( QAction a) [inherited]

An action is removed from the action list and destroyed.

Parameters:
aaction to be removed.

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

void QtxActionSet::removeAction ( const int  id) [inherited]

An action is removed from the action list and destroyed.

Parameters:
idaction identifier

References QtxActionSet.action(), and QtxActionSet.removeAction().

void QtxActionSet::clear ( ) [inherited]

An actions list is cleared and all actions are destroyed.

References QtxActionSet.mySet, and QtxActionSet.updateAction().

void QtxActionSet::triggered ( int  id) [signal, inherited]
Parameters:
actionID
void QtxActionSet::triggered ( QAction a) [signal, inherited]
Parameters:
aaction being activated
void QtxActionSet::addedTo ( QWidget w) [protected, virtual, inherited]
Parameters:
wwidget this action set is added to

Reimplemented from QtxAction.

Reimplemented in QtxWorkspaceAction, and QtxWorkstackAction.

References QtxActionSet.updateAction().

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

Reimplemented from QtxAction.

Reimplemented in QtxWorkspaceAction, and QtxWorkstackAction.

References QtxActionSet.updateAction().

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

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

int QtxActionSet::actionId ( QAction a) const [protected, inherited]
Parameters:
aaction
Returns:
action ID or -1 if it is not found
void QtxActionSet::setActionId ( QAction a,
const int  id 
) [protected, inherited]
Parameters:
aaction
idnew action ID
void QtxActionSet::updateAction ( ) [protected, virtual, inherited]

Reimplemented in QtxMultiAction.

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

bool QtxActionGroup.myDropDown [private]
QActionGroup* QtxActionGroup.myActionGroup [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