QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
qgsmaplayeraction.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaplayeraction.h
3 ---------------------------
4 begin : January 2014
5 copyright : (C) 2014 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMAPLAYERACTION_H
17#define QGSMAPLAYERACTION_H
18
19#include "qgis.h"
20#include "qgis_gui.h"
21#include "qgis_sip.h"
22
23#include <QAction>
24#include <QList>
25#include <QMap>
26#include <QObject>
27#include <QPointer>
28
29class QgsFeature;
30class QgsMapLayer;
32
33
43class GUI_EXPORT QgsMapLayerAction : public QAction
44{
45 Q_OBJECT
46
47 public:
53 const QString &name,
54 QObject *parent SIP_TRANSFERTHIS,
56 const QIcon &icon = QIcon(),
58 );
59
62 const QString &name,
63 QObject *parent SIP_TRANSFERTHIS,
64 QgsMapLayer *layer,
66 const QIcon &icon = QIcon(),
68 );
69
72 const QString &name,
73 QObject *parent SIP_TRANSFERTHIS,
74 Qgis::LayerType layerType,
76 const QIcon &icon = QIcon(),
78 );
79
80 ~QgsMapLayerAction() override;
81
86
92 Q_DECL_DEPRECATED virtual bool canRunUsingLayer( QgsMapLayer *layer ) const SIP_DEPRECATED;
93
101 virtual bool canRunUsingLayer( QgsMapLayer *layer, const QgsMapLayerActionContext &context ) const;
102
108 Q_DECL_DEPRECATED virtual void triggerForFeatures( QgsMapLayer *layer, const QList<QgsFeature> &featureList ) SIP_DEPRECATED;
109
115 Q_DECL_DEPRECATED virtual void triggerForFeature( QgsMapLayer *layer, const QgsFeature &feature ) SIP_DEPRECATED;
116
122 Q_DECL_DEPRECATED virtual void triggerForLayer( QgsMapLayer *layer ) SIP_DEPRECATED;
123
129 virtual void triggerForFeatures( QgsMapLayer *layer, const QList<QgsFeature> &featureList, const QgsMapLayerActionContext &context );
130
136 virtual void triggerForFeature( QgsMapLayer *layer, const QgsFeature &feature, const QgsMapLayerActionContext &context );
137
143 virtual void triggerForLayer( QgsMapLayer *layer, const QgsMapLayerActionContext &context );
144
148 Qgis::MapLayerActionTargets targets() const { return mTargets; }
149
153 bool isEnabledOnlyWhenEditable() const;
154
155 signals:
156
161 Q_DECL_DEPRECATED void triggeredForFeatures( QgsMapLayer *layer, const QList<QgsFeature> &featureList ) SIP_DEPRECATED;
162
168 Q_DECL_DEPRECATED void triggeredForFeature( QgsMapLayer *layer, const QgsFeature &feature ) SIP_DEPRECATED;
169
175 Q_DECL_DEPRECATED void triggeredForLayer( QgsMapLayer *layer ) SIP_DEPRECATED;
176
182 void triggeredForFeaturesV2( QgsMapLayer *layer, const QList<QgsFeature> &featureList, const QgsMapLayerActionContext &context );
183
189 void triggeredForFeatureV2( QgsMapLayer *layer, const QgsFeature &feature, const QgsMapLayerActionContext &context );
190
197
198 private:
199 // true if action is only valid for a single layer
200 bool mSingleLayer = false;
201 // layer if action is only valid for a single layer
202 QgsMapLayer *mActionLayer = nullptr;
203
204 // true if action is only valid for a specific layer type
205 bool mSpecificLayerType = false;
206 // layer type if action is only valid for a specific layer type
208
209 // determine if the action can be run on layer and/or single feature and/or multiple features
211
213};
214
215
216#endif // QGSMAPLAYERACTION_H
QFlags< MapLayerActionTarget > MapLayerActionTargets
Map layer action targets.
Definition qgis.h:4797
LayerType
Types of layers that can be added to a map.
Definition qgis.h:206
@ Vector
Vector layer.
Definition qgis.h:207
QFlags< MapLayerActionFlag > MapLayerActionFlags
Map layer action flags.
Definition qgis.h:4821
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
Encapsulates the context in which a QgsMapLayerAction action is executed.
void triggeredForFeatureV2(QgsMapLayer *layer, const QgsFeature &feature, const QgsMapLayerActionContext &context)
Triggered when action has been run for a specific feature.
Q_DECL_DEPRECATED void triggeredForFeatures(QgsMapLayer *layer, const QList< QgsFeature > &featureList)
Triggered when action has been run for a specific list of features.
virtual Q_DECL_DEPRECATED bool canRunUsingLayer(QgsMapLayer *layer) const
Returns true if the action can run using the specified layer.
void triggeredForFeaturesV2(QgsMapLayer *layer, const QList< QgsFeature > &featureList, const QgsMapLayerActionContext &context)
Triggered when action has been run for a specific list of features.
Q_DECL_DEPRECATED void triggeredForFeature(QgsMapLayer *layer, const QgsFeature &feature)
Triggered when action has been run for a specific feature.
virtual Q_DECL_DEPRECATED void triggerForFeatures(QgsMapLayer *layer, const QList< QgsFeature > &featureList)
Triggers the action with the specified layer and list of feature.
void setTargets(Qgis::MapLayerActionTargets targets)
Define the targets of the action.
Q_DECL_DEPRECATED void triggeredForLayer(QgsMapLayer *layer)
Triggered when action has been run for a specific layer.
Qgis::MapLayerActionTargets targets() const
Returns availibity of action.
virtual Q_DECL_DEPRECATED void triggerForLayer(QgsMapLayer *layer)
Triggers the action with the specified layer.
void triggeredForLayerV2(QgsMapLayer *layer, const QgsMapLayerActionContext &context)
Triggered when action has been run for a specific layer.
QgsMapLayerAction(const QString &name, QObject *parent, Qgis::MapLayerActionTargets targets=Qgis::MapLayerActionTarget::AllActions, const QIcon &icon=QIcon(), Qgis::MapLayerActionFlags flags=Qgis::MapLayerActionFlags())
Creates a map layer action which can run on any layer.
Qgis::MapLayerActionFlags flags() const
Layer behavior flags.
virtual Q_DECL_DEPRECATED void triggerForFeature(QgsMapLayer *layer, const QgsFeature &feature)
Triggers the action with the specified layer and feature.
Base class for all map layer types.
Definition qgsmaplayer.h:83
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52