An action, representing the list of modules to be inserted to the toolbar. More...
#include <LightApp_ModuleAction.h>
Classes | |
class | ActionSet |
Internal class to represent list of modules buttons. More... | |
class | ActivateEvent |
Internal class to represent custom event for transfer the activation item id. 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. More... | |
Public Member Functions | |
LightApp_ModuleAction (const QString &, QObject *=0) | |
Constructor. More... | |
LightApp_ModuleAction (const QString &, const QIcon &, QObject *=0) | |
Constructor. More... | |
virtual | ~LightApp_ModuleAction () |
Destructor. More... | |
QStringList | modules () const |
Get list of modules. More... | |
QIcon | moduleIcon (const QString &) const |
Get module icon. More... | |
void | setModuleIcon (const QString &, const QIcon &) |
Set module icon. More... | |
void | insertModule (const QString &, const QIcon &, const int=-1) |
Add module into the list. More... | |
void | removeModule (const QString &) |
Remove module from the list. More... | |
QString | activeModule () const |
Get active module. More... | |
void | setActiveModule (const QString &) |
Set active module. More... | |
void | setMode (const int) |
Set action display mode. More... | |
int | mode () const |
Get action display mode. More... | |
Public Member Functions inherited from QtxAction | |
QtxAction (QObject *=0, bool=false, const QString &=QString()) | |
Constructor. More... | |
QtxAction (const QString &, const QString &, int, QObject *, bool=false, const QString &=QString()) | |
Constructor. More... | |
QtxAction (const QString &, const QString &, const QKeySequence &, QObject *, bool=false, const QString &=QString()) | |
Constructor. More... | |
QtxAction (const QString &, const QIcon &, const QString &, int, QObject *, bool=false, const QString &=QString()) | |
Constructor. More... | |
QtxAction (const QString &, const QIcon &, const QString &, const QKeySequence &, QObject *, bool=false, const QString &=QString()) | |
Constructor. More... | |
virtual | ~QtxAction () |
Destructor. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Customize action events. More... | |
QString | shortcutActionName () const |
Return shortcut action name for the action. More... | |
void | setShortcutActionName (const QString &) |
Set shortcut action name to the action. More... | |
Protected Member Functions | |
virtual void | addedTo (QWidget *) |
Called when the action is added to the widget. More... | |
virtual void | removedFrom (QWidget *) |
Remove action from widget. More... | |
virtual bool | event (QEvent *) |
Perform delayed activation with specified id. More... | |
Protected Member Functions inherited from QtxAction | |
virtual void | customEvent (QEvent *) |
Process notification events. More... | |
Private Slots | |
void | onChanged () |
Called when action state is changed. More... | |
void | onTriggered (int) |
Called when module button is triggered. More... | |
void | onComboActivated (int) |
Called when combo box item is activated. More... | |
Private Member Functions | |
void | init () |
Initialize an action,. More... | |
void | update () |
Update an action. More... | |
void | update (QtxComboBox *) |
Update combo box. More... | |
QAction * | active () const |
Get an action corresponding to the active module. More... | |
void | activate (int, bool=true) |
Activate a module item. More... | |
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.
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().
|
virtual |
|
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().
|
private |
References QtxActionSet::actions(), and mySet.
QString LightApp_ModuleAction::activeModule | ( | ) | const |
If there is no active module ("neutral point"), then the null string is returned.
References active().
|
protectedvirtual |
|
protectedvirtual |
e | custom event |
true
if the event was processed successfully and false
otherwise. References activate().
|
private |
References All, myCombo, myMode, mySet, onChanged(), onComboActivated(), and onTriggered().
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 QtxActionSet::insertAction(), mySet, QtxAction::QtxAction(), and update().
int LightApp_ModuleAction::mode | ( | ) | const |
|
signal |
name | module name (empty string for neutral point) |
QIcon LightApp_ModuleAction::moduleIcon | ( | const QString & | name | ) | const |
name | module name |
References LightApp_ModuleAction::ActionSet::moduleAction(), and mySet.
QStringList LightApp_ModuleAction::modules | ( | ) | const |
References QtxActionSet::actions(), and mySet.
|
privateslot |
This slot is used to prevent making the parent action visible.
|
privateslot |
id | module identifier |
|
privateslot |
id | module identifier |
References activate().
|
protectedvirtual |
void LightApp_ModuleAction::removeModule | ( | const QString & | name | ) |
name | module name |
References LightApp_ModuleAction::ActionSet::moduleId(), mySet, QtxActionSet::removeAction(), and update().
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 | ) |
name | module name |
ico | new module icon |
References LightApp_ModuleAction::ActionSet::moduleAction(), mySet, and update().
|
private |
|
private |
cb | combo box |
References QtxActionSet::actions(), active(), LightApp_ModuleAction::ActionSet::moduleId(), mySet, QtxComboBox::setCurrentId(), and QtxComboBox::setId().
|
private |
|
private |
|
private |