• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

KActionCollection Class Reference

A container for a set of QAction objects. More...

#include <kactioncollection.h>

Inheritance diagram for KActionCollection:

Inheritance graph
[legend]

List of all members.


Signals

QT_MOC_COMPAT void actionHighlighted (QAction *action)
void actionHovered (QAction *action)
void actionTriggered (QAction *action)
void inserted (QAction *action)
QT_MOC_COMPAT void removed (QAction *action)

Public Member Functions

QAction * action (const QString &name) const
QAction * action (int index) const
const QList< QActionGroup * > actionGroups () const
QList< QAction * > actions () const
const QList< QAction * > actionsWithoutGroup () const
template<class ActionType >
ActionType * add (const QString &name, const QObject *receiver=0, const char *member=0)
KAction * addAction (const QString &name, const QObject *receiver=0, const char *member=0)
KAction * addAction (KStandardAction::StandardAction actionType, const QString &name, const QObject *receiver=0, const char *member=0)
KAction * addAction (KStandardAction::StandardAction actionType, const QObject *receiver=0, const char *member=0)
KAction * addAction (const QString &name, KAction *action)
QAction * addAction (const QString &name, QAction *action)
void addAssociatedWidget (QWidget *widget)
QList< QWidget * > associatedWidgets () const
void associateWidget (QWidget *widget) const
void clear ()
void clearAssociatedWidgets ()
KComponentData componentData () const
QString configGroup () const
bool configIsGlobal () const
int count () const
void exportGlobalShortcuts (KConfigGroup *config, bool writeDefaults=false) const
void importGlobalShortcuts (KConfigGroup *config)
bool isEmpty () const
 KActionCollection (QObject *parent, const KComponentData &cData=KComponentData())
const KXMLGUIClient * parentGUIClient () const
void readSettings (KConfigGroup *config=0)
void removeAction (QAction *action)
void removeAssociatedWidget (QWidget *widget)
void setComponentData (const KComponentData &componentData)
void setConfigGlobal (bool global)
void setConfigGroup (const QString &group)
QAction * takeAction (QAction *action)
void writeSettings (KConfigGroup *config=0, bool writeDefaults=false, QAction *oneAction=0) const
virtual ~KActionCollection ()

Static Public Member Functions

static const QList
< KActionCollection * > & 
allCollections ()

Protected Slots

virtual void connectNotify (const char *signal)
virtual QT_MOC_COMPAT void slotActionHighlighted ()
virtual void slotActionTriggered ()

Properties

QString configGroup
bool configIsGlobal

Detailed Description

A container for a set of QAction objects.

KActionCollection manages a set of QAction objects. It allows them to be grouped for organized presentation of configuration to the user, saving + loading of configuration, and optionally for automatic plugging into specified widget(s).

Additionally, KActionCollection provides several convenience functions for locating named actions, and actions grouped by QActionGroup.

Note:
If you create your own action collection and need to assign shortcuts to the actions within, you have to call associateWidget() or addAssociatedWidget() to have them working.

Definition at line 56 of file kactioncollection.h.


Constructor & Destructor Documentation

KActionCollection::KActionCollection ( QObject *  parent,
const KComponentData &  cData = KComponentData() 
) [explicit]

Constructor.

Allows specification of a KComponentData other than the default global KComponentData, where needed.

Definition at line 98 of file kactioncollection.cpp.

KActionCollection::~KActionCollection (  )  [virtual]

Destructor.

Definition at line 119 of file kactioncollection.cpp.


Member Function Documentation

QAction * KActionCollection::action ( const QString &  name  )  const

Get the action with the given name from the action collection.

Parameters:
name Name of the KAction
Returns:
A pointer to the KAction in the collection which matches the parameters or null if nothing matches.

Definition at line 133 of file kactioncollection.cpp.

QAction * KActionCollection::action ( int  index  )  const

Return the QAction* at position "index" in the action collection.

This is equivalent to actions().value(index);

Definition at line 143 of file kactioncollection.cpp.

const QList< QActionGroup * > KActionCollection::actionGroups (  )  const

Returns the list of all QActionGroups associated with actions in this action collection.

Definition at line 202 of file kactioncollection.cpp.

QT_MOC_COMPAT void KActionCollection::actionHighlighted ( QAction *  action  )  [signal]

Indicates that action was highlighted (hovered over).

Deprecated:
Replaced by actionHovered(QAction* action);

void KActionCollection::actionHovered ( QAction *  action  )  [signal]

Indicates that action was hovered.

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

Returns the list of KActions which belong to this action collection.

The list is guaranteed to be in the same order the action were put into the collection.

Definition at line 188 of file kactioncollection.cpp.

const QList< QAction * > KActionCollection::actionsWithoutGroup (  )  const

Returns the list of KActions without an QAction::actionGroup() which belong to this action collection.

