QGIS API Documentation  2.6.0-Brighton
 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  {}
48 
51  , actionId( actionId )
52  , featureId( featureId )
53  , mapLayer( mapLayer )
54  {}
55 
58  , actionId( action )
59  , featureId( featureId )
60  , mapLayer( mapLayer )
61  {}
62 
64 
65  union aid
66  {
67  aid( int i ) : id( i ) {}
68  aid( QgsMapLayerAction* a ) : action( a ) {}
69  int id;
71  } actionId;
72 
75  };
76 
77 
78  public:
87  explicit QgsActionMenu( QgsVectorLayer* layer, const QgsFeature* feature, QWidget* parent = 0 );
88 
96  explicit QgsActionMenu( QgsVectorLayer* layer, const QgsFeatureId fid, QWidget* parent = 0 );
97 
101  ~QgsActionMenu();
102 
109  void setFeature( QgsFeature* feature );
110 
115  void setFeature( QgsFeatureId feature );
116 
117  private slots:
118  void triggerAction();
119  void reloadActions();
120 
121  signals:
122  void reinit();
123 
124  private:
125  void init();
126  const QgsFeature* feature();
127 
128  QgsVectorLayer* mLayer;
129  QgsAttributeAction* mActions;
130  const QgsFeature* mFeature;
131  QgsFeatureId mFeatureId;
132  bool mOwnsFeature;
133 };
134 
136 
137 #endif // QGSACTIONMENU_H