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

Utility class that encapsulates an action based on vector attributes. More...

#include <qgsaction.h>

Public Member Functions

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

Detailed Description

Utility class that encapsulates an action based on vector attributes.

Definition at line 36 of file qgsaction.h.

Constructor & Destructor Documentation

◆ QgsAction() [1/4]

QgsAction::QgsAction ( )
default

Default constructor.

◆ QgsAction() [2/4]

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

Create a new QgsAction.

Parameters
typeThe type of this action
descriptionA human readable description string
commandThe action text. Its interpretation depends on the type
captureIf this is set to true, the output will be captured when an action is run
enabledOnlyWhenEditableif true then action is only enable in editmode. Not available in Python bindings.

Definition at line 54 of file qgsaction.h.

◆ QgsAction() [3/4]

QgsAction::QgsAction ( Qgis::AttributeActionType  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 
)
inline

Create a new QgsAction.

Parameters
typeThe type of this action
descriptionA human readable description string
actionThe action text. Its interpretation depends on the type
iconPath to an icon for this action
captureIf this is set to true, the output will be captured when an action is run
shortTitleA short string used to label user interface elements like buttons
actionScopesA set of scopes in which this action will be available
notificationMessageA particular message which reception will trigger the action
enabledOnlyWhenEditableif true then action is only enable in editmode. Not available in Python bindings.

Definition at line 76 of file qgsaction.h.

◆ QgsAction() [4/4]

QgsAction::QgsAction ( const QUuid &  id,
Qgis::AttributeActionType  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 
)
inline

Create a new QgsAction.

Parameters
idThe unique identifier of this action
typeThe type of this action
descriptionA human readable description string
actionThe action text. Its interpretation depends on the type
iconPath to an icon for this action
captureIf this is set to true, the output will be captured when an action is run
shortTitleA short string used to label user interface elements like buttons
actionScopesA set of scopes in which this action will be available
notificationMessageA particular message which reception will trigger the action
enabledOnlyWhenEditableif true then action is only enable in editmode. Not available in Python bindings.

Definition at line 103 of file qgsaction.h.

Member Function Documentation

◆ actionScopes()

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.

See also
QgsActionScope
Since
QGIS 3.0

Definition at line 319 of file qgsaction.cpp.

◆ capture()

bool QgsAction::capture ( ) const
inline

Whether to capture output for display when this action is run.

Definition at line 163 of file qgsaction.h.

◆ command()

QString QgsAction::command ( ) const
inline

Returns the command that is executed by this action.

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

Since
QGIS 3.0

Definition at line 150 of file qgsaction.h.

◆ expressionContextScope()

QgsExpressionContextScope QgsAction::expressionContextScope ( ) const

Returns an expression context scope used for running the action.

Since
QGIS 3.0

Definition at line 392 of file qgsaction.cpp.

◆ html()

QString QgsAction::html ( ) const

Returns an HTML table with the basic information about this action.

Since
QGIS 3.24

Definition at line 397 of file qgsaction.cpp.

◆ icon()

QIcon QgsAction::icon ( ) const
inline

The icon.

Definition at line 141 of file qgsaction.h.

◆ iconPath()

QString QgsAction::iconPath ( ) const
inline

The path to the icon.

Definition at line 138 of file qgsaction.h.

◆ id()

QUuid QgsAction::id ( ) const
inline

Returns a unique id for this action.

Since
QGIS 3.0

Definition at line 128 of file qgsaction.h.

◆ isEnabledOnlyWhenEditable()

bool QgsAction::isEnabledOnlyWhenEditable ( ) const
inline

Returns whether only enabled in editable mode.

Definition at line 167 of file qgsaction.h.

◆ isValid()

bool QgsAction::isValid ( ) const
inline

Returns true if this action was a default constructed one.

Since
QGIS 3.0

Definition at line 135 of file qgsaction.h.

◆ name()

QString QgsAction::name ( ) const
inline

The name of the action. This may be a longer description.

Definition at line 118 of file qgsaction.h.

◆ notificationMessage()

QString QgsAction::notificationMessage ( ) const
inline

Returns the notification message that triggers the action.

Since
QGIS 3.0

Definition at line 157 of file qgsaction.h.

◆ readXml()

void QgsAction::readXml ( const QDomNode &  actionNode)

Reads an XML definition from actionNode into this object.

Since
QGIS 3.0

Definition at line 329 of file qgsaction.cpp.

◆ run() [1/2]

void QgsAction::run ( const QgsExpressionContext expressionContext) const

Run this action.

Since
QGIS 3.0

Definition at line 275 of file qgsaction.cpp.

◆ run() [2/2]

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

Run this action.

Since
QGIS 3.0

Definition at line 78 of file qgsaction.cpp.

◆ runable()

bool QgsAction::runable ( ) const

Checks if the action is runable on the current platform.

Definition at line 41 of file qgsaction.cpp.

◆ setActionScopes()

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.

Since
QGIS 3.0

Definition at line 324 of file qgsaction.cpp.

◆ setCommand()

void QgsAction::setCommand ( const QString &  newCommand)

Sets the action command.

Since
QGIS 3.26

Definition at line 270 of file qgsaction.cpp.

◆ setEnabledOnlyWhenEditable()

void QgsAction::setEnabledOnlyWhenEditable ( bool  enable)
inline

Set whether the action is only enabled in editable mode.

Since
QGIS 3.16

Definition at line 174 of file qgsaction.h.

◆ setExpressionContextScope()

void QgsAction::setExpressionContextScope ( const QgsExpressionContextScope scope)

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

Since
QGIS 3.0

Definition at line 387 of file qgsaction.cpp.

◆ shortTitle()

QString QgsAction::shortTitle ( ) const
inline

The short title is used to label user interface elements like buttons.

Definition at line 121 of file qgsaction.h.

◆ type()

Qgis::AttributeActionType QgsAction::type ( ) const
inline

The action type.

Definition at line 160 of file qgsaction.h.

◆ writeXml()

void QgsAction::writeXml ( QDomNode &  actionsNode) const

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

Since
QGIS 3.0

Definition at line 363 of file qgsaction.cpp.


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