QGIS API Documentation 3.37.0-Master (4ace69f83af)
Loading...
Searching...
No Matches
qgsactionmenu.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsactionmenu.h
3 --------------------------------------
4 Date : 11.8.2014
5 Copyright : (C) 2014 Matthias Kuhn
6 Email : matthias at opengis dot ch
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 QGSACTIONMENU_H
17#define QGSACTIONMENU_H
18
19#include <QMenu>
20#include "qgis_sip.h"
21
22#include "qgsfeature.h"
24#include "qgsaction.h"
25#include "qgis_gui.h"
26
27class QgsMapLayer;
29class QgsVectorLayer;
32
38class GUI_EXPORT QgsActionMenu : public QMenu
39{
40 Q_OBJECT
41
42 public:
43
44 struct GUI_EXPORT ActionData
45 {
46
50 ActionData() = default;
51 ActionData( const QgsAction &action, QgsFeatureId featureId, QgsMapLayer *mapLayer );
52 ActionData( QgsMapLayerAction *action, QgsFeatureId featureId, QgsMapLayer *mapLayer );
53
55 QVariant actionData;
56 QgsFeatureId featureId = 0;
57 QgsMapLayer *mapLayer = nullptr;
58 };
59
69 explicit QgsActionMenu( QgsVectorLayer *layer, const QgsFeature &feature, const QString &actionScope, QWidget *parent SIP_TRANSFERTHIS = nullptr );
70
79 explicit QgsActionMenu( QgsVectorLayer *layer, QgsFeatureId fid, const QString &actionScope, QWidget *parent SIP_TRANSFERTHIS = nullptr );
80
88 void setActionContextGenerator( QgsMapLayerActionContextGenerator *generator );
89
96 void setFeature( const QgsFeature &feature );
97
103 void setMode( QgsAttributeEditorContext::Mode mode );
104
109 void setExpressionContextScope( const QgsExpressionContextScope &scope );
110
115 QgsExpressionContextScope expressionContextScope() const;
116
122 QList<QgsAction> menuActions();
123
129 bool isEmpty() const;
130
131 signals:
132 void reinit();
133
134 private slots:
135 void triggerAction();
136 void reloadActions();
137 void layerWillBeDeleted();
138
139 private:
140 void init();
141 QgsFeature feature();
142
143 QgsVectorLayer *mLayer = nullptr;
144 int mVisibleActionCount = 0;
145 QList<QgsAction> mActions;
146 QgsFeature mFeature;
147 QgsFeatureId mFeatureId;
148 QString mActionScope;
149 QgsExpressionContextScope mExpressionContextScope;
151
152 QgsMapLayerActionContextGenerator *mContextGenerator = nullptr;
153};
154
155
157
158#endif // QGSACTIONMENU_H
ActionType
Action types.
Definition qgis.h:3750
@ Invalid
Invalid.
Storage and management of actions associated with a layer.
This class is a menu that is populated automatically with the actions defined for a given layer.
Utility class that encapsulates an action based on vector attributes.
Definition qgsaction.h:37
@ SingleEditMode
Single edit mode, for editing a single feature.
Single scope for storing variables and functions for use within a QgsExpressionContext.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:56
An interface for objects which can create a QgsMapLayerActionContext.
An action which can run on map layers The class can be used in two manners:
Base class for all map layer types.
Definition qgsmaplayer.h:75
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
ActionData()=default
Constructor for ActionData.