QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgsabstractrelationeditorwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsabstractrelationeditorwidget.h
3 ----------------------
4 begin : October 2020
5 copyright : (C) 2020 by Ivan Ivanov
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSABSTRACTRELATIONEDITORWIDGET_H
19#define QGSABSTRACTRELATIONEDITORWIDGET_H
20
21#include <QWidget>
22#include "qobjectuniqueptr.h"
23
25#include "qgsrelation.h"
26#include "qgis_sip.h"
27#include "qgis_gui.h"
28
29#ifdef SIP_RUN
30// this is needed for the "convert to subclass" code below to compile
31//%ModuleHeaderCode
33//%End
34#endif
35
36class QgsFeature;
37class QgsVectorLayer;
38
45class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
46{
47#ifdef SIP_RUN
49 if ( qobject_cast<QgsRelationEditorWidget *>( sipCpp ) )
50 sipType = sipType_QgsRelationEditorWidget;
51 else
52 sipType = 0;
54#endif
55
56 Q_OBJECT
57
58 public:
62 QgsAbstractRelationEditorWidget( const QVariantMap &config, QWidget *parent SIP_TRANSFERTHIS = nullptr );
63
67 void setRelationFeature( const QgsRelation &relation, const QgsFeature &feature );
68
78 void setRelations( const QgsRelation &relation, const QgsRelation &nmrelation );
79
84 QgsRelation relation() const { return mRelation; }
85
90 QgsRelation nmRelation() const { return mNmRelation; }
91
95 void setFeature( const QgsFeature &feature, bool update = true );
96
102 void setMultiEditFeatureIds( const QgsFeatureIds &fids );
103
109 virtual void setEditorContext( const QgsAttributeEditorContext &context );
110
114 QgsAttributeEditorContext editorContext() const;
115
120 Q_DECL_DEPRECATED bool showLabel() const SIP_DEPRECATED;
121
126 Q_DECL_DEPRECATED void setShowLabel( bool showLabel ) SIP_DEPRECATED;
127
131 QVariant nmRelationId() const;
132
137 void setNmRelationId( const QVariant &nmRelationId = QVariant() );
138
143 Q_DECL_DEPRECATED QString label() const SIP_DEPRECATED;
144
149 void setLabel( const QString &label = QString() );
150
156 QgsFeature feature() const;
157
162 QList<QgsFeature> features() const;
163
167 bool forceSuppressFormPopup() const;
168
173 void setForceSuppressFormPopup( bool forceSuppressFormPopup );
174
178 virtual QVariantMap config() const = 0;
179
183 virtual void setConfig( const QVariantMap &config ) = 0;
184
189 bool multiEditModeActive() const;
190
191 signals:
192
200 void relatedFeaturesChanged();
201
202 public slots:
203
207 virtual void parentFormValueChanged( const QString &attribute, const QVariant &newValue ) = 0;
208
209 protected slots:
210
214 void toggleEditing( bool state );
215
219 void saveEdits();
220
225 QgsFeatureIds addFeature( const QgsGeometry &geometry = QgsGeometry() );
226
230 void deleteFeature( QgsFeatureId fid = QgsFeatureId() );
231
236 void linkFeature( const QString &filterExpression = QString() );
237
241 void onLinkFeatureDlgAccepted();
242
246 void unlinkFeature( QgsFeatureId fid = QgsFeatureId() );
247
251 void duplicateFeature( const QgsFeatureId &fid );
252
256 void duplicateFeatures( const QgsFeatureIds &fids );
257
258 protected:
260 QgsRelation mRelation;
261 QgsRelation mNmRelation;
262 QgsFeatureList mFeatureList;
263
264 bool mLayerInSameTransactionGroup = false;
265
266 bool mForceSuppressFormPopup = false;
267
271 void showEvent( QShowEvent * );
272
277 Q_DECL_DEPRECATED void updateTitle() SIP_DEPRECATED;
278
282 void deleteFeatures( const QgsFeatureIds &fids );
283
287 void unlinkFeatures( const QgsFeatureIds &fids );
288
289 // Following virtual methods need to be protected so they can be overridden in bindings
290
297 virtual void updateUi();
298
303 Q_DECL_DEPRECATED virtual void setTitle( const QString &title ) SIP_DEPRECATED;
304
309 virtual void beforeSetRelationFeature( const QgsRelation &newRelation, const QgsFeature &newFeature );
310
315 virtual void afterSetRelationFeature();
316
321 virtual void beforeSetRelations( const QgsRelation &newRelation, const QgsRelation &newNmRelation );
322
327 virtual void afterSetRelations();
328};
329
330
340class GUI_EXPORT QgsAbstractRelationEditorConfigWidget : public QWidget
341{
342#ifdef SIP_RUN
344 if ( qobject_cast<QgsRelationEditorConfigWidget *>( sipCpp ) )
345 sipType = sipType_QgsRelationEditorConfigWidget;
346 else
347 sipType = 0;
348 SIP_END
349#endif
350
351 Q_OBJECT
352 public:
359 explicit QgsAbstractRelationEditorConfigWidget( const QgsRelation &relation, QWidget *parent SIP_TRANSFERTHIS );
360
366 virtual QVariantMap config() = 0;
367
373 virtual void setConfig( const QVariantMap &config ) = 0;
374
380 QgsVectorLayer *layer();
381
387 QgsRelation relation() const;
388
394 virtual void setNmRelation( const QgsRelation &nmRelation );
395
401 virtual QgsRelation nmRelation() const;
402
403 private:
404 QgsVectorLayer *mLayer = nullptr;
405 QgsRelation mRelation;
406 QgsRelation mNmRelation;
407};
408
409
411
412
420{
421 public:
426
428
432 virtual QString type() const = 0;
433
437 virtual QString name() const = 0;
438
449 virtual QgsAbstractRelationEditorWidget *create( const QVariantMap &config, QWidget *parent = nullptr ) const = 0 SIP_FACTORY;
450
460 virtual QgsAbstractRelationEditorConfigWidget *configWidget( const QgsRelation &relation, QWidget *parent ) const = 0 SIP_FACTORY;
461};
462
463#endif // QGSABSTRACTRELATIONEDITORWIDGET_H
This class should be subclassed for every configurable relation widget type.
virtual QVariantMap config()=0
Create a configuration from the current GUI state.
virtual void setConfig(const QVariantMap &config)=0
Update the configuration widget to represent the given configuration.
Factory class for creating relation widgets and their corresponding config widgets.
virtual QString type() const =0
Returns the machine readable identifier name of this widget type.
virtual QString name() const =0
Returns the human readable identifier name of this widget type.
virtual QgsAbstractRelationEditorConfigWidget * configWidget(const QgsRelation &relation, QWidget *parent) const =0
Override this in your implementation.
virtual QgsAbstractRelationEditorWidget * create(const QVariantMap &config, QWidget *parent=nullptr) const =0
Override this in your implementation.
virtual ~QgsAbstractRelationEditorWidgetFactory()=default
Base class to build new relation widgets.
QgsRelation relation() const
Returns the relation.
QgsRelation nmRelation() const
Returns the nm relation.
This class contains context information for attribute editor widgets.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
A geometry is the spatial representation of a feature.
Represents a relationship between two vector layers.
Definition qgsrelation.h:44
Represents a vector layer which manages a vector based data sets.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208
QList< QgsFeature > QgsFeatureList
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features