QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
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
86 void removeAction( QUuid actionId );
87
98 void doAction( QUuid actionId, const QgsFeature &feature, int defaultValueIndex = 0, const QgsExpressionContextScope &scope = QgsExpressionContextScope() ) SIP_PYNAME( doActionFeature );
99
107 void doAction( QUuid actionId, const QgsFeature &feature, const QgsExpressionContext &context );
108
110 void clearActions();
111
117 QList<QgsAction> actions( const QString &actionScope = QString() ) const;
118
120 QgsVectorLayer *layer() const { return mLayer; }
121
123 bool writeXml( QDomNode &layer_node ) const;
124
126 bool readXml( const QDomNode &layer_node );
127
132 QgsAction action( QUuid id ) const;
133
139 QgsAction action( const QString &id ) const;
140
146 void setDefaultAction( const QString &actionScope, QUuid actionId );
147
153 QgsAction defaultAction( const QString &actionScope );
154
155 private:
156 QList<QgsAction> mActions;
157 QgsVectorLayer *mLayer = nullptr;
158 static void ( *smPythonExecute )( const QString & );
159
160 void runAction( const QgsAction &action );
161
162 QMap<QString, QUuid> mDefaultActions;
163
164 bool mOnNotifyConnected = false;
165
166 QgsExpressionContext createExpressionContext() const;
167
168 private slots:
169 void onNotifyRunActions( const QString &message );
170};
171
172#endif
AttributeActionType
Attribute action types.
Definition qgis.h:4331
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:58
Represents a vector layer which manages a vector based data sets.
#define SIP_PYNAME(name)
Definition qgis_sip.h:81