QGIS API Documentation  3.0.2-Girona (307d082)
qgsrelationeditorwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrelationeditorwidget.h
3  --------------------------------------
4  Date : 17.5.2013
5  Copyright : (C) 2013 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 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 #include "qgis_gui.h"
29 
30 class QgsFeature;
32 class QgsVectorLayer;
34 
35 #ifdef SIP_RUN
36 % ModuleHeaderCode
37 // fix to allow compilation with sip that for some reason
38 // doesn't add this include to the file where the code from
39 // ConvertToSubClassCode goes.
41 % End
42 #endif
43 
49 {
50 
51 #ifdef SIP_RUN
53  if ( qobject_cast<QgsRelationEditorWidget *>( sipCpp ) )
54  sipType = sipType_QgsRelationEditorWidget;
55  else
56  sipType = NULL;
57  SIP_END
58 #endif
59 
60 
61 
62  Q_OBJECT
63  Q_PROPERTY( QgsDualView::ViewMode viewMode READ viewMode WRITE setViewMode )
64  Q_PROPERTY( bool showLabel READ showLabel WRITE setShowLabel )
65 
66  public:
67 
71  QgsRelationEditorWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
72 
74  void setViewMode( QgsDualView::ViewMode mode );
75 
77  QgsDualView::ViewMode viewMode() {return mViewMode;}
78 
79  void setRelationFeature( const QgsRelation &relation, const QgsFeature &feature );
80 
90  void setRelations( const QgsRelation &relation, const QgsRelation &nmrelation );
91 
92  void setFeature( const QgsFeature &feature );
93 
94  void setEditorContext( const QgsAttributeEditorContext &context );
95 
100  QgsIFeatureSelectionManager *featureSelectionManager();
101 
107  bool showLabel() const;
108 
114  void setShowLabel( bool showLabel );
115 
121  bool showLinkButton() const;
122 
128  void setShowLinkButton( bool showLinkButton );
129 
135  bool showUnlinkButton() const;
136 
142  void setShowUnlinkButton( bool showUnlinkButton );
143 
144  private slots:
145  void setViewMode( int mode ) {setViewMode( static_cast<QgsDualView::ViewMode>( mode ) );}
146  void updateButtons();
147 
148  void addFeature();
149  void duplicateFeature();
150  void linkFeature();
151  void deleteFeature( const QgsFeatureId featureid = QgsFeatureId() );
152  void deleteSelectedFeatures();
153  void unlinkFeature( const QgsFeatureId featureid = QgsFeatureId() );
154  void unlinkSelectedFeatures();
155  void saveEdits();
156  void toggleEditing( bool state );
157  void onCollapsedStateChanged( bool collapsed );
158  void showContextMenu( QgsActionMenu *menu, const QgsFeatureId fid );
159 
160  private:
161  void updateUi();
162 
163  QgsDualView *mDualView = nullptr;
165  QgsGenericFeatureSelectionManager *mFeatureSelectionMgr = nullptr;
166  QgsAttributeEditorContext mEditorContext;
167  QgsRelation mRelation;
168  QgsRelation mNmRelation;
169  QgsFeature mFeature;
170 
171  QToolButton *mToggleEditingButton = nullptr;
172  QToolButton *mSaveEditsButton = nullptr;
173  QToolButton *mAddFeatureButton = nullptr;
174  QToolButton *mDuplicateFeatureButton = nullptr;
175  QToolButton *mDeleteFeatureButton = nullptr;
176  QToolButton *mLinkFeatureButton = nullptr;
177  QToolButton *mUnlinkFeatureButton = nullptr;
178  QToolButton *mFormViewButton = nullptr;
179  QToolButton *mTableViewButton = nullptr;
180  QGridLayout *mRelationLayout = nullptr;
181  QButtonGroup *mViewModeButtonGroup = nullptr;
182 
183  bool mShowLabel = true;
184  bool mVisible = false;
185 
191  void deleteFeatures( const QgsFeatureIds &featureids );
192 
198  void unlinkFeatures( const QgsFeatureIds &featureids );
199 };
200 
201 #endif // QGSRELATIONEDITOR_H
Methods in this class are used to handle basic operations on vector layers.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
A groupbox that collapses/expands when toggled and can save its collapsed and checked states...
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:544
This class contains context information for attribute editor widgets.
ViewMode
The view modes, in which this widget can present information.
Definition: qgsdualview.h:54
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:62
Show a list of the features, where one can be chosen and the according attribute dialog will be prese...
Definition: qgsdualview.h:67
This class is a menu that is populated automatically with the actions defined for a given layer...
Definition: qgsactionmenu.h:38
#define SIP_END
Definition: qgis_sip.h:175
This selection manager synchronizes a local set of selected features with an attribute table...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:165
qint64 QgsFeatureId
Definition: qgsfeature.h:37
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.
This widget is used to show the attributes of a set of features of a QgsVectorLayer.
Definition: qgsdualview.h:43