QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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
An action which can run on map layers.
Definition: qgsmaplayeractionregistry.h:35
QgsActionMenu::ActionData::actionData
QVariant actionData
Definition: qgsactionmenu.h:60
qgsfeature.h
QgsActionMenu::ActionData
Definition: qgsactionmenu.h:50
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
QgsActionMenu::ActionType
ActionType
Definition: qgsactionmenu.h:43
QgsAttributeEditorContext::Mode
Mode
modes
Definition: qgsattributeeditorcontext.h:48
qgis_sip.h
qgsaction.h
QgsActionMenu
This class is a menu that is populated automatically with the actions defined for a given layer.
Definition: qgsactionmenu.h:38
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext.
Definition: qgsexpressioncontext.h:112
QgsAction
Utility class that encapsulates an action based on vector attributes.
Definition: qgsaction.h:36
QgsActionMenu::ActionData::ActionData
ActionData()=default
Constructor for ActionData.
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsActionManager
Storage and management of actions associated with a layer.
Definition: qgsactionmanager.h:52
QgsActionMenu::reinit
void reinit()
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28