QGIS API Documentation  2.14.0-Essen
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 <QSignalMapper>
21 
22 #include "qgsattributeaction.h"
24 
25 
30 class GUI_EXPORT QgsActionMenu : public QMenu
31 {
32  Q_OBJECT
33 
34  public:
36  {
39  AttributeAction
40  };
41 
42  struct ActionData
43  {
45  : actionType( Invalid )
46  , actionId( 0 )
47  , featureId( 0 )
48  , mapLayer( nullptr )
49  {}
50 
51  ActionData( int actionId, QgsFeatureId featureId, QgsMapLayer* mapLayer )
52  : actionType( AttributeAction )
53  , actionId( actionId )
54  , featureId( featureId )
55  , mapLayer( mapLayer )
56  {}
57 
58  ActionData( QgsMapLayerAction* action, QgsFeatureId featureId, QgsMapLayer* mapLayer )
59  : actionType( MapLayerAction )
60  , actionId( action )
61  , featureId( featureId )
62  , mapLayer( mapLayer )
63  {}
64 
66 
67  union aid
68  {
69  aid( int i ) : id( i ) {}
70  aid( QgsMapLayerAction* a ) : action( a ) {}
71  int id;
73  } actionId;
74 
77  };
78 
87  explicit QgsActionMenu( QgsVectorLayer *layer, const QgsFeature *feature, QWidget *parent = nullptr );
88 
96  explicit QgsActionMenu( QgsVectorLayer *layer, const QgsFeatureId fid, QWidget *parent = nullptr );
97 
101  ~QgsActionMenu();
102 
109  void setFeature( QgsFeature* feature );
110 
111  private slots:
112  void triggerAction();
113  void reloadActions();
114 
115  signals:
116  void reinit();
117 
118  private:
119  void init();
120  const QgsFeature* feature();
121 
122  QgsVectorLayer* mLayer;
123  QgsAttributeAction* mActions;
124  const QgsFeature* mFeature;
125  QgsFeatureId mFeatureId;
126  bool mOwnsFeature;
127 };
128 
129 Q_DECLARE_METATYPE( QgsActionMenu::ActionData )
130 
131 #endif // QGSACTIONMENU_H
Base class for all map layer types.
Definition: qgsmaplayer.h:49
Storage and management of actions associated with Qgis layer attributes.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
Standard actions (defined by core or plugins)
Definition: qgsactionmenu.h:38
ActionData(QgsMapLayerAction *action, QgsFeatureId featureId, QgsMapLayer *mapLayer)
Definition: qgsactionmenu.h:58
This class is a menu that is populated automatically with the actions defined for a given layer...
Definition: qgsactionmenu.h:30
QgsMapLayerAction * action
Definition: qgsactionmenu.h:72
aid(QgsMapLayerAction *a)
Definition: qgsactionmenu.h:70
qint64 QgsFeatureId
Definition: qgsfeature.h:31
Represents a vector layer which manages a vector based data sets.
ActionData(int actionId, QgsFeatureId featureId, QgsMapLayer *mapLayer)
Definition: qgsactionmenu.h:51
An action which can run on map layers.