A ready to use implementation of the IActionProvider interface. More...
#include <ActionProvider.h>
Public Member Functions | |
QList< QtilitiesCategory > | actionCategories () const |
QList< QtilitiesCategory > | actionGroupCategories () const |
A list of all action group categories provided through this interface. | |
QMap< QActionGroup *, QtilitiesCategory > | actionGroupMap (QActionGroup *action_group) const |
A map with the actions and action categories of all the action groups provided through the interface. | |
QList< QActionGroup * > | actionGroups () const |
A list of all the action groups provided through the interface. | |
QMap< QAction *, QtilitiesCategory > | actionMap (IActionProvider::ActionFilterFlags action_filter=NoFilter, const QtilitiesCategory &category_filter=QtilitiesCategory()) const |
A map with the action and action category of all the actions provided through the interface. | |
QAction * | addAction (QAction *action, const QtilitiesCategory &category_filter=QtilitiesCategory()) |
Adds an action to the object implementing this interface and returns it if added successfully. Returns 0 otherwise. | |
QActionGroup * | addActionGroup (QActionGroup *action_group, const QtilitiesCategory &category_filter=QtilitiesCategory()) |
Adds an action group to the object implementing this interface and returns it if added successfully. Returns 0 otherwise. | |
void | addActions (QList< QAction * > actions, const QtilitiesCategory &category=QtilitiesCategory()) |
Adds an list of actions to the object implementing this interface. | |
void | disableAllActions () |
Disables all actions registered in this action provider. | |
void | enableAllActions () |
Enables all actions registered in this action provider. | |
QList< QAction * > | findActionsByObjectName (const QString &match_string, Qt::MatchFlags match_flags=Qt::MatchFixedString) |
Finds an action with the specified objectName() and returns a reference to it, otherwise return 0 if it was not found. | |
QList< QAction * > | findActionsByText (const QString &match_string, Qt::MatchFlags match_flags=Qt::MatchFixedString) |
Finds an action that has the specified text and returns a reference to it, otherwise return 0 if it was not found. | |
QObject * | objectBase () |
Returns the QObject* base of the interface. | |
const QObject * | objectBase () const |
Returns a const QObject* base of the interface. | |
void | removeAction (QAction *action) |
Removes an action from the action provider. Does not delete the action. | |
void | removeActionCategory (const QtilitiesCategory &category) |
Removes a complete category from the action provider. Does not delete the actions. | |
Public Member Functions inherited from Qtilities::CoreGui::Interfaces::IActionProvider | |
virtual QList< QAction * > | actions (ActionFilterFlags action_filter=NoFilter, const QtilitiesCategory &category_filter=QtilitiesCategory("Hello World!")) const =0 |
A list of all the actions provided through the interface. | |
Public Member Functions inherited from Qtilities::Core::Interfaces::IObjectBase | |
QString | objectOriginID () const |
Allows interfaces to provide some sort of source identification. | |
void | setObjectOriginID (const QString &object_origin_id) |
Allows setting of the object source ID of this interface implementation. |
Additional Inherited Members | |
Public Types inherited from Qtilities::CoreGui::Interfaces::IActionProvider | |
enum | ActionFilter { NoFilter = 0, FilterDisabled = 1, FilterHidden = 2 } |
Action Filter Flag. More... |
A ready to use implementation of the IActionProvider interface.
In the development done using Qtilities the problem was often faced where an object (which is not a QWidget) needed to provide some actions to another object. To solve the problem the concept of action providers was introducted. Any object can become an action provider and other objects (a toolbar for example) can query the object for actions that it provides, or it can add actions to the object, in the same way that you can add actions to QWidget.
Action providers allow actions to be grouped into categories and allows you to do specialized queries on the actions provided by an object, for example you can get only a list of actions which are enabled. The Qtilities::CoreGui::Interfaces::IActionProvider interface defines the interface that action providers use and the Qtilities::CoreGui::ActionProvider class provides a default implementation of this interface.
Many classes in Qtilities are action providers and they provide actions through their actionProvider()
function. An example is Qtilities::CoreGui::ObserverWidget, which provides all the actions that is created and allows you to get for example all the enabled actions for the current observer context. If you use an ObserverWidget
that displays its actions in an action toolbar, you can easily add new actions to the toolbar where toolbars are created for each action category. For example:
|
virtual |
The ActionProvider implementation of the IActionProvider interface will always return a sorted category list in ascending order. That is: starts with 'AAA' and ends with 'ZZZ'.
Implements Qtilities::CoreGui::Interfaces::IActionProvider.
|
virtual |
A map with the actions and action categories of all the action groups provided through the interface.
This function can be used to visualize the actions provided through this interface.
action_group | The action group for which the map is required. If no group is specified, all actions in all action groups are returned in the map. |
Implements Qtilities::CoreGui::Interfaces::IActionProvider.
|
virtual |
A map with the action and action category of all the actions provided through the interface.
This function can be used to visualize the actions provided through this interface.
action_filter | The action filter flags to be used to filter returned actions. |
category_filter | Only actions which have a category which appears in the category filter will be part of the returned list. |
Implements Qtilities::CoreGui::Interfaces::IActionProvider.
|
virtual |
Adds an action to the object implementing this interface and returns it if added successfully. Returns 0 otherwise.
action | The action to be added. |
category | The category under which the action should be added. By default no category is assigned. The first level of hierarchy in the category is defined by the first item in the list, and the last level of hierarchy by the last item in the list. |
Implements Qtilities::CoreGui::Interfaces::IActionProvider.
|
virtual |
Adds an action group to the object implementing this interface and returns it if added successfully. Returns 0 otherwise.
action_group | The action group to be added. |
category | The category under which the actions in the action group should be added. By default no category is assigned. The first level of hierarchy in the category is defined by the first item in the list, and the last level of hierarchy by the last item in the list. |
Implements Qtilities::CoreGui::Interfaces::IActionProvider.
|
virtual |
Adds an list of actions to the object implementing this interface.
actions | The actions to be added. |
category | The category under which the actions should be added. By default no category is assigned. The first level of hierarchy in the category is defined by the first item in the list, and the last level of hierarchy by the last item in the list. |
Implements Qtilities::CoreGui::Interfaces::IActionProvider.
|
virtual |
Finds an action with the specified objectName() and returns a reference to it, otherwise return 0 if it was not found.
match_string | The match string to match. |
match_flags | The match flags to use during matching. At present Qt::MatchExactly, Qt::MatchFixedString, Qt::MatchContains, Qt::MatchStartsWith, Qt::MatchEndsWith, Qt::MatchCaseSensitive is supported. |
Implements Qtilities::CoreGui::Interfaces::IActionProvider.
|
virtual |
Finds an action that has the specified text and returns a reference to it, otherwise return 0 if it was not found.
match_string | The match string to match. |
match_flags | The match flags to use during matching. All match flags except Qt::MatchRecursive and Qt::MatchWrap can be used. |
Implements Qtilities::CoreGui::Interfaces::IActionProvider.
|
inlinevirtual |
Returns a const QObject* base of the interface.
This function can be used in const methods, but make sure that you don't modify things that should stay const. An example where this is used is when we want to get a property on an object in a const method. This is a const operation.
Implements Qtilities::Core::Interfaces::IObjectBase.
Qtilities : Reference Documentation | Back to top |
Copyright © 2009-2013, Jaco Naudé
|