QGIS API Documentation 3.28.14-Firenze (exported)
Loading...
Searching...
No Matches
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
27class QgsMapLayer;
29class QgsVectorLayer;
31
37class 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
127 bool isEmpty() const;
128
129 signals:
130 void reinit();
131
132 private slots:
133 void triggerAction();
134 void reloadActions();
135 void layerWillBeDeleted();
136
137 private:
138 void init();
139 QgsFeature feature();
140
141 QgsVectorLayer *mLayer = nullptr;
142 int mVisibleActionCount = 0;
143 QList<QgsAction> mActions;
144 QgsFeature mFeature;
145 QgsFeatureId mFeatureId;
146 QString mActionScope;
147 QgsExpressionContextScope mExpressionContextScope;
149};
150
151
153
154#endif // QGSACTIONMENU_H
Storage and management of actions associated with a layer.
This class is a menu that is populated automatically with the actions defined for a given layer.
@ Invalid
Invalid.
@ MapLayerAction
Standard actions (defined by core or plugins)
Utility class that encapsulates an action based on vector attributes.
Definition qgsaction.h:35
@ SingleEditMode
Single edit mode, for editing a single feature.
Single scope for storing variables and functions for use within a QgsExpressionContext.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:56
An action which can run on map layers The class can be used in two manners:
Base class for all map layer types.
Definition qgsmaplayer.h:73
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
ActionData()=default
Constructor for ActionData.