QGIS API Documentation  3.0.2-Girona (307d082)
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.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, const QgsFeatureId fid, const QString &actionScope, QWidget *parent SIP_TRANSFERTHIS = nullptr );
86 
93  void setFeature( const QgsFeature &feature );
94 
100  void setMode( const QgsAttributeForm::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 
123  private:
124  void init();
125  QgsFeature feature();
126 
127  QgsVectorLayer *mLayer = nullptr;
128  QList<QgsAction> mActions;
129  QgsFeature mFeature;
130  QgsFeatureId mFeatureId;
131  QString mActionScope;
132  QgsExpressionContextScope mExpressionContextScope;
134 };
135 
136 
138 
139 #endif // QGSACTIONMENU_H
Base class for all map layer types.
Definition: qgsmaplayer.h:56
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:62
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.
qint64 QgsFeatureId
Definition: qgsfeature.h:37
Represents a vector layer which manages a vector based data sets.
An action which can run on map layers.