QGIS API Documentation  3.6.0-Noosa (5873452)
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 #include <QSignalMapper>
22 
23 #include "qgsfeature.h"
24 #include "qgsaction.h"
25 #include "qgis_gui.h"
26 #include "qgsattributeform.h"
27 
28 class QgsMapLayer;
29 class QgsMapLayerAction;
30 class QgsVectorLayer;
31 class QgsActionManager;
32 
38 class GUI_EXPORT QgsActionMenu : public QMenu
39 {
40  Q_OBJECT
41 
42  public:
44  {
47  AttributeAction
48  };
49 
50  struct GUI_EXPORT ActionData
51  {
52 
56  ActionData() = default;
57  ActionData( const QgsAction &action, QgsFeatureId featureId, QgsMapLayer *mapLayer );
58  ActionData( QgsMapLayerAction *action, QgsFeatureId featureId, QgsMapLayer *mapLayer );
59 
60  QgsActionMenu::ActionType actionType = Invalid;
61  QVariant actionData;
62  QgsFeatureId featureId = 0;
63  QgsMapLayer *mapLayer = nullptr;
64  };
65 
75  explicit QgsActionMenu( QgsVectorLayer *layer, const QgsFeature &feature, const QString &actionScope, QWidget *parent SIP_TRANSFERTHIS = nullptr );
76 
85  explicit QgsActionMenu( QgsVectorLayer *layer, QgsFeatureId fid, const QString &actionScope, QWidget *parent SIP_TRANSFERTHIS = nullptr );
86 
93  void setFeature( const QgsFeature &feature );
94 
100  void setMode( QgsAttributeEditorContext::Mode mode );
101 
107  void setExpressionContextScope( const QgsExpressionContextScope &scope );
108 
114  QgsExpressionContextScope expressionContextScope() const;
115 
116  signals:
117  void reinit();
118 
119  private slots:
120  void triggerAction();
121  void reloadActions();
122  void layerWillBeDeleted();
123 
124  private:
125  void init();
126  QgsFeature feature();
127 
128  QgsVectorLayer *mLayer = nullptr;
129  QList<QgsAction> mActions;
130  QgsFeature mFeature;
131  QgsFeatureId mFeatureId;
132  QString mActionScope;
133  QgsExpressionContextScope mExpressionContextScope;
135 };
136 
137 
139 
140 #endif // QGSACTIONMENU_H
Base class for all map layer types.
Definition: qgsmaplayer.h:64
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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
Q_DECLARE_METATYPE(QModelIndex)
Standard actions (defined by core or plugins)
Definition: qgsactionmenu.h:46
This class is a menu that is populated automatically with the actions defined for a given layer...
Definition: qgsactionmenu.h:38
Utility class that encapsulates an action based on vector attributes.
Definition: qgsaction.h:35
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.