QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Storage and management of actions associated with a layer. More...
#include <qgsactionmanager.h>
Public Member Functions | |
QgsActionManager (QgsVectorLayer *layer) | |
Constructor. | |
QgsAction | action (const QString &id) const |
Gets an action by its id. | |
QgsAction | action (QUuid id) const |
Gets an action by its id. | |
QList< QgsAction > | actions (const QString &actionScope=QString()) const |
Returns a list of actions that are available in the given action scope. | |
void | addAction (const QgsAction &action) |
Add a new action to this list. | |
QUuid | addAction (Qgis::AttributeActionType type, const QString &name, const QString &command, bool capture=false) |
Add an action with the given name and action details. | |
QUuid | addAction (Qgis::AttributeActionType type, const QString &name, const QString &command, const QString &icon, bool capture=false) |
Add an action with the given name and action details. | |
void | clearActions () |
Removes all actions. | |
QgsAction | defaultAction (const QString &actionScope) |
Each scope can have a default action. | |
void | doAction (QUuid actionId, const QgsFeature &feature, const QgsExpressionContext &context) |
Does the action using the expression engine to replace any embedded expressions in the action definition. | |
void | doAction (QUuid actionId, const QgsFeature &feature, int defaultValueIndex=0, const QgsExpressionContextScope &scope=QgsExpressionContextScope()) |
Does the given action. | |
QgsVectorLayer * | layer () const |
Returns the layer. | |
bool | readXml (const QDomNode &layer_node) |
Reads the actions in in XML format. | |
void | removeAction (QUuid actionId) |
Remove an action by its id. | |
void | setDefaultAction (const QString &actionScope, QUuid actionId) |
Each scope can have a default action. | |
bool | writeXml (QDomNode &layer_node) const |
Writes the actions out in XML format. | |
Storage and management of actions associated with a layer.
Actions can trigger custom code or applications to be executed based on attributes of a given feature.
Definition at line 51 of file qgsactionmanager.h.
QgsActionManager::QgsActionManager | ( | QgsVectorLayer * | layer | ) |
Constructor.
Definition at line 45 of file qgsactionmanager.cpp.
QgsAction QgsActionManager::action | ( | const QString & | id | ) | const |
QgsAction QgsActionManager::action | ( | QUuid | id | ) | const |
Gets an action by its id.
Definition at line 284 of file qgsactionmanager.cpp.
QList< QgsAction > QgsActionManager::actions | ( | const QString & | actionScope = QString() | ) | const |
Returns a list of actions that are available in the given action scope.
If no action scope is provided, all actions will be returned.
Definition at line 175 of file qgsactionmanager.cpp.
void QgsActionManager::addAction | ( | const QgsAction & | action | ) |
Add a new action to this list.
Definition at line 63 of file qgsactionmanager.cpp.
QUuid QgsActionManager::addAction | ( | Qgis::AttributeActionType | type, |
const QString & | name, | ||
const QString & | command, | ||
bool | capture = false |
||
) |
Add an action with the given name and action details.
Will happily have duplicate names and actions. If capture is true
, when running the action using doAction(), any stdout from the process will be captured and displayed in a dialog box.
Definition at line 49 of file qgsactionmanager.cpp.
QUuid QgsActionManager::addAction | ( | Qgis::AttributeActionType | type, |
const QString & | name, | ||
const QString & | command, | ||
const QString & | icon, | ||
bool | capture = false |
||
) |
Add an action with the given name and action details.
Will happily have duplicate names and actions. If capture is true
, when running the action using doAction(), any stdout from the process will be captured and displayed in a dialog box.
Definition at line 56 of file qgsactionmanager.cpp.
void QgsActionManager::clearActions | ( | ) |
Removes all actions.
Definition at line 163 of file qgsactionmanager.cpp.
QgsAction QgsActionManager::defaultAction | ( | const QString & | actionScope | ) |
Each scope can have a default action.
This will be saved in the project file.
Definition at line 311 of file qgsactionmanager.cpp.
void QgsActionManager::doAction | ( | QUuid | actionId, |
const QgsFeature & | feature, | ||
const QgsExpressionContext & | context | ||
) |
Does the action using the expression engine to replace any embedded expressions in the action definition.
actionId | action id |
feature | feature to run action for |
context | expression context to evaluate expressions under |
Definition at line 142 of file qgsactionmanager.cpp.
void QgsActionManager::doAction | ( | QUuid | actionId, |
const QgsFeature & | feature, | ||
int | defaultValueIndex = 0 , |
||
const QgsExpressionContextScope & | scope = QgsExpressionContextScope() |
||
) |
Does the given action.
actionId | action id |
feature | feature to run action for |
defaultValueIndex | index of the field to be used if the action has a $currfield placeholder. |
scope | expression context scope to add during expression evaluation |
Definition at line 130 of file qgsactionmanager.cpp.
|
inline |
Returns the layer.
Definition at line 120 of file qgsactionmanager.h.
bool QgsActionManager::readXml | ( | const QDomNode & | layer_node | ) |
Reads the actions in in XML format.
Definition at line 257 of file qgsactionmanager.cpp.
void QgsActionManager::removeAction | ( | QUuid | actionId | ) |
Remove an action by its id.
Definition at line 102 of file qgsactionmanager.cpp.
void QgsActionManager::setDefaultAction | ( | const QString & | actionScope, |
QUuid | actionId | ||
) |
Each scope can have a default action.
This will be saved in the project file.
Definition at line 306 of file qgsactionmanager.cpp.
bool QgsActionManager::writeXml | ( | QDomNode & | layer_node | ) | const |
Writes the actions out in XML format.
Definition at line 237 of file qgsactionmanager.cpp.