QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 <QObject>
20#include "qgis_sip.h"
21#include <QList>
22#include <QMap>
23#include <QAction>
24#include <QPointer>
25
26#include "qgis.h"
27#include "qgis_gui.h"
28
29class QgsFeature;
30class QgsMapLayer;
32
33
41class GUI_EXPORT QgsMapLayerAction : public QAction
42{
43 Q_OBJECT
44
45 public:
50 QgsMapLayerAction( const QString &name, QObject *parent SIP_TRANSFERTHIS, Qgis::MapLayerActionTargets targets = Qgis::MapLayerActionTarget::AllActions, const QIcon &icon = QIcon(), Qgis::MapLayerActionFlags flags = Qgis::MapLayerActionFlags() );
51
53 QgsMapLayerAction( const QString &name, QObject *parent SIP_TRANSFERTHIS, QgsMapLayer *layer, Qgis::MapLayerActionTargets targets = Qgis::MapLayerActionTarget::AllActions, const QIcon &icon = QIcon(), Qgis::MapLayerActionFlags flags = Qgis::MapLayerActionFlags() );
54
56 QgsMapLayerAction( const QString &name, QObject *parent SIP_TRANSFERTHIS, Qgis::LayerType layerType, Qgis::MapLayerActionTargets targets = Qgis::MapLayerActionTarget::AllActions, const QIcon &icon = QIcon(), Qgis::MapLayerActionFlags flags = Qgis::MapLayerActionFlags() );
57
58 ~QgsMapLayerAction() override;
59
63 Qgis::MapLayerActionFlags flags() const;
64
70 Q_DECL_DEPRECATED virtual bool canRunUsingLayer( QgsMapLayer *layer ) const SIP_DEPRECATED;
71
79 virtual bool canRunUsingLayer( QgsMapLayer *layer, const QgsMapLayerActionContext &context ) const;
80
86 Q_DECL_DEPRECATED virtual void triggerForFeatures( QgsMapLayer *layer, const QList<QgsFeature> &featureList ) SIP_DEPRECATED;
87
93 Q_DECL_DEPRECATED virtual void triggerForFeature( QgsMapLayer *layer, const QgsFeature &feature ) SIP_DEPRECATED;
94
100 Q_DECL_DEPRECATED virtual void triggerForLayer( QgsMapLayer *layer ) SIP_DEPRECATED;
101
107 virtual void triggerForFeatures( QgsMapLayer *layer, const QList<QgsFeature> &featureList, const QgsMapLayerActionContext &context );
108
114 virtual void triggerForFeature( QgsMapLayer *layer, const QgsFeature &feature, const QgsMapLayerActionContext &context );
115
121 virtual void triggerForLayer( QgsMapLayer *layer, const QgsMapLayerActionContext &context );
122
124 void setTargets( Qgis::MapLayerActionTargets targets ) { mTargets = targets; }
126 Qgis::MapLayerActionTargets targets() const { return mTargets; }
127
131 bool isEnabledOnlyWhenEditable() const;
132
133 signals:
134
139 Q_DECL_DEPRECATED void triggeredForFeatures( QgsMapLayer *layer, const QList<QgsFeature> &featureList ) SIP_DEPRECATED;
140
146 Q_DECL_DEPRECATED void triggeredForFeature( QgsMapLayer *layer, const QgsFeature &feature ) SIP_DEPRECATED;
147
153 Q_DECL_DEPRECATED void triggeredForLayer( QgsMapLayer *layer ) SIP_DEPRECATED;
154
160 void triggeredForFeaturesV2( QgsMapLayer *layer, const QList<QgsFeature> &featureList, const QgsMapLayerActionContext &context );
161
167 void triggeredForFeatureV2( QgsMapLayer *layer, const QgsFeature &feature, const QgsMapLayerActionContext &context );
168
175
176 private:
177 // true if action is only valid for a single layer
178 bool mSingleLayer = false;
179 // layer if action is only valid for a single layer
180 QgsMapLayer *mActionLayer = nullptr;
181
182 // true if action is only valid for a specific layer type
183 bool mSpecificLayerType = false;
184 // layer type if action is only valid for a specific layer type
186
187 // determine if the action can be run on layer and/or single feature and/or multiple features
189
191};
192
193
194#endif // QGSMAPLAYERACTION_H
QFlags< MapLayerActionTarget > MapLayerActionTargets
Map layer action targets.
Definition qgis.h:4350
LayerType
Types of layers that can be added to a map.
Definition qgis.h:169
@ Vector
Vector layer.
QFlags< MapLayerActionFlag > MapLayerActionFlags
Map layer action flags.
Definition qgis.h:4373
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Encapsulates the context in which a QgsMapLayerAction action is executed.
An action which can run on map layers The class can be used in two manners:
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.
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.
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.
void triggeredForLayerV2(QgsMapLayer *layer, const QgsMapLayerActionContext &context)
Triggered when action has been run for a specific layer.
Base class for all map layer types.
Definition qgsmaplayer.h:76
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53