QGIS API Documentation  3.13.0-Master (5a3b1ced84)
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"
23 #include "qgsaction.h"
24 #include "qgis_gui.h"
25 #include "qgsattributeform.h"
26 
27 class QgsMapLayer;
28 class QgsMapLayerAction;
29 class QgsVectorLayer;
30 class QgsActionManager;
31 
37 class GUI_EXPORT QgsActionMenu : public QMenu
38 {
39  Q_OBJECT
40 
41  public:
43  {
46  AttributeAction
47  };
48 
49  struct GUI_EXPORT ActionData
50  {
51 
55  ActionData() = default;
56  ActionData( const QgsAction &action, QgsFeatureId featureId, QgsMapLayer *mapLayer );
57  ActionData( QgsMapLayerAction *action, QgsFeatureId featureId, QgsMapLayer *mapLayer );
58 
59  QgsActionMenu::ActionType actionType = Invalid;
60  QVariant actionData;
61  QgsFeatureId featureId = 0;
62  QgsMapLayer *mapLayer = nullptr;
63  };
64 
74  explicit QgsActionMenu( QgsVectorLayer *layer, const QgsFeature &feature, const QString &actionScope, QWidget *parent SIP_TRANSFERTHIS = nullptr );
75 
84  explicit QgsActionMenu( QgsVectorLayer *layer, QgsFeatureId fid, const QString &actionScope, QWidget *parent SIP_TRANSFERTHIS = nullptr );
85 
92  void setFeature( const QgsFeature &feature );
93 
99  void setMode( QgsAttributeEditorContext::Mode mode );
100 
106  void setExpressionContextScope( const QgsExpressionContextScope &scope );
107 
113  QgsExpressionContextScope expressionContextScope() const;
114 
120  QList<QgsAction> menuActions();
121 
122  signals:
123  void reinit();
124 
125  private slots:
126  void triggerAction();
127  void reloadActions();
128  void layerWillBeDeleted();
129 
130  private:
131  void init();
132  QgsFeature feature();
133 
134  QgsVectorLayer *mLayer = nullptr;
135  QList<QgsAction> mActions;
136  QgsFeature mFeature;
137  QgsFeatureId mFeatureId;
138  QString mActionScope;
139  QgsExpressionContextScope mExpressionContextScope;
141 };
142 
143 
145 
146 #endif // QGSACTIONMENU_H
Base class for all map layer types.
Definition: qgsmaplayer.h:80
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
Standard actions (defined by core or plugins)
Definition: qgsactionmenu.h:45
This class is a menu that is populated automatically with the actions defined for a given layer...
Definition: qgsactionmenu.h:37
Utility class that encapsulates an action based on vector attributes.
Definition: qgsaction.h:35
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
Storage and management of actions associated with a layer.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Represents a vector layer which manages a vector based data sets.
An action which can run on map layers.