QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
actions
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 "
qgsaction.h
"
29
#include "
qgsexpressioncontext.h
"
30
31
#include <QIcon>
32
#include <QObject>
33
#include <QString>
34
#include <QUuid>
35
36
class
QDomNode;
37
class
QDomDocument;
38
class
QgsPythonUtils;
39
class
QgsVectorLayer
;
40
class
QgsFeature
;
41
50
51
class
CORE_EXPORT
QgsActionManager
:
public
QObject
52
{
53
Q_OBJECT
54
55
public
:
57
QgsActionManager
(
QgsVectorLayer
*
layer
);
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
130
bool
readXml(
const
QDomNode &layer_node,
const
QgsReadWriteContext
&context =
QgsReadWriteContext
() );
131
136
QgsAction
action( QUuid
id
)
const
;
137
143
QgsAction
action(
const
QString &
id
)
const
;
144
150
void
setDefaultAction(
const
QString &actionScope, QUuid actionId );
151
157
QgsAction
defaultAction(
const
QString &actionScope );
158
159
private
:
160
QList<QgsAction> mActions;
161
QgsVectorLayer
*mLayer =
nullptr
;
162
static
void ( *smPythonExecute )(
const
QString & );
163
164
void
runAction(
const
QgsAction
&action );
165
166
QMap<QString, QUuid> mDefaultActions;
167
168
bool
mOnNotifyConnected =
false
;
169
170
QgsExpressionContext
createExpressionContext()
const
;
171
172
private
slots:
173
void
onNotifyRunActions(
const
QString &message );
174
};
175
176
#endif
Qgis::AttributeActionType
AttributeActionType
Attribute action types.
Definition
qgis.h:5215
QgsActionManager::removeAction
void removeAction(QUuid actionId)
Remove an action by its id.
Definition
qgsactionmanager.cpp:107
QgsActionManager::actions
QList< QgsAction > actions(const QString &actionScope=QString()) const
Returns a list of actions that are available in the given action scope.
Definition
qgsactionmanager.cpp:180
QgsActionManager::layer
QgsVectorLayer * layer() const
Returns the layer.
Definition
qgsactionmanager.h:120
QgsActionManager::doAction
void doAction(QUuid actionId, const QgsFeature &feature, int defaultValueIndex=0, const QgsExpressionContextScope &scope=QgsExpressionContextScope())
Does the given action.
Definition
qgsactionmanager.cpp:135
QgsActionManager::clearActions
void clearActions()
Removes all actions.
Definition
qgsactionmanager.cpp:168
QgsActionManager::addAction
QUuid addAction(Qgis::AttributeActionType type, const QString &name, const QString &command, bool capture=false)
Add an action with the given name and action details.
Definition
qgsactionmanager.cpp:54
QgsActionManager::QgsActionManager
QgsActionManager(QgsVectorLayer *layer)
Constructor.
Definition
qgsactionmanager.cpp:50
QgsActionManager::action
QgsAction action(QUuid id) const
Gets an action by its id.
Definition
qgsactionmanager.cpp:298
QgsAction
Utility class that encapsulates an action based on vector attributes.
Definition
qgsaction.h:38
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext.
Definition
qgsexpressioncontext.h:119
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition
qgsexpressioncontext.h:491
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition
qgsfeature.h:60
QgsReadWriteContext
A container for the context for various read/write operations on objects.
Definition
qgsreadwritecontext.h:38
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
SIP_PYNAME
#define SIP_PYNAME(name)
Definition
qgis_sip.h:88
qgsaction.h
qgsexpressioncontext.h
Generated on
for QGIS API Documentation by
1.17.0