Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LightApp_ModuleAction Class Reference

An action, representing the list of modules to be inserted to the toolbar. More...

#include <LightApp_ModuleAction.h>

Inheritance diagram for LightApp_ModuleAction:
Inheritance graph

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...
 
QActionactive () const
 Get an action corresponding to the active module. More...
 
void activate (int, bool=true)
 Activate a module item. More...
 

Private Attributes

ComboActionmyCombo
 
ActionSetmySet
 
int myMode
 

Detailed Description

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.

Member Enumeration Documentation

anonymous enum
Enumerator
None 
Buttons 
ComboItem 
All 

Constructor & Destructor Documentation

LightApp_ModuleAction::LightApp_ModuleAction ( const QString &  text,
QObject parent = 0 
)

Creates an module action with "neutral point" item described by text.

Parameters
text"neutral point" item's text
parentparent 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.

Parameters
text"neutral point" item's text
ico"neutral point" item's icon
parentparent object

References init().

LightApp_ModuleAction::~LightApp_ModuleAction ( )
virtual

Member Function Documentation

void LightApp_ModuleAction::activate ( int  id,
bool  fromAction = true 
)
private
Parameters
idmodule identifier
fromActiontrue 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().

QAction * LightApp_ModuleAction::active ( ) const
private
Returns
active module action or 0 if there is no active module

References QtxActionSet::actions(), and mySet.

QString LightApp_ModuleAction::activeModule ( ) const

If there is no active module ("neutral point"), then the null string is returned.

Returns
active module name
See Also
setActiveModule()

References active().

void LightApp_ModuleAction::addedTo ( QWidget w)
protectedvirtual
Parameters
wwidget (not used)

Reimplemented from QtxAction.

References myCombo, mySet, and update().

bool LightApp_ModuleAction::event ( QEvent e)
protectedvirtual
Parameters
ecustom event
Returns
true if the event was processed successfully and false otherwise.

References activate().

void LightApp_ModuleAction::init ( )
private
void LightApp_ModuleAction::insertModule ( const QString &  name,
const QIcon &  ico,
const int  idx = -1 
)
Parameters
namemodule name
icomodule icon
idxposition in the module list (if -1, the module is added to the end of list)
See Also
removeModule()

References QtxActionSet::insertAction(), mySet, QtxAction::QtxAction(), and update().

int LightApp_ModuleAction::mode ( ) const
Parameters
modeaction display mode
See Also
setMode()

References myMode.

void LightApp_ModuleAction::moduleActivated ( const QString &  name)
signal
Parameters
namemodule name (empty string for neutral point)
QIcon LightApp_ModuleAction::moduleIcon ( const QString &  name) const
Parameters
namemodule name
Returns
module icon
See Also
setModuleIcon()

References LightApp_ModuleAction::ActionSet::moduleAction(), and mySet.

QStringList LightApp_ModuleAction::modules ( ) const
Returns
modules names list

References QtxActionSet::actions(), and mySet.

void LightApp_ModuleAction::onChanged ( )
privateslot

This slot is used to prevent making the parent action visible.

void LightApp_ModuleAction::onComboActivated ( int  id)
privateslot
Parameters
idmodule identifier
void LightApp_ModuleAction::onTriggered ( int  id)
privateslot
Parameters
idmodule identifier

References activate().

void LightApp_ModuleAction::removedFrom ( QWidget w)
protectedvirtual
Parameters
wwidget (menu or toolbar)
Returns
true if the action is removed successfully and false otherwise.
See Also
addTo()

Reimplemented from QtxAction.

References myCombo, and mySet.

void LightApp_ModuleAction::removeModule ( const QString &  name)
void LightApp_ModuleAction::setActiveModule ( const QString &  name)

To turn to the "neutral point" (no active module), pass empty string.

Parameters
namenew active module name
See Also
activeModule()

References activate(), activeModule(), LightApp_ModuleAction::ActionSet::moduleId(), and mySet.

void LightApp_ModuleAction::setMode ( const int  mode)

Action can be represented in the toolbar as combo box only (Qtx::ComboItem) set of modules buttons only (Qtx::Buttons) combo box followed by the set of modules buttons (Qtx::All) none (Qtx::None)

Parameters
modeaction display mode
See Also
mode()

References mode(), myMode, and update().

void LightApp_ModuleAction::setModuleIcon ( const QString &  name,
const QIcon &  ico 
)
Parameters
namemodule name
iconew module icon
See Also
moduleIcon()

References LightApp_ModuleAction::ActionSet::moduleAction(), mySet, and update().

void LightApp_ModuleAction::update ( QtxComboBox cb)
private

Member Data Documentation

ComboAction* LightApp_ModuleAction::myCombo
private
int LightApp_ModuleAction::myMode
private
ActionSet* LightApp_ModuleAction::mySet
private

The documentation for this class was generated from the following files: