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

QtxMultiAction Class Reference

The class QtxMultiAction implements modifiable action. More...

#include <QtxMultiAction.h>

Inheritance diagram for QtxMultiAction:
Inheritance graph

Data Structures

class  Button
 Custom button to be used in the toolbar. More...
class  Filter
 Waches for the buttons in the popup menu to update the tool buttons state. More...
class  Menu
 Custom menu to be used with the toolbuttons as drop down list. More...

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

 QtxMultiAction (QObject *parent=0)
 Constructor.
 QtxMultiAction (const QString &, QObject *parent=0)
 Constructor.
 QtxMultiAction (const QIcon &, const QString &, QObject *parent=0)
 Constructor.
virtual ~QtxMultiAction ()
 Destructor.
void setActiveAction (QAction *)
 Set current action.
QActionactiveAction () const
 Get current action.
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 bool isEmptyAction () const
 Check if the action itself should be invisible (only child action are shown)
virtual QWidgetcreateWidget (QWidget *)
 Create widget to be displayed in the toolbar.
virtual void updateAction ()
 Update action.
virtual void updateAction (QWidget *)
 Update child (popup menu) action.
virtual void actionAdded (QAction *)
 Called when the child action is added to this action.
virtual void actionRemoved (QAction *)
 Called when the child action is removed from this action.
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 customEvent (QEvent *)
 Process notification events.

Private Slots

void onClicked (bool)
 Called when the user activates the current action (for example by clicking the tool button).
void onTriggered (QAction *)
 Called when user activates any action from the dropdown menu.
void onActionChanged ()
 Called when any child action is enabled/disabled.

Private Member Functions

void updateButton (QToolButton *)
 Update toolbar button.

Private Attributes

QActionmyCurrent

Detailed Description

The QtxMultiAction class provides a possibility to assign a set of actions (insertAction() function). The action can be used in the toolbar (and even in the menu) to show drop-down menu with the list of the assigned actions.

Initially the first action from the list becomes current and it is activated when the tool button is clicked by the user. If user presses and holds the mouse button at the tool button, it shows the popup menu with all the assigned actions. When the user selects any action from the popup menu, it becames current.


Constructor & Destructor Documentation

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

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

QtxMultiAction::QtxMultiAction ( const QString &  txt,
QObject parent = 0 
)
Parameters:
txtaction menu text
parentparent object

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

QtxMultiAction::QtxMultiAction ( const QIcon &  ico,
const QString &  txt,
QObject parent = 0 
)
Parameters:
icoaction menu icon
txtaction menu text
parentparent object

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

QtxMultiAction::~QtxMultiAction ( ) [virtual]

Member Function Documentation

void QtxMultiAction::setActiveAction ( QAction a)
Parameters:
aaction to be set current

References test_table.a, QtxActionSet.actions(), myCurrent, and updateAction().

QAction * QtxMultiAction::activeAction ( ) const
Returns:
current action (0 if there is no active action)

References myCurrent.

void QtxMultiAction::onClicked ( bool  ) [private, slot]
Parameters:
on(not used)

References myCurrent.

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

References test_table.a, myCurrent, and updateAction().

void QtxMultiAction::onActionChanged ( ) [private, slot]

If the current action is disabled, the multi-action switches to first found enabled. If all child actions are disabled, the action itself is also disabled.

References test_table.a, QtxActionSet.actions(), myCurrent, and updateAction().

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

Reimplemented from QtxActionSet.

QWidget * QtxMultiAction::createWidget ( QWidget parent) [protected, virtual]
Parameters:
parentparent widget (should be toolbar)
Returns:
toolbar button

References onClicked(), and updateButton().

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

Reimplemented from QtxActionSet.

References updateButton().

void QtxMultiAction::updateAction ( QWidget w) [protected, virtual]
Parameters:
wwidget menu widget

Reimplemented from QtxActionSet.

References updateAction().

void QtxMultiAction::actionAdded ( QAction a) [protected, virtual]
Parameters:
achild action being added

Reimplemented from QtxActionSet.

References onActionChanged().

void QtxMultiAction::actionRemoved ( QAction a) [protected, virtual]
Parameters:
achild action being removed

Reimplemented from QtxActionSet.

References myCurrent, onActionChanged(), and updateAction().

void QtxMultiAction::updateButton ( QToolButton btn) [private]
Parameters:
btntoolbar button

References QtxActionSet.actions(), and myCurrent.

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
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