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

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

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

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

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

References QtxActionSet.actions(), and mySet.

QIcon LightApp_ModuleAction::moduleIcon ( const QString &  name) const
Parameters:
namemodule name
Returns:
module icon
See also:
setModuleIcon()

References test_table.a, LightApp_ModuleAction.ActionSet.moduleAction(), and mySet.

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

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 
)
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 test_table.a, QtxActionSet.insertAction(), mySet, QtxAction.QtxAction(), and update().

void LightApp_ModuleAction::removeModule ( const QString &  name)
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 test_table.a, and active().

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().

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

References myMode.

void LightApp_ModuleAction::addedTo ( QWidget w) [protected, virtual]
Parameters:
wwidget (not used)

Reimplemented from QtxAction.

References myCombo, mySet, and update().

void LightApp_ModuleAction::removedFrom ( QWidget w) [protected, virtual]
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::moduleActivated ( const QString &  name) [signal]
Parameters:
namemodule name (empty string for neutral point)
void LightApp_ModuleAction::init ( ) [private]
void LightApp_ModuleAction::update ( ) [private]
void LightApp_ModuleAction::update ( QtxComboBox cb) [private]
QAction * LightApp_ModuleAction::active ( ) const [private]
Returns:
active module action or 0 if there is no active module

References test_table.a, QtxActionSet.actions(), and mySet.

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().

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]
Parameters:
idmodule identifier

References activate().

void LightApp_ModuleAction::onComboActivated ( int  id) [private, slot]
Parameters:
idmodule identifier

References activate().

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