QGIS API Documentation  3.2.0-Bonn (bc43194)
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( QgsFeatureId featureid = QgsFeatureId() );
152  void deleteSelectedFeatures();
153  void unlinkFeature( QgsFeatureId featureid = QgsFeatureId() );
154  void unlinkSelectedFeatures();
155  void zoomToSelectedFeatures();
156  void saveEdits();
157  void toggleEditing( bool state );
158  void onCollapsedStateChanged( bool collapsed );
159  void showContextMenu( QgsActionMenu *menu, QgsFeatureId fid );
160 
161  private:
162  void updateUi();
163 
164  QgsDualView *mDualView = nullptr;
166  QgsGenericFeatureSelectionManager *mFeatureSelectionMgr = nullptr;
167  QgsAttributeEditorContext mEditorContext;
168  QgsRelation mRelation;
169  QgsRelation mNmRelation;
170  QgsFeature mFeature;
171 
172  QToolButton *mToggleEditingButton = nullptr;
173  QToolButton *mSaveEditsButton = nullptr;
174  QToolButton *mAddFeatureButton = nullptr;
175  QToolButton *mDuplicateFeatureButton = nullptr;
176  QToolButton *mDeleteFeatureButton = nullptr;
177  QToolButton *mLinkFeatureButton = nullptr;
178  QToolButton *mUnlinkFeatureButton = nullptr;
179  QToolButton *mZoomToFeatureButton = nullptr;
180  QToolButton *mFormViewButton = nullptr;
181  QToolButton *mTableViewButton = nullptr;
182  QGridLayout *mRelationLayout = nullptr;
183  QButtonGroup *mViewModeButtonGroup = nullptr;
184 
185  bool mShowLabel = true;
186  bool mVisible = false;
187 
193  void deleteFeatures( const QgsFeatureIds &featureids );
194 
200  void unlinkFeatures( const QgsFeatureIds &featureids );
201 };
202 
203 #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:182
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