QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrelationeditorwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrelationeditor.h
3  --------------------------------------
4  Date : 17.5.2013
5  Copyright : (C) 2013 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 QGSRELATIONEDITOR_H
17 #define QGSRELATIONEDITOR_H
18 
19 #include <QWidget>
20 #include <QToolButton>
21 #include <QButtonGroup>
22 #include <QGridLayout>
23 
25 #include "qgscollapsiblegroupbox.h"
26 #include "qgsdualview.h"
27 #include "qgsrelation.h"
28 
29 class QgsFeature;
31 class QgsVectorLayer;
33 
35 {
36  Q_OBJECT
37  Q_PROPERTY( QString qgisRelation READ qgisRelation WRITE setQgisRelation )
38  Q_PROPERTY( QgsDualView::ViewMode viewMode READ viewMode WRITE setViewMode )
39 
40  public:
44  QgsRelationEditorWidget( QWidget* parent = NULL );
45 
47  void setViewMode( QgsDualView::ViewMode mode );
48  QgsDualView::ViewMode viewMode() {return mViewMode;}
49 
52  void setQgisRelation( QString qgisRelationId ) { mRelationId = qgisRelationId; }
53  QString qgisRelation() { return mRelationId; } //property( "qgisRelation" ).toString()
54 
55  void setRelationFeature( const QgsRelation& relation, const QgsFeature& feature );
56 
57  void setEditorContext( const QgsAttributeEditorContext& context );
58 
59  private slots:
60  void setViewMode( int mode ) {setViewMode( static_cast<QgsDualView::ViewMode>( mode ) );}
61  void referencingLayerEditingToggled();
62 
63  void addFeature();
64  void linkFeature();
65  void deleteFeature();
66  void unlinkFeature();
67  void toggleEditing( bool state );
68  void onCollapsedStateChanged( bool collapsed );
69 
70  private:
71  QgsDualView* mDualView;
72  QgsDualView::ViewMode mViewMode;
73  QgsGenericFeatureSelectionManager* mFeatureSelectionMgr;
74  QgsAttributeEditorContext mEditorContext;
75  QgsRelation mRelation;
76  QString mRelationId;
77  QgsFeature mFeature;
78 
79  QToolButton* mToggleEditingButton;
80  QToolButton* mAddFeatureButton;
81  QToolButton* mDeleteFeatureButton;
82  QToolButton* mLinkFeatureButton;
83  QToolButton* mUnlinkFeatureButton;
84  QToolButton* mFormViewButton;
85  QToolButton* mTableViewButton;
86  QGridLayout* mRelationLayout;
87  QButtonGroup* mViewModeButtonGroup;
88 
89  bool mInitialized;
90 };
91 
92 #endif // QGSRELATIONEDITOR_H