An action, representing the list of modules to be inserted to the toolbar. More...
#include <LightApp_ModuleAction.h>

Data Structures | |
| class | ActionSet |
| Internal class to represent list of modules buttons. More... | |
| class | ComboAction |
| Internal class to represent combo box with the list of modules in the toolbar. More... | |
Public Types | |
| enum | { None = 0x00, Buttons = 0x01, ComboItem = 0x02, All = Buttons | ComboItem } |
Signals | |
| void | moduleActivated (const QString &) |
| Emitted when the module is activated. | |
Public Member Functions | |
| LightApp_ModuleAction (const QString &, QObject *=0) | |
| Constructor. | |
| LightApp_ModuleAction (const QString &, const QIcon &, QObject *=0) | |
| Constructor. | |
| virtual | ~LightApp_ModuleAction () |
| Destructor. | |
| QStringList | modules () const |
| Get list of modules. | |
| QIcon | moduleIcon (const QString &) const |
| Get module icon. | |
| void | setModuleIcon (const QString &, const QIcon &) |
| Set module icon. | |
| void | insertModule (const QString &, const QIcon &, const int=-1) |
| Add module into the list. | |
| void | removeModule (const QString &) |
| Remove module from the list. | |
| QString | activeModule () const |
| Get active module. | |
| void | setActiveModule (const QString &) |
| Set active module. | |
| void | setMode (const int) |
| Set action display mode. | |
| int | mode () const |
| Get action display mode. | |
| 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 the action is added to the widget. | |
| virtual void | removedFrom (QWidget *) |
| Remove action from widget. | |
| virtual void | customEvent (QEvent *) |
| Process notification events. | |
Private Slots | |
| void | onChanged () |
| Called when action state is changed. | |
| void | onTriggered (int) |
| Called when module button is triggered. | |
| void | onComboActivated (int) |
| Called when combo box item is activated. | |
Private Member Functions | |
| void | init () |
| Initialize an action,. | |
| void | update () |
| Update an action. | |
| void | update (QtxComboBox *) |
| Update combo box. | |
| QAction * | active () const |
| Get an action corresponding to the active module. | |
| void | activate (int, bool=true) |
| Activate a module item. | |
Private Attributes | |
| ComboAction * | myCombo |
| ActionSet * | mySet |
| int | myMode |
This action is represented in the toolbar as combo box and a set of buttons for each module. In addition to the modules items, the combo box contains an item corresponding to the "neutral point" of the application (when there is no active module).
The action can be constructed with up to two parameters, defining the text and icon to be displayed for the "neutral point".
Only one module can be active at the moment. It can be set programmatically with setActiveModule() function. Use this method with empty string to turn to the "neutral point". To get active module, use activeModule() function.
When user activates/deactivates any module, the signal moduleActivated() is emitted.
The action can be represented in the toolbar in different modes: as combo box only (Qtx.ComboItem) as set of modules buttons only (Qtx.Buttons) as combo box followed by the set of modules buttons (Qtx.All) as none (Qtx.None) By default, both combo box and buttons set are shown. Use method setMode() to change this behavior.
An action can be also added to the popup menu, but combo box is never shown in this case, only modules buttons.
| LightApp_ModuleAction::LightApp_ModuleAction | ( | const QString & | text, |
| QObject * | parent = 0 |
||
| ) |
Creates an module action with "neutral point" item described by text.
| text | "neutral point" item's text |
| parent | parent object |
References init().
| LightApp_ModuleAction::LightApp_ModuleAction | ( | const QString & | text, |
| const QIcon & | ico, | ||
| QObject * | parent = 0 |
||
| ) |
Creates an module action with "neutral point" item described by text and ico.
| text | "neutral point" item's text |
| ico | "neutral point" item's icon |
| parent | parent object |
References init().
| LightApp_ModuleAction::~LightApp_ModuleAction | ( | ) | [virtual] |
| QStringList LightApp_ModuleAction::modules | ( | ) | const |
References QtxActionSet.actions(), and mySet.
| QIcon LightApp_ModuleAction::moduleIcon | ( | const QString & | name | ) | const |
| name | module name |
References test_table.a, LightApp_ModuleAction.ActionSet.moduleAction(), and mySet.
| void LightApp_ModuleAction::setModuleIcon | ( | const QString & | name, |
| const QIcon & | ico | ||
| ) |
| name | module name |
| ico | new module icon |
References test_table.a, LightApp_ModuleAction.ActionSet.moduleAction(), mySet, and update().
| void LightApp_ModuleAction::insertModule | ( | const QString & | name, |
| const QIcon & | ico, | ||
| const int | idx = -1 |
||
| ) |
| name | module name |
| ico | module icon |
| idx | position in the module list (if -1, the module is added to the end of list) |
References test_table.a, QtxActionSet.insertAction(), mySet, QtxAction.QtxAction(), and update().
| void LightApp_ModuleAction::removeModule | ( | const QString & | name | ) |
| name | module name |
References LightApp_ModuleAction.ActionSet.moduleId(), mySet, QtxActionSet.removeAction(), and update().
| QString LightApp_ModuleAction::activeModule | ( | ) | const |
If there is no active module ("neutral point"), then the null string is returned.
References test_table.a, and active().
| void LightApp_ModuleAction::setActiveModule | ( | const QString & | name | ) |
To turn to the "neutral point" (no active module), pass empty string.
| name | new active module name |
References activate(), activeModule(), LightApp_ModuleAction.ActionSet.moduleId(), and mySet.
| void LightApp_ModuleAction::setMode | ( | const int | mode | ) |
| int LightApp_ModuleAction::mode | ( | ) | const |
| void LightApp_ModuleAction::addedTo | ( | QWidget * | w | ) | [protected, virtual] |
| void LightApp_ModuleAction::removedFrom | ( | QWidget * | w | ) | [protected, virtual] |
| void LightApp_ModuleAction::moduleActivated | ( | const QString & | name | ) | [signal] |
| name | module name (empty string for neutral point) |
| void LightApp_ModuleAction::init | ( | ) | [private] |
References All, myCombo, myMode, mySet, onChanged(), onComboActivated(), and onTriggered().
| void LightApp_ModuleAction::update | ( | ) | [private] |
| void LightApp_ModuleAction::update | ( | QtxComboBox * | cb | ) | [private] |
| cb | combo box |
References test_table.a, QtxActionSet.actions(), active(), LightApp_ModuleAction.ActionSet.moduleId(), mySet, QtxComboBox.setCurrentId(), and QtxComboBox.setId().
| QAction * LightApp_ModuleAction::active | ( | ) | const [private] |
References test_table.a, QtxActionSet.actions(), and mySet.
| void LightApp_ModuleAction::activate | ( | int | id, |
| bool | fromAction = true |
||
| ) | [private] |
| id | module identifier |
| fromAction | true if function is called from the module button |
References QtxActionSet.actions(), activeModule(), moduleActivated(), LightApp_ModuleAction.ActionSet.moduleId(), myCombo, mySet, QtxComboBox.setCurrentId(), and LightApp_ModuleAction.ComboAction.widgets().
| void LightApp_ModuleAction::onChanged | ( | ) | [private, slot] |
This slot is used to prevent making the parent action visible.
| void LightApp_ModuleAction::onTriggered | ( | int | id | ) | [private, slot] |
| id | module identifier |
References activate().
| void LightApp_ModuleAction::onComboActivated | ( | int | id | ) | [private, slot] |
| id | module identifier |
References activate().
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().
ComboAction* LightApp_ModuleAction.myCombo [private] |
ActionSet* LightApp_ModuleAction.mySet [private] |
int LightApp_ModuleAction.myMode [private] |