@@ -34,62 +34,71 @@ class GUI_EXPORT QgsMapLayerAction : public QAction
34
34
Q_FLAGS ( Availability )
35
35
36
36
public:
37
- enum AvailabityFlag
37
+ enum Target
38
38
{
39
39
Layer = 1 ,
40
- Feature = 2 ,
41
- LayerAndFeature = Layer | Feature
40
+ SingleFeature = 2 ,
41
+ MultipleFeatures = 4 ,
42
+ AllActions = Layer | SingleFeature | MultipleFeatures
42
43
};
43
- Q_DECLARE_FLAGS ( Availability, AvailabityFlag )
44
+ Q_DECLARE_FLAGS ( Targets, Target )
45
+
46
+ // ! Creates a map layer action which can run on any layer
47
+ // ! @note using AllActions as a target probably does not make a lot of sense. This default action was settled for API compatiblity reasons.
48
+ QgsMapLayerAction ( QString name, QObject *parent, Targets targets = AllActions );
44
49
45
- /* *Creates a map layer action which can run on any layer*/
46
- QgsMapLayerAction ( QString name, QObject *parent, Availability availability = LayerAndFeature );
47
50
/* *Creates a map layer action which can run only on a specific layer*/
48
- QgsMapLayerAction ( QString name, QObject *parent, QgsMapLayer* layer, Availability availability = LayerAndFeature );
51
+ QgsMapLayerAction ( QString name, QObject *parent, QgsMapLayer* layer, Targets targets = AllActions );
52
+
49
53
/* *Creates a map layer action which can run on a specific type of layer*/
50
- QgsMapLayerAction ( QString name, QObject *parent, QgsMapLayer::LayerType layerType, Availability availability = LayerAndFeature );
54
+ QgsMapLayerAction ( QString name, QObject *parent, QgsMapLayer::LayerType layerType, Targets targets = AllActions );
51
55
52
56
~QgsMapLayerAction ();
53
57
54
58
/* * True if action can run using the specified layer */
55
59
bool canRunUsingLayer ( QgsMapLayer* layer ) const ;
56
60
57
- /* * Triggers the action with the specified layer and feature. This also emits the triggeredForLayer( QgsMapLayer *)
58
- * and triggered() slots */
59
- void triggerForFeature ( QgsMapLayer* layer, QgsFeature* feature );
61
+ /* * Triggers the action with the specified layer and list of feature. */
62
+ void triggerForFeatures ( QgsMapLayer* layer, QList<const QgsFeature*> featureList );
60
63
61
- /* * Triggers the action with the specified layer. This also emits the triggered() slot. */
64
+ /* * Triggers the action with the specified layer and feature. */
65
+ void triggerForFeature ( QgsMapLayer* layer, const QgsFeature* feature );
66
+
67
+ /* * Triggers the action with the specified layer. */
62
68
void triggerForLayer ( QgsMapLayer* layer );
63
69
64
- /* * Define the availibility of the action */
65
- void setAvailability ( Availability availability ) {mAvailability = availability ;}
70
+ /* * Define the targets of the action */
71
+ void setTargets ( Targets targets ) {mTargets = targets ;}
66
72
/* * Return availibity of action */
67
- Availability availability () const {return mAvailability ;}
73
+ Targets targets () const {return mTargets ;}
68
74
69
75
signals:
76
+ /* * Triggered when action has been run for a specific list of features */
77
+ void triggeredForFeatures ( QgsMapLayer* layer, QList<const QgsFeature*> featureList );
78
+
70
79
/* * Triggered when action has been run for a specific feature */
71
- void triggeredForFeature ( QgsMapLayer* layer, QgsFeature* feature );
80
+ void triggeredForFeature ( QgsMapLayer* layer, const QgsFeature* feature );
72
81
73
82
/* * Triggered when action has been run for a specific layer */
74
83
void triggeredForLayer ( QgsMapLayer* layer );
75
84
76
85
private:
77
86
78
- // true if action is only valid for a single layer
87
+ // true if action is only valid for a single layer
79
88
bool mSingleLayer ;
80
- // layer if action is only valid for a single layer
89
+ // layer if action is only valid for a single layer
81
90
QgsMapLayer* mActionLayer ;
82
91
83
- // true if action is only valid for a specific layer type
92
+ // true if action is only valid for a specific layer type
84
93
bool mSpecificLayerType ;
85
- // layer type if action is only valid for a specific layer type
94
+ // layer type if action is only valid for a specific layer type
86
95
QgsMapLayer::LayerType mLayerType ;
87
96
88
- // determine if the action can be run on feature and/or layer
89
- Availability mAvailability ;
97
+ // determine if the action can be run on layer and/or single feature and/or multiple features
98
+ Targets mTargets ;
90
99
};
91
100
92
- Q_DECLARE_OPERATORS_FOR_FLAGS ( QgsMapLayerAction::Availability )
101
+ Q_DECLARE_OPERATORS_FOR_FLAGS ( QgsMapLayerAction::Targets )
93
102
94
103
/* *
95
104
* This class tracks map layer actions
@@ -108,7 +117,7 @@ class GUI_EXPORT QgsMapLayerActionRegistry : public QObject
108
117
void addMapLayerAction ( QgsMapLayerAction * action );
109
118
110
119
/* *Returns the map layer actions which can run on the specified layer*/
111
- QList<QgsMapLayerAction *> mapLayerActions ( QgsMapLayer* layer );
120
+ QList<QgsMapLayerAction *> mapLayerActions ( QgsMapLayer* layer, QgsMapLayerAction::Targets targets = QgsMapLayerAction::AllActions );
112
121
113
122
/* *Removes a map layer action from the registry*/
114
123
bool removeMapLayerAction ( QgsMapLayerAction *action );
0 commit comments