QgsAction class

Utility class that encapsulates an action based on vector attributes.

Constructors, destructors, conversion operators

QgsAction() defaulted
Default constructor.
QgsAction(ActionType type, const QString& description, const QString& command, bool capture = false, bool enabledOnlyWhenEditable = false)
Create a new QgsAction.
QgsAction(ActionType type, const QString& description, const QString& action, const QString& icon, bool capture, const QString& shortTitle = QString(), const QSet<QString>& actionScopes = QSet<QString>(), const QString& notificationMessage = QString(), bool enabledOnlyWhenEditable = false)
Create a new QgsAction.

Public functions

auto actionScopes() const -> QSet<QString>
The action scopes define where an action will be available.
auto capture() const -> bool
Whether to capture output for display when this action is run.
auto command() const -> QString
Returns the command that is executed by this action.
auto expressionContextScope() const -> QgsExpressionContextScope
Returns an expression context scope used for running the action.
auto icon() const -> QIcon
The icon.
auto iconPath() const -> QString
The path to the icon.
auto id() const -> QUuid
Returns a unique id for this action.
auto isEnabledOnlyWhenEditable() const -> bool
Returns whether only enabled in editable mode.
auto isValid() const -> bool
Returns true if this action was a default constructed one.
auto name() const -> QString
The name of the action. This may be a longer description.
auto notificationMessage() const -> QString
Returns the notification message that triggers the action.
void readXml(const QDomNode& actionNode)
Reads an XML definition from actionNode into this object.
void run(QgsVectorLayer* layer, const QgsFeature& feature, const QgsExpressionContext& expressionContext) const
Run this action.
void run(const QgsExpressionContext& expressionContext) const
Run this action.
auto runable() const -> bool
Checks if the action is runable on the current platform.
void setActionScopes(const QSet<QString>& actionScopes)
The action scopes define where an action will be available.
void setExpressionContextScope(const QgsExpressionContextScope& scope)
Sets an expression context scope to use for running the action.
auto shortTitle() const -> QString
The short title is used to label user interface elements like buttons.
auto type() const -> ActionType
The action type.
void writeXml(QDomNode& actionsNode) const
Appends an XML definition for this action as a new child node to actionsNode.

Function documentation

QgsAction::QgsAction(ActionType type, const QString& description, const QString& command, bool capture = false, bool enabledOnlyWhenEditable = false)

Create a new QgsAction.

Parameters
type The type of this action
description A human readable description string
command The action text. Its interpretation depends on the type
capture If this is set to true, the output will be captured when an action is run
enabledOnlyWhenEditable if true then action is only enable in editmode

QgsAction::QgsAction(ActionType type, const QString& description, const QString& action, const QString& icon, bool capture, const QString& shortTitle = QString(), const QSet<QString>& actionScopes = QSet<QString>(), const QString& notificationMessage = QString(), bool enabledOnlyWhenEditable = false)

Create a new QgsAction.

Parameters
type The type of this action
description A human readable description string
action The action text. Its interpretation depends on the type
icon Path to an icon for this action
capture If this is set to true, the output will be captured when an action is run
shortTitle A short string used to label user interface elements like buttons
actionScopes A set of scopes in which this action will be available
notificationMessage A particular message which reception will trigger the action
enabledOnlyWhenEditable if true then action is only enable in editmode

QSet<QString> QgsAction::actionScopes() const

The action scopes define where an action will be available.

Action scopes may offer additional variables like the clicked coordinate.

QString QgsAction::command() const

Returns the command that is executed by this action.

How the content is interpreted depends on the type() and the actionScope().

QgsExpressionContextScope QgsAction::expressionContextScope() const

Returns an expression context scope used for running the action.

QUuid QgsAction::id() const

Returns a unique id for this action.

bool QgsAction::isValid() const

Returns true if this action was a default constructed one.

QString QgsAction::notificationMessage() const

Returns the notification message that triggers the action.

void QgsAction::readXml(const QDomNode& actionNode)

Reads an XML definition from actionNode into this object.

void QgsAction::run(QgsVectorLayer* layer, const QgsFeature& feature, const QgsExpressionContext& expressionContext) const

Run this action.

void QgsAction::run(const QgsExpressionContext& expressionContext) const

Run this action.

void QgsAction::setActionScopes(const QSet<QString>& actionScopes)

The action scopes define where an action will be available.

Action scopes may offer additional variables like the clicked coordinate.

void QgsAction::setExpressionContextScope(const QgsExpressionContextScope& scope)

Sets an expression context scope to use for running the action.

void QgsAction::writeXml(QDomNode& actionsNode) const

Appends an XML definition for this action as a new child node to actionsNode.