QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "qgis_gui.h"
20#include "qgis_sip.h"
21#include "qgsaction.h"
23#include "qgsfeature.h"
24
25#include <QMenu>
26
27class QgsMapLayer;
29class QgsVectorLayer;
32
37class GUI_EXPORT QgsActionMenu : public QMenu
38{
39 Q_OBJECT
40
41 public:
53
63 explicit QgsActionMenu( QgsVectorLayer *layer, const QgsFeature &feature, const QString &actionScope, QWidget *parent SIP_TRANSFERTHIS = nullptr );
64
73 explicit QgsActionMenu( QgsVectorLayer *layer, QgsFeatureId fid, const QString &actionScope, QWidget *parent SIP_TRANSFERTHIS = nullptr );
74
83
90 void setFeature( const QgsFeature &feature );
91
98
104
110
116 QList<QgsAction> menuActions() const;
117
123 bool isEmpty() const;
124
125 signals:
126
130 void reinit();
131
138 void messageEmitted( const QString &message, Qgis::MessageLevel level = Qgis::MessageLevel::Info );
139
147
148 private slots:
149 void triggerAction();
150 void reloadActions();
151 void layerWillBeDeleted();
152
153 private:
154 void init();
155 QgsFeature feature();
156
157 QgsVectorLayer *mLayer = nullptr;
158 int mVisibleActionCount = 0;
159 QList<QgsAction> mActions;
160 QgsFeature mFeature;
161 QgsFeatureId mFeatureId;
162 QString mActionScope;
163 QgsExpressionContextScope mExpressionContextScope;
165
166 QgsMapLayerActionContextGenerator *mContextGenerator = nullptr;
167};
168
169
171
172#endif // QGSACTIONMENU_H
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition qgis.h:156
@ Info
Information message.
Definition qgis.h:157
ActionType
Action types.
Definition qgis.h:4610
@ Invalid
Invalid.
Definition qgis.h:4611
Storage and management of actions associated with a layer.
QgsActionMenu(QgsVectorLayer *layer, const QgsFeature &feature, const QString &actionScope, QWidget *parent=nullptr)
Constructs a new QgsActionMenu.
void setExpressionContextScope(const QgsExpressionContextScope &scope)
Sets an expression context scope used to resolve underlying actions.
void messageEmitted(const QString &message, Qgis::MessageLevel level=Qgis::MessageLevel::Info)
Emitted when a message should be shown to the user in the application message bar.
void setMode(QgsAttributeEditorContext::Mode mode)
Change the mode of the actions.
void reinit()
Emitted after actions have been reloaded.
void setActionContextGenerator(QgsMapLayerActionContextGenerator *generator)
Sets a QgsMapLayerActionContextGenerator to create action contexts for the menu.
void messageDiscarded()
Emitted when the previous message from the tool should be cleared from the application message bar.
void setFeature(const QgsFeature &feature)
Change the feature on which actions are performed.
QgsExpressionContextScope expressionContextScope() const
Returns an expression context scope used to resolve underlying actions.
QList< QgsAction > menuActions() const
Returns menu actions.
bool isEmpty() const
Returns true if the menu has no valid actions.
Utility class that encapsulates an action based on vector attributes.
Definition qgsaction.h:37
@ 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:58
An interface for objects which can create a QgsMapLayerActionContext.
An action which can run on map layers.
Base class for all map layer types.
Definition qgsmaplayer.h:80
Represents a vector layer which manages a vector based dataset.
#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
Qgis::ActionType actionType