QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
Public Member Functions | List of all members
QgsActionManager Class Reference

Storage and management of actions associated with a layer. More...

#include <qgsactionmanager.h>

Inheritance diagram for QgsActionManager:
Inheritance graph
[legend]

Public Member Functions

 QgsActionManager (QgsVectorLayer *layer)
 Constructor. More...
 
QgsAction action (const QString &id) const
 Gets an action by its id. More...
 
QgsAction action (QUuid id) const
 Gets an action by its id. More...
 
QList< QgsActionactions (const QString &actionScope=QString()) const
 Returns a list of actions that are available in the given action scope. More...
 
void addAction (const QgsAction &action)
 Add a new action to this list. More...
 
QUuid addAction (Qgis::AttributeActionType type, const QString &name, const QString &command, bool capture=false)
 Add an action with the given name and action details. More...
 
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. More...
 
void clearActions ()
 Removes all actions. More...
 
QgsAction defaultAction (const QString &actionScope)
 Each scope can have a default action. More...
 
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. More...
 
void doAction (QUuid actionId, const QgsFeature &feature, int defaultValueIndex=0, const QgsExpressionContextScope &scope=QgsExpressionContextScope())
 Does the given action. More...
 
QgsVectorLayerlayer () const
 Returns the layer. More...
 
bool readXml (const QDomNode &layer_node)
 Reads the actions in in XML format. More...
 
void removeAction (QUuid actionId)
 Remove an action by its id. More...
 
void setDefaultAction (const QString &actionScope, QUuid actionId)
 Each scope can have a default action. More...
 
bool writeXml (QDomNode &layer_node) const
 Writes the actions out in XML format. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ QgsActionManager()

QgsActionManager::QgsActionManager ( QgsVectorLayer layer)

Constructor.

Definition at line 44 of file qgsactionmanager.cpp.

Member Function Documentation

◆ action() [1/2]

QgsAction QgsActionManager::action ( const QString &  id) const

Gets an action by its id.

Since
QGIS 3.28

Definition at line 294 of file qgsactionmanager.cpp.

◆ action() [2/2]

QgsAction QgsActionManager::action ( QUuid  id) const

Gets an action by its id.

Since
QGIS 3.0

Definition at line 283 of file qgsactionmanager.cpp.

◆ actions()

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.

Since
QGIS 3.0

Definition at line 174 of file qgsactionmanager.cpp.

◆ addAction() [1/3]

void QgsActionManager::addAction ( const QgsAction action)

Add a new action to this list.

Definition at line 62 of file qgsactionmanager.cpp.

◆ addAction() [2/3]

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 48 of file qgsactionmanager.cpp.

◆ addAction() [3/3]

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 55 of file qgsactionmanager.cpp.

◆ clearActions()

void QgsActionManager::clearActions ( )

Removes all actions.

Definition at line 162 of file qgsactionmanager.cpp.

◆ defaultAction()

QgsAction QgsActionManager::defaultAction ( const QString &  actionScope)

Each scope can have a default action.

This will be saved in the project file.

Since
QGIS 3.0

Definition at line 310 of file qgsactionmanager.cpp.

◆ doAction() [1/2]

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.

Parameters
actionIdaction id
featurefeature to run action for
contextexpression context to evaluate expressions under

Definition at line 141 of file qgsactionmanager.cpp.

◆ doAction() [2/2]

void QgsActionManager::doAction ( QUuid  actionId,
const QgsFeature feature,
int  defaultValueIndex = 0,
const QgsExpressionContextScope scope = QgsExpressionContextScope() 
)

Does the given action.

Parameters
actionIdaction id
featurefeature to run action for
defaultValueIndexindex of the field to be used if the action has a $currfield placeholder.
scopeexpression context scope to add during expression evaluation
Note
available in Python bindings as doActionFeature

Definition at line 129 of file qgsactionmanager.cpp.

◆ layer()

QgsVectorLayer * QgsActionManager::layer ( ) const
inline

Returns the layer.

Definition at line 122 of file qgsactionmanager.h.

◆ readXml()

bool QgsActionManager::readXml ( const QDomNode &  layer_node)

Reads the actions in in XML format.

Definition at line 256 of file qgsactionmanager.cpp.

◆ removeAction()

void QgsActionManager::removeAction ( QUuid  actionId)

Remove an action by its id.

Since
QGIS 3.0

Definition at line 101 of file qgsactionmanager.cpp.

◆ setDefaultAction()

void QgsActionManager::setDefaultAction ( const QString &  actionScope,
QUuid  actionId 
)

Each scope can have a default action.

This will be saved in the project file.

Since
QGIS 3.0

Definition at line 305 of file qgsactionmanager.cpp.

◆ writeXml()

bool QgsActionManager::writeXml ( QDomNode &  layer_node) const

Writes the actions out in XML format.

Definition at line 236 of file qgsactionmanager.cpp.


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