Version: 9.12.0
QtxActionSet Class Reference

An action class which is represented in the menu bar (or toolbar) as a group of items (which can be customized). More...

#include <QtxActionSet.h>

Inheritance diagram for QtxActionSet:
Inheritance graph

Signals

void triggered (int)
 Emitted when some child action is activated by the user. More...
 
void triggered (QAction *)
 Emitted when some child action is activated by the user. More...
 

Public Member Functions

 QtxActionSet (QObject *=0)
 Constructor. More...
 
virtual ~QtxActionSet ()
 Destructor. More...
 
QList< QAction * > actions () const
 Get list of child actions. More...
 
void setActions (const QList< QAction * > &)
 Assign child actions. More...
 
void insertActions (const QList< QAction * > &, const int=-1)
 Insert actions at the specified position. More...
 
int insertAction (QAction *, const int id=-1, const int=-1)
 Insert action at the specified position. More...
 
int insertAction (const QString &, const int id=-1, const int=-1)
 Insert action at the specified position. More...
 
int insertAction (const QString &, const QIcon &, const int id=-1, const int=-1)
 Insert action at the specified position. More...
 
void removeAction (QAction *)
 Remove specified action. More...
 
void removeAction (const int)
 Remove specified action. More...
 
void clear ()
 Remove all actions. 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 this action set is added to the menu bar (or toolbar). More...
 
virtual void removedFrom (QWidget *)
 Called when this action set is removed from the menu bar (or toolbar). More...
 
virtual void actionAdded (QAction *)
 Notify that action was added. More...
 
virtual void actionRemoved (QAction *)
 Notify that action was removed. More...
 
QActionaction (int) const
 Get action by specified identifier. More...
 
int actionId (QAction *) const
 Get action identifier for the action. More...
 
void setActionId (QAction *, const int)
 Set action identifier for the action. More...
 
virtual bool isEmptyAction () const
 Check if the action itself should be invisible (only child action are shown) More...
 
virtual void updateAction ()
 Update action set. More...
 
virtual void updateAction (QWidget *)
 Update action set for the specified widget. More...
 
- Protected Member Functions inherited from QtxAction
virtual void customEvent (QEvent *)
 Process notification events. More...
 

Private Types

typedef QList< QAction * > ActionList
 

Private Slots

void onChanged ()
 Called when action is changed. More...
 
void onActionTriggered (bool=false)
 Called when some action is activated by the user. More...
 

Private Member Functions

int generateId () const
 Getneration unique action identifier. More...
 

Private Attributes

ActionList mySet
 actions list More...
 

Detailed Description

An action class which is represented in the menu bar (or toolbar) as a group of items (which can be customized).

Example: Window menu in the MDI application with menu items:

  • Cascade
  • Tile vertically
  • Tile horizontally
  • <separator>
  • Window1
  • Window2

Member Typedef Documentation

◆ ActionList

Constructor & Destructor Documentation

◆ QtxActionSet()

QtxActionSet::QtxActionSet ( QObject parent = 0)

Constructor.

Parameters
parentparent object

References onChanged().

◆ ~QtxActionSet()

QtxActionSet::~QtxActionSet ( )
virtual

Destructor.

Member Function Documentation

◆ action()

QAction * QtxActionSet::action ( int  id) const
protected

Get action by specified identifier.

Parameters
idaction ID
Returns
action or 0 if it is not found

References actionId(), and mySet.

◆ actionAdded()

void QtxActionSet::actionAdded ( QAction )
protectedvirtual

Notify that action was added.

Reimplemented in QtxMultiAction, and QtxActionGroup.

◆ actionId()

int QtxActionSet::actionId ( QAction a) const
protected

Get action identifier for the action.

Parameters
aaction
Returns
action ID or -1 if it is not found

◆ actionRemoved()

void QtxActionSet::actionRemoved ( QAction )
protectedvirtual

Notify that action was removed.

Reimplemented in QtxMultiAction, and QtxActionGroup.

◆ actions()

QList< QAction * > QtxActionSet::actions ( ) const

Get list of child actions.

Returns
list of assigned actions

References mySet.

◆ addedTo()

void QtxActionSet::addedTo ( QWidget w)
protectedvirtual

Called when this action set is added to the menu bar (or toolbar).

Parameters
wwidget this action set is added to

Reimplemented from QtxAction.

Reimplemented in QtxWorkstackAction, and QtxWorkspaceAction.

References QtxAction::addedTo(), and updateAction().

◆ clear()

void QtxActionSet::clear ( )

Remove all actions.

An actions list is cleared and all actions are destroyed.

References mySet, and updateAction().

◆ generateId()

int QtxActionSet::generateId ( ) const
private

Getneration unique action identifier.

Returns
generation action ID

References mySet.

◆ insertAction() [1/3]

int QtxActionSet::insertAction ( const QString &  txt,
const int  id = -1,
const int  index = -1 
)

Insert action at the specified position.

If id < 0, it is generated automatically.

Parameters
txtaction text
idaction ID
indexposition in the action list (if < 0, item is appended to the end of list)
Returns
action identifier

References insertAction(), and QtxAction::QtxAction().

◆ insertAction() [2/3]

int QtxActionSet::insertAction ( const QString &  txt,
const QIcon &  icon,
const int  id = -1,
const int  index = -1 
)

Insert action at the specified position.

If id < 0, it is generated automatically.

Parameters
txtaction text
iconaction icon
idaction ID
indexposition in the action list (if < 0, item is appended to the end of list)
Returns
action identifier

References insertAction(), and QtxAction::QtxAction().

◆ insertAction() [3/3]

int QtxActionSet::insertAction ( QAction a,
const int  id = -1,
const int  index = -1 
)

Insert action at the specified position.

If id < 0, it is generated automatically.

Parameters
aaction being inserted
idaction ID
indexposition in the action list (if < 0, item is appended to the end of list)
Returns
action identifier

References actionAdded(), generateId(), mySet, onActionTriggered(), triggered(), and updateAction().

◆ insertActions()

void QtxActionSet::insertActions ( const QList< QAction * > &  lst,
const int  index = -1 
)

Insert actions at the specified position.

Parameters
lstlist of actions
indexposition in the action list (if < 0, items are appended to the end of list)

References generateId(), mySet, onActionTriggered(), triggered(), and updateAction().

◆ isEmptyAction()

bool QtxActionSet::isEmptyAction ( ) const
protectedvirtual

Check if the action itself should be invisible (only child action are shown)

Returns
true if the action itself should be visible

Reimplemented in QtxMultiAction, and QtxActionGroup.

◆ onActionTriggered

void QtxActionSet::onActionTriggered ( bool  = false)
privateslot

Called when some action is activated by the user.

Parameters
ontoggled state (not used)

References actionId(), and triggered().

◆ onChanged

void QtxActionSet::onChanged ( )
privateslot

Called when action is changed.

Update action state.

References isEmptyAction().

◆ removeAction() [1/2]

void QtxActionSet::removeAction ( const int  id)

Remove specified action.

An action is removed from the action list and destroyed.

Parameters
idaction identifier

References action(), and removeAction().

◆ removeAction() [2/2]

void QtxActionSet::removeAction ( QAction a)

Remove specified action.

An action is removed from the action list and destroyed.

Parameters
aaction to be removed.

References actionRemoved(), and mySet.

◆ removedFrom()

void QtxActionSet::removedFrom ( QWidget w)
protectedvirtual

Called when this action set is removed from the menu bar (or toolbar).

Parameters
wwidget this action set is removed from

Reimplemented from QtxAction.

Reimplemented in QtxWorkstackAction, and QtxWorkspaceAction.

References QtxAction::removedFrom(), and updateAction().

◆ setActionId()

void QtxActionSet::setActionId ( QAction a,
const int  id 
)
protected

Set action identifier for the action.

Parameters
aaction
idnew action ID

◆ setActions()

void QtxActionSet::setActions ( const QList< QAction * > &  lst)

Assign child actions.

Parameters
lstlist of actions

References insertActions(), and mySet.

◆ triggered [1/2]

void QtxActionSet::triggered ( int  id)
signal

Emitted when some child action is activated by the user.

Parameters
actionID

◆ triggered [2/2]

void QtxActionSet::triggered ( QAction a)
signal

Emitted when some child action is activated by the user.

Parameters
aaction being activated

◆ updateAction() [1/2]

void QtxActionSet::updateAction ( )
protectedvirtual

Update action set.

Reimplemented in QtxMultiAction.

◆ updateAction() [2/2]

void QtxActionSet::updateAction ( QWidget w)
protectedvirtual

Update action set for the specified widget.

Parameters
wa widget this action is added to

Reimplemented in QtxMultiAction, and QtxActionGroup.

References mySet.

Member Data Documentation

◆ mySet

ActionList QtxActionSet::mySet
private

actions list


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