QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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
QgsActionMenu::Invalid
@ Invalid
Invalid.
Definition: qgsactionmenu.h:44
qgsattributeform.h
QgsActionMenu::MapLayerAction
@ MapLayerAction
Standard actions (defined by core or plugins)
Definition: qgsactionmenu.h:45
QgsMapLayerAction
Definition: qgsmaplayeractionregistry.h:34
QgsActionMenu::ActionData::actionData
QVariant actionData
Definition: qgsactionmenu.h:60
qgsfeature.h
QgsActionMenu::ActionData
Definition: qgsactionmenu.h:49
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
QgsActionMenu::ActionType
ActionType
Definition: qgsactionmenu.h:42
QgsAttributeEditorContext::Mode
Mode
modes
Definition: qgsattributeeditorcontext.h:47
qgis_sip.h
qgsaction.h
QgsActionMenu
Definition: qgsactionmenu.h:37
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext....
Definition: qgsexpressioncontext.h:111
QgsAction
Definition: qgsaction.h:35
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsFeature
Definition: qgsfeature.h:55
QgsActionManager
Definition: qgsactionmanager.h:51
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25