Definition at line 193 of file kactioncollection.cpp.

void KActionCollection::actionTriggered ( QAction *  action  )  [signal]

Indicates that action was triggered.

template<class ActionType >
ActionType* KActionCollection::add ( const QString &  name,
const QObject *  receiver = 0,
const char *  member = 0 
) [inline]

Creates a new action under the given name, adds it to the collection and connects the action's triggered(bool) signal to the specified receiver/member.

The receiver slot may accept either a bool or no parameters at all (i.e. slotTriggered(bool) or slotTriggered() ). The type of the action is specified by the template parameter ActionType.

NOTE: KDE prior to 4.2 connected the triggered() signal instead of the triggered(bool) signal.

Parameters:
name The internal name of the action (e.g. "file-open").
receiver The QObject to connect the triggered(bool) signal to. Leave 0 if no connection is desired.
member The SLOT to connect the triggered(bool) signal to. Leave 0 if no connection is desired.
Returns:
new action of the given type ActionType.

Definition at line 377 of file kactioncollection.h.

KAction * KActionCollection::addAction ( const QString &  name,
const QObject *  receiver = 0,
const char *  member = 0 
)

Creates a new action under the given name to the collection and connects the action's triggered() signal to the specified receiver/member.

The newly created action is returned.

Inserting an action that was previously inserted under a different name will replace the old entry, i.e. the action will not be available under the old name anymore but only under the new one.

Inserting an action under a name that is already used for another action will replace the other action in the collection.

Parameters:
name The name by which the action be retrieved again from the collection.
action The action to add.

Definition at line 358 of file kactioncollection.cpp.

KAction * KActionCollection::addAction ( KStandardAction::StandardAction  actionType,
const QString &  name,
const QObject *  receiver = 0,
const char *  member = 0 
)

Creates a new standard action, adds to the collection under the given name and connects the action's triggered() signal to the specified receiver/member.

The newly created action is also returned.

The action can be retrieved later from the collection by the specified name.

Definition at line 345 of file kactioncollection.cpp.

KAction * KActionCollection::addAction ( KStandardAction::StandardAction  actionType,
const QObject *  receiver = 0,
const char *  member = 0 
)

Creates a new standard action, adds it to the collection and connects the action's triggered() signal to the specified receiver/member.

The newly created action is also returned.

The action can be retrieved later from the collection by its standard name as per KStandardAction::stdName.

Definition at line 339 of file kactioncollection.cpp.

KAction * KActionCollection::addAction ( const QString &  name,
KAction *  action 
)

Definition at line 211 of file kactioncollection.cpp.

QAction * KActionCollection::addAction ( const QString &  name,
QAction *  action 
)

Add an action under the given name to the collection.

Inserting an action that was previously inserted under a different name will replace the old entry, i.e. the action will not be available under the old name anymore but only under the new one.

Inserting an action under a name that is already used for another action will replace the other action in the collection.

Parameters:
name The name by which the action be retrieved again from the collection.
action The action to add.

Definition at line 219 of file kactioncollection.cpp.

void KActionCollection::addAssociatedWidget ( QWidget *  widget  ) 

Associate all actions in this collection to the given widget, including any actions added after this association is made.

This does not change the action's shortcut context, so if you need to have the actions only trigger when the widget has focus, you'll need to set the shortcut context on each action to Qt::WidgetShortcut (or better still, Qt::WidgetWithChildrenShortcut with Qt 4.4+)

Definition at line 708 of file kactioncollection.cpp.

const QList< KActionCollection * > & KActionCollection::allCollections (  )  [static]

Access the list of all action collections in existence for this app.

Definition at line 695 of file kactioncollection.cpp.

QList< QWidget * > KActionCollection::associatedWidgets (  )  const

Return a list of all associated widgets.

Definition at line 761 of file kactioncollection.cpp.

void KActionCollection::associateWidget ( QWidget *  widget  )  const

Associate all actions in this collection to the given widget.

Unlike addAssociatedWidget, this method only adds all current actions in the collection to the given widget. Any action added after this call will not be added to the given widget automatically. So this is just a shortcut for a foreach loop and a widget->addAction call.

Definition at line 700 of file kactioncollection.cpp.

void KActionCollection::clear (  ) 

Clears the entire action collection, deleting all actions.

Definition at line 126 of file kactioncollection.cpp.

void KActionCollection::clearAssociatedWidgets (  ) 

Clear all associated widgets and remove the actions from those widgets.

Definition at line 766 of file kactioncollection.cpp.

KComponentData KActionCollection::componentData (  )  const

The KComponentData with which this class is associated.

Definition at line 178 of file kactioncollection.cpp.

QString KActionCollection::configGroup (  )  const

Returns the KConfig group with which settings will be loaded and saved.

bool KActionCollection::configIsGlobal (  )  const

Returns whether this action collection's configuration should be global to KDE ( true ), or specific to the application ( false ).

void KActionCollection::connectNotify ( const char *  signal  )  [protected, virtual, slot]

Overridden to perform connections when someone wants to know whether an action was highlighted or triggered.

Reimplemented from QObject.

Definition at line 671 of file kactioncollection.cpp.

int KActionCollection::count (  )  const

Returns the number of actions in the collection.

This is equivalent to actions().count().

Definition at line 149 of file kactioncollection.cpp.

void KActionCollection::exportGlobalShortcuts ( KConfigGroup *  config,
bool  writeDefaults = false 
) const

Export the current configurable global key associations to config.

Since:
4.1
Parameters:
config Config object to save to
writeDefaults set to true to write settings which are already at defaults.

Definition at line 444 of file kactioncollection.cpp.

void KActionCollection::importGlobalShortcuts ( KConfigGroup *  config  ) 

Import from config all configurable global key associations.

Since:
4.1
Parameters:
config Config object to read from

Definition at line 386 of file kactioncollection.cpp.

void KActionCollection::inserted ( QAction *  action  )  [signal]

Indicates that action was inserted into this action collection.

bool KActionCollection::isEmpty (  )  const

Returns whether the action collection is empty or not.

Definition at line 154 of file kactioncollection.cpp.

const KXMLGUIClient * KActionCollection::parentGUIClient (  )  const

The parent KXMLGUIClient, or null if not available.

Definition at line 183 of file kactioncollection.cpp.

void KActionCollection::readSettings ( KConfigGroup *  config = 0  ) 

Read all key associations from config.

If config is zero, read all key associations from the application's configuration file KGlobal::config(), in the group set by setConfigGroup().

Definition at line 413 of file kactioncollection.cpp.

void KActionCollection::removeAction ( QAction *  action  ) 

Removes an action from the collection and deletes it.

Parameters:
action The action to remove.

Definition at line 318 of file kactioncollection.cpp.

void KActionCollection::removeAssociatedWidget ( QWidget *  widget  ) 

Remove an association between all actions in this collection and the given widget, i.e.

remove those actions from the widget, and stop associating newly added actions as well.

Definition at line 718 of file kactioncollection.cpp.

QT_MOC_COMPAT void KActionCollection::removed ( QAction *  action  )  [signal]

Indicates that action was removed from this action collection.

Deprecated:

void KActionCollection::setComponentData ( const KComponentData &  componentData  ) 

Set the componentData associated with this action collection.

Warning:
Don't call this method on a KActionCollection that contains actions. This is not supported.
Parameters:
componentData the KComponentData which is to be associated with this action collection, or an invalid KComponentData instance to indicate the default KComponentData.

Definition at line 159 of file kactioncollection.cpp.

void KActionCollection::setConfigGlobal ( bool  global  ) 

Set whether this action collection's configuration should be global to KDE ( true ), or specific to the application ( false ).

Definition at line 381 of file kactioncollection.cpp.

void KActionCollection::setConfigGroup ( const QString &  group  ) 

Sets group as the KConfig group with which settings will be loaded and saved.

Definition at line 371 of file kactioncollection.cpp.

void KActionCollection::slotActionHighlighted (  )  [protected, virtual, slot]

For internal use only.

Deprecated:
Replaced by slotActionHovered();

Definition at line 643 of file kactioncollection.cpp.

void KActionCollection::slotActionTriggered (  )  [protected, virtual, slot]

Definition at line 636 of file kactioncollection.cpp.

QAction * KActionCollection::takeAction ( QAction *  action  ) 

Removes an action from the collection.

Parameters:
action the action to remove.

Definition at line 323 of file kactioncollection.cpp.

void KActionCollection::writeSettings ( KConfigGroup *  config = 0,
bool  writeDefaults = false,
QAction *  oneAction = 0 
) const

Write the current configurable key associations to config.

What the function does if config is zero depends. If this action collection belongs to a KXMLGuiClient the setting are saved to the kxmlgui definition file. If not the settings are written to the applications config file.

Note:
oneAction() and writeDefaults() have no meaning for the kxmlgui configuration file.
Parameters:
config Config object to save to, or null (see above)
writeDefaults set to true to write settings which are already at defaults.
oneAction pass an action here if you just want to save the values for one action, eg. if you know that action is the only one which has changed.

Definition at line 563 of file kactioncollection.cpp.


Property Documentation

QString KActionCollection::configGroup [read, write]

Definition at line 62 of file kactioncollection.h.

bool KActionCollection::configIsGlobal [read, write]

Definition at line 63 of file kactioncollection.h.


The documentation for this class was generated from the following files:
  • kactioncollection.h
  • kactioncollection.cpp

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal