Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

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

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

Member Typedef Documentation

Constructor & Destructor Documentation

QtxActionSet::QtxActionSet ( QObject parent = 0)
Parameters
parentparent object

References onChanged().

QtxActionSet::~QtxActionSet ( )
virtual

Member Function Documentation

QAction * QtxActionSet::action ( int  id) const
protected
Parameters
idaction ID
Returns
action or 0 if it is not found

References actionId(), and mySet.

void QtxActionSet::actionAdded ( QAction )
protectedvirtual

Reimplemented in QtxActionGroup, and QtxMultiAction.

int QtxActionSet::actionId ( QAction a) const
protected
Parameters
aaction
Returns
action ID or -1 if it is not found
void QtxActionSet::actionRemoved ( QAction )
protectedvirtual

Reimplemented in QtxActionGroup, and QtxMultiAction.

QList< QAction * > QtxActionSet::actions ( ) const
Returns
list of assigned actions

References mySet.

void QtxActionSet::addedTo ( QWidget w)
protectedvirtual
Parameters
wwidget this action set is added to

Reimplemented from QtxAction.

Reimplemented in QtxWorkspaceAction, and QtxWorkstackAction.

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

void QtxActionSet::clear ( )

An actions list is cleared and all actions are destroyed.

References mySet, and updateAction().

int QtxActionSet::generateId ( ) const
private
Returns
generation action ID

References mySet.

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

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

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

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

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

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

void QtxActionSet::insertActions ( const QList< QAction * > &  lst,
const int  index = -1 
)
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().

bool QtxActionSet::isEmptyAction ( ) const
protectedvirtual
Returns
true if the action itself should be visible

Reimplemented in QtxActionGroup, and QtxMultiAction.

void QtxActionSet::onActionTriggered ( bool  = false)
privateslot
Parameters
ontoggled state (not used)

References actionId(), and triggered().

void QtxActionSet::onChanged ( )
privateslot

Update action state.

References isEmptyAction().

void QtxActionSet::removeAction ( QAction a)

An action is removed from the action list and destroyed.

Parameters
aaction to be removed.

References actionRemoved(), and mySet.

void QtxActionSet::removeAction ( const int  id)

An action is removed from the action list and destroyed.

Parameters
idaction identifier

References action(), and removeAction().

void QtxActionSet::removedFrom ( QWidget w)
protectedvirtual
Parameters
wwidget this action set is removed from

Reimplemented from QtxAction.

Reimplemented in QtxWorkspaceAction, and QtxWorkstackAction.

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

void QtxActionSet::setActionId ( QAction a,
const int  id 
)
protected
Parameters
aaction
idnew action ID
void QtxActionSet::setActions ( const QList< QAction * > &  lst)
Parameters
lstlist of actions

References insertActions(), and mySet.

void QtxActionSet::triggered ( int  id)
signal
Parameters
actionID
void QtxActionSet::triggered ( QAction a)
signal
Parameters
aaction being activated
void QtxActionSet::updateAction ( )
protectedvirtual

Reimplemented in QtxMultiAction.

void QtxActionSet::updateAction ( QWidget w)
protectedvirtual
Parameters
wa widget this action is added to

Reimplemented in QtxActionGroup, and QtxMultiAction.

References mySet.

Member Data Documentation

ActionList QtxActionSet::mySet
private

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