QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 dot kuhn at gmx 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 QgsActionMenu : public QMenu
31 {
32  Q_OBJECT
33 
34  public:
36  {
40  };
41 
42  struct ActionData
43  {
45  : actionType( Invalid )
46  , actionId( 0 )
47  , featureId( 0 )
48  , mapLayer( NULL )
49  {}
50 
53  , actionId( actionId )
54  , featureId( featureId )
55  , mapLayer( mapLayer )
56  {}
57 
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 
79 
80  public:
89  explicit QgsActionMenu( QgsVectorLayer* layer, const QgsFeature* feature, QWidget* parent = 0 );
90 
98  explicit QgsActionMenu( QgsVectorLayer* layer, const QgsFeatureId fid, QWidget* parent = 0 );
99 
103  ~QgsActionMenu();
104 
111  void setFeature( QgsFeature* feature );
112 
117  void setFeature( QgsFeatureId feature );
118 
119  private slots:
120  void triggerAction();
121  void reloadActions();
122 
123  signals:
124  void reinit();
125 
126  private:
127  void init();
128  const QgsFeature* feature();
129 
130  QgsVectorLayer* mLayer;
131  QgsAttributeAction* mActions;
132  const QgsFeature* mFeature;
133  QgsFeatureId mFeatureId;
134  bool mOwnsFeature;
135 };
136 
138 
139 #endif // QGSACTIONMENU_H