QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgsactionmanager.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsactionmanager.h
3
4 These classes store and control the management and execution of actions
5 associated with a particular QGIS layer. Actions are defined to be
6 external programs that are run with user-specified inputs that can
7 depend on the contents of layer attributes.
8
9 -------------------
10 begin : Oct 24 2004
11 copyright : (C) 2004 by Gavin Macaulay
12 email : gavin at macaulay dot co dot nz
13 ***************************************************************************/
14
15/***************************************************************************
16 * *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
21 * *
22 ***************************************************************************/
23
24#ifndef QGSACTIONMANAGER_H
25#define QGSACTIONMANAGER_H
26
27#include "qgis_core.h"
28#include <QString>
29#include <QIcon>
30#include <QObject>
31#include <QUuid>
32
34#include "qgsaction.h"
35
36class QDomNode;
37class QDomDocument;
38class QgsPythonUtils;
39class QgsVectorLayer;
40class QgsFeature;
41
51class CORE_EXPORT QgsActionManager: public QObject
52{
53 Q_OBJECT
54
55 public:
58
66 QUuid addAction( Qgis::AttributeActionType type, const QString &name, const QString &command, bool capture = false );
67
75 QUuid addAction( Qgis::AttributeActionType type, const QString &name, const QString &command, const QString &icon, bool capture = false );
76
80 void addAction( const QgsAction &action );
81
87 void removeAction( QUuid actionId );
88
99 void doAction( QUuid actionId, const QgsFeature &feature, int defaultValueIndex = 0, const QgsExpressionContextScope &scope = QgsExpressionContextScope() ) SIP_PYNAME( doActionFeature );
100
108 void doAction( QUuid actionId, const QgsFeature &feature, const QgsExpressionContext &context );
109
111 void clearActions();
112
119 QList<QgsAction> actions( const QString &actionScope = QString() ) const;
120
122 QgsVectorLayer *layer() const { return mLayer; }
123
125 bool writeXml( QDomNode &layer_node ) const;
126
128 bool readXml( const QDomNode &layer_node );
129
135 QgsAction action( QUuid id ) const;
136
142 QgsAction action( const QString &id ) const;
143
150 void setDefaultAction( const QString &actionScope, QUuid actionId );
151
158 QgsAction defaultAction( const QString &actionScope );
159
160 private:
161 QList<QgsAction> mActions;
162 QgsVectorLayer *mLayer = nullptr;
163 static void ( *smPythonExecute )( const QString & );
164
165 void runAction( const QgsAction &action );
166
167 QMap<QString, QUuid> mDefaultActions;
168
169 bool mOnNotifyConnected = false;
170
171 QgsExpressionContext createExpressionContext() const;
172
173 private slots:
174 void onNotifyRunActions( const QString &message );
175};
176
177#endif
AttributeActionType
Map layer action flags.
Definition: qgis.h:3062
Storage and management of actions associated with a layer.
QgsVectorLayer * layer() const
Returns the layer.
Utility class that encapsulates an action based on vector attributes.
Definition: qgsaction.h:37
Single scope for storing variables and functions for use within a QgsExpressionContext.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Represents a vector layer which manages a vector based data sets.
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81