QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
Storage and management of actions associated with a layer. More...
#include <qgsactionmanager.h>
Public Member Functions | |
QgsActionManager (QgsVectorLayer *layer) | |
Constructor. More... | |
void | addAction (QgsAction::ActionType type, const QString &name, const QString &action, bool capture=false) |
Add an action with the given name and action details. More... | |
void | addAction (QgsAction::ActionType type, const QString &name, const QString &action, const QString &icon, bool capture=false) |
Add an action with the given name and action details. More... | |
void | addAction (const QgsAction &action) |
Add a new action to this list. More... | |
const QgsAction & | at (int idx) const |
Get the action at the specified index. More... | |
void | clearActions () |
Removes all actions. More... | |
int | defaultAction () const |
Returns the index of the default action, or -1 if no default action is available. More... | |
void | doAction (int index, const QgsFeature &feat, int defaultValueIndex=0, const QgsExpressionContextScope &scope=QgsExpressionContextScope()) |
Does the given action. More... | |
void | doAction (int index, const QgsFeature &feature, const QgsExpressionContext &context, const QMap< QString, QVariant > *substitutionMap=nullptr) |
Does the action using the expression engine to replace any embedded expressions in the action definition. More... | |
Q_DECL_DEPRECATED void | doAction (int index, const QgsFeature &feat, const QMap< QString, QVariant > *substitutionMap) |
Does the action using the expression builder to expand it and getting values from the passed feature attribute map. More... | |
Q_DECL_DEPRECATED QString | expandAction (QString action, const QgsAttributeMap &attributes, uint defaultValueIndex) |
Expands the given action, replacing all 's with the value as given. More... | |
Q_DECL_DEPRECATED QString | expandAction (const QString &action, QgsFeature &feat, const QMap< QString, QVariant > *substitutionMap=nullptr) |
Expands the given action using the expression builder This function currently replaces each expression between [% and %] placeholders in the action with the result of its evaluation on the feature passed as argument. More... | |
QgsVectorLayer * | layer () const |
Return the layer. More... | |
QList< QgsAction > | listActions () const |
Return a list of all actions. More... | |
QgsAction | operator[] (int idx) const |
Get the action at the specified index. More... | |
bool | readXML (const QDomNode &layer_node) |
Reads the actions in in XML format. More... | |
void | removeAction (int index) |
Remove an action at given index. More... | |
void | setDefaultAction (int actionNumber) |
Set the index of the default action. More... | |
int | size () const |
Get the number of actions managed by this. More... | |
bool | writeXML (QDomNode &layer_node, QDomDocument &doc) const |
Writes the actions out in XML format. More... | |
Static Public Member Functions | |
static Q_DECL_DEPRECATED void | setPythonExecute (void(*)(const QString &)) |
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 48 of file qgsactionmanager.h.
|
inline |
Constructor.
Definition at line 52 of file qgsactionmanager.h.
void QgsActionManager::addAction | ( | QgsAction::ActionType | type, |
const QString & | name, | ||
const QString & | action, | ||
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 43 of file qgsactionmanager.cpp.
void QgsActionManager::addAction | ( | QgsAction::ActionType | type, |
const QString & | name, | ||
const QString & | action, | ||
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 48 of file qgsactionmanager.cpp.
void QgsActionManager::addAction | ( | const QgsAction & | action | ) |
Add a new action to this list.
Definition at line 53 of file qgsactionmanager.cpp.
|
inline |
Get the action at the specified index.
Definition at line 165 of file qgsactionmanager.h.
void QgsActionManager::clearActions | ( | ) |
Removes all actions.
Definition at line 118 of file qgsactionmanager.cpp.
|
inline |
Returns the index of the default action, or -1 if no default action is available.
Definition at line 181 of file qgsactionmanager.h.
void QgsActionManager::doAction | ( | int | index, |
const QgsFeature & | feat, | ||
int | defaultValueIndex = 0 , |
||
const QgsExpressionContextScope & | scope = QgsExpressionContextScope() |
||
) |
Does the given action.
index | Index of the action |
feat | 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 66 of file qgsactionmanager.cpp.
void QgsActionManager::doAction | ( | int | index, |
const QgsFeature & | feature, | ||
const QgsExpressionContext & | context, | ||
const QMap< QString, QVariant > * | substitutionMap = nullptr |
||
) |
Does the action using the expression engine to replace any embedded expressions in the action definition.
index | action index |
feature | feature to run action for |
context | expression context to evalute expressions under |
substitutionMap | deprecated - kept for compatibility with projects, will be removed for 3.0 |
Definition at line 75 of file qgsactionmanager.cpp.
void QgsActionManager::doAction | ( | int | index, |
const QgsFeature & | feat, | ||
const QMap< QString, QVariant > * | substitutionMap | ||
) |
Does the action using the expression builder to expand it and getting values from the passed feature attribute map.
substitutionMap is used to pass custom substitutions, to replace each key in the map with the associated value
Definition at line 98 of file qgsactionmanager.cpp.
QString QgsActionManager::expandAction | ( | QString | action, |
const QgsAttributeMap & | attributes, | ||
uint | defaultValueIndex | ||
) |
Expands the given action, replacing all 's with the value as given.
Definition at line 175 of file qgsactionmanager.cpp.
QString QgsActionManager::expandAction | ( | const QString & | action, |
QgsFeature & | feat, | ||
const QMap< QString, QVariant > * | substitutionMap = nullptr |
||
) |
Expands the given action using the expression builder This function currently replaces each expression between [% and %] placeholders in the action with the result of its evaluation on the feature passed as argument.
Additional substitutions can be passed through the substitutionMap parameter
Definition at line 233 of file qgsactionmanager.cpp.
|
inline |
Return the layer.
Definition at line 129 of file qgsactionmanager.h.
Return a list of all actions.
Definition at line 123 of file qgsactionmanager.cpp.
|
inline |
Get the action at the specified index.
Definition at line 170 of file qgsactionmanager.h.
bool QgsActionManager::readXML | ( | const QDomNode & | layer_node | ) |
Reads the actions in in XML format.
Definition at line 315 of file qgsactionmanager.cpp.
void QgsActionManager::removeAction | ( | int | index | ) |
Remove an action at given index.
Definition at line 58 of file qgsactionmanager.cpp.
|
inline |
Set the index of the default action.
actionNumber | index of action which should be made the default for the layer |
Definition at line 188 of file qgsactionmanager.h.
|
static |
Definition at line 346 of file qgsactionmanager.cpp.
|
inline |
Get the number of actions managed by this.
Definition at line 160 of file qgsactionmanager.h.
bool QgsActionManager::writeXML | ( | QDomNode & | layer_node, |
QDomDocument & | doc | ||
) | const |
Writes the actions out in XML format.
Definition at line 293 of file qgsactionmanager.cpp.