The class QtxMultiAction implements modifiable action. More...
#include <QtxMultiAction.h>

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. | |
| QAction * | activeAction () 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 QWidget * | createWidget (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). | |
| QAction * | action (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 | |
| QAction * | myCurrent |
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.
| QtxMultiAction::QtxMultiAction | ( | QObject * | parent = 0 | ) |
| parent | parent object |
References onTriggered(), and QtxActionSet.triggered().
| QtxMultiAction::QtxMultiAction | ( | const QString & | txt, |
| QObject * | parent = 0 |
||
| ) |
| txt | action menu text |
| parent | parent object |
References onTriggered(), and QtxActionSet.triggered().
| QtxMultiAction::QtxMultiAction | ( | const QIcon & | ico, |
| const QString & | txt, | ||
| QObject * | parent = 0 |
||
| ) |
| ico | action menu icon |
| txt | action menu text |
| parent | parent object |
References onTriggered(), and QtxActionSet.triggered().
| QtxMultiAction::~QtxMultiAction | ( | ) | [virtual] |
| void QtxMultiAction::setActiveAction | ( | QAction * | a | ) |
| a | action to be set current |
References test_table.a, QtxActionSet.actions(), myCurrent, and updateAction().
| QAction * QtxMultiAction::activeAction | ( | ) | const |
References myCurrent.
| void QtxMultiAction::onClicked | ( | bool | ) | [private, slot] |
| on | (not used) |
References myCurrent.
| void QtxMultiAction::onTriggered | ( | QAction * | a | ) | [private, slot] |
| a | action 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] |
true if the action itself should be visible Reimplemented from QtxActionSet.
| parent | parent widget (should be toolbar) |
References onClicked(), and updateButton().
| void QtxMultiAction::updateAction | ( | ) | [protected, virtual] |
Reimplemented from QtxActionSet.
References updateButton().
| void QtxMultiAction::updateAction | ( | QWidget * | w | ) | [protected, virtual] |
| void QtxMultiAction::actionAdded | ( | QAction * | a | ) | [protected, virtual] |
| a | child action being added |
Reimplemented from QtxActionSet.
References onActionChanged().
| void QtxMultiAction::actionRemoved | ( | QAction * | a | ) | [protected, virtual] |
| a | child action being removed |
Reimplemented from QtxActionSet.
References myCurrent, onActionChanged(), and updateAction().
| void QtxMultiAction::updateButton | ( | QToolButton * | btn | ) | [private] |
| btn | toolbar button |
References QtxActionSet.actions(), and myCurrent.
References QtxActionSet.mySet.
| lst | list of actions |
References QtxActionSet.insertActions(), and QtxActionSet.mySet.
| void QtxActionSet::insertActions | ( | const QList< QAction * > & | lst, |
| const int | index = -1 |
||
| ) | [inherited] |
| lst | list of actions |
| index | position 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.
| a | action being inserted |
| id | action ID |
| index | position in the action list (if < 0, item is appended to the end of list) |
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.
| txt | action text |
| id | action ID |
| index | position in the action list (if < 0, item is appended to the end of list) |
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.
| txt | action text |
| icon | action icon |
| id | action ID |
| index | position in the action list (if < 0, item is appended to the end of list) |
References QtxActionSet.insertAction(), and QtxAction.QtxAction().
| void QtxActionSet::removeAction | ( | QAction * | a | ) | [inherited] |
An action is removed from the action list and destroyed.
| a | action 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.
| id | action 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] |
| action | ID |
| void QtxActionSet::triggered | ( | QAction * | a | ) | [signal, inherited] |
| a | action being activated |
| void QtxActionSet::addedTo | ( | QWidget * | w | ) | [protected, virtual, inherited] |
| w | widget 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] |
| w | widget 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] |
| id | action ID |
References test_table.a, QtxActionSet.actionId(), and QtxActionSet.mySet.
| int QtxActionSet::actionId | ( | QAction * | a | ) | const [protected, inherited] |
| a | action |
| void QtxActionSet::setActionId | ( | QAction * | a, |
| const int | id | ||
| ) | [protected, inherited] |
| a | action |
| id | new action ID |
Sends a notification event to the action when it is added to the widget or removed from it in order to perform custom processing.
| o | object |
| e | event |
true if further event processing should be stopped | QString QtxAction::shortcutActionName | ( | ) | const [inherited] |
References QtxAction.myShortcutActionName.
| void QtxAction::setShortcutActionName | ( | const QString & | shortcutAction | ) | [inherited] |
Shortcut action name is used for shortcuts customization.
| shortcutAction | shortcut action name |
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.
| e | noification event |
References QtxAction.addedTo(), QtxAction.ActionNotify.isAdded(), QtxAction.removedFrom(), and QtxAction.ActionNotify.widget().
QAction* QtxMultiAction.myCurrent [private] |