Class: QgsActionManager

class qgis.core.QgsActionManager(layer: QgsVectorLayer)

Bases: PyQt5.QtCore.QObject

Constructor

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.

Methods

action

Gets an action by its id.

actions

Returns a list of actions that are available in the given action scope.

addAction

Add an action with the given name and action details.

childEvent

clearActions

Removes all actions

connectNotify

customEvent

defaultAction

Each scope can have a default action.

disconnectNotify

doAction

Does the action using the expression engine to replace any embedded expressions in the action definition.

doActionFeature

Does the given action.

isSignalConnected

layer

Returns the layer

readXml

Reads the actions in in XML format

receivers

removeAction

Remove an action by its id.

sender

senderSignalIndex

setDefaultAction

Each scope can have a default action.

timerEvent

writeXml

Writes the actions out in XML format

action(self, id: QUuid) QgsAction

Gets an action by its id.

New in version 3.0.

Parameters

id (QUuid) –

Return type

QgsAction

actions(self, actionScope: str = '') List[QgsAction]

Returns a list of actions that are available in the given action scope. If no action scope is provided, all actions will be returned.

New in version 3.0.

Parameters

actionScope (str = '') –

Return type

List[QgsAction]

addAction(self, type: QgsAction.ActionType, name: str, command: str, capture: bool = False) QUuid

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.

addAction(self, type: QgsAction.ActionType, name: str, command: str, icon: str, capture: bool = False) -> QUuid 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.

addAction(self, action: QgsAction) Add a new action to this list.

Parameters
Return type

QUuid

childEvent(self, QChildEvent)
clearActions(self)

Removes all actions

connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
defaultAction(self, actionScope: str) QgsAction

Each scope can have a default action. This will be saved in the project file.

New in version 3.0.

Parameters

actionScope (str) –

Return type

QgsAction

disconnectNotify(self, QMetaMethod)
doAction(self, actionId: QUuid, feature: QgsFeature, context: QgsExpressionContext)

Does the action using the expression engine to replace any embedded expressions in the action definition.

Parameters
  • actionId (QUuid) – action id

  • feature (QgsFeature) – feature to run action for

  • context (QgsExpressionContext) – expression context to evaluate expressions under

doActionFeature(self, actionId: QUuid, feature: QgsFeature, defaultValueIndex: int = 0, scope: QgsExpressionContextScope = QgsExpressionContextScope())

Does the given action.

Parameters
  • actionId (QUuid) – action id

  • feature (QgsFeature) – feature to run action for

  • defaultValueIndex (int = 0) – index of the field to be used if the action has a $currfield placeholder.

  • scope (QgsExpressionContextScope = QgsExpressionContextScope()) – expression context scope to add during expression evaluation

Note

available in Python bindings as doActionFeature

isSignalConnected(self, QMetaMethod) bool
layer(self) QgsVectorLayer

Returns the layer

Return type

QgsVectorLayer

readXml(self, layer_node: QDomNode) bool

Reads the actions in in XML format

Parameters

layer_node (QDomNode) –

Return type

bool

receivers(self, PYQT_SIGNAL) int
removeAction(self, actionId: QUuid)

Remove an action by its id.

New in version 3.0.

Parameters

actionId (QUuid) –

sender(self) QObject
senderSignalIndex(self) int
setDefaultAction(self, actionScope: str, actionId: QUuid)

Each scope can have a default action. This will be saved in the project file.

New in version 3.0.

Parameters
  • actionScope (str) –

  • actionId (QUuid) –

timerEvent(self, QTimerEvent)
writeXml(self, layer_node: QDomNode) bool

Writes the actions out in XML format

Parameters

layer_node (QDomNode) –

Return type

bool