QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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
48#ifdef SIP_RUN
50 if ( qobject_cast<QgsRelationEditorWidget *>( sipCpp ) )
51 sipType = sipType_QgsRelationEditorWidget;
52 else
53 sipType = 0;
55#endif
56
57 Q_OBJECT
58
59 public:
60
61
65 QgsAbstractRelationEditorWidget( const QVariantMap &config, QWidget *parent SIP_TRANSFERTHIS = nullptr );
66
70 void setRelationFeature( const QgsRelation &relation, const QgsFeature &feature );
71
81 void setRelations( const QgsRelation &relation, const QgsRelation &nmrelation );
82
87 QgsRelation relation() const {return mRelation;}
88
93 QgsRelation nmRelation() const {return mNmRelation;}
94
98 void setFeature( const QgsFeature &feature, bool update = true );
99
105 void setMultiEditFeatureIds( const QgsFeatureIds &fids );
106
112 virtual void setEditorContext( const QgsAttributeEditorContext &context );
113
117 QgsAttributeEditorContext editorContext( ) const;
118
123 Q_DECL_DEPRECATED bool showLabel() const SIP_DEPRECATED;
124
129 Q_DECL_DEPRECATED void setShowLabel( bool showLabel ) SIP_DEPRECATED;
130
134 QVariant nmRelationId() const;
135
140 void setNmRelationId( const QVariant &nmRelationId = QVariant() );
141
146 Q_DECL_DEPRECATED QString label() const SIP_DEPRECATED;
147
152 void setLabel( const QString &label = QString() );
153
159 QgsFeature feature() const;
160
165 QList<QgsFeature> features() const;
166
170 bool forceSuppressFormPopup() const;
171
176 void setForceSuppressFormPopup( bool forceSuppressFormPopup );
177
181 virtual QVariantMap config() const = 0;
182
186 virtual void setConfig( const QVariantMap &config ) = 0;
187
192 bool multiEditModeActive() const;
193
194 signals:
195
203 void relatedFeaturesChanged();
204
205 public slots:
206
210 virtual void parentFormValueChanged( const QString &attribute, const QVariant &newValue ) = 0;
211
212 protected slots:
213
217 void toggleEditing( bool state );
218
222 void saveEdits();
223
228 QgsFeatureIds addFeature( const QgsGeometry &geometry = QgsGeometry() );
229
233 void deleteFeature( QgsFeatureId fid = QgsFeatureId() );
234
239 void linkFeature( const QString &filterExpression = QString() );
240
244 void onLinkFeatureDlgAccepted();
245
249 void unlinkFeature( QgsFeatureId fid = QgsFeatureId() );
250
254 void duplicateFeature( const QgsFeatureId &fid );
255
259 void duplicateFeatures( const QgsFeatureIds &fids );
260
261 protected:
262
264 QgsRelation mRelation;
265 QgsRelation mNmRelation;
266 QgsFeatureList mFeatureList;
267
268 bool mLayerInSameTransactionGroup = false;
269
270 bool mForceSuppressFormPopup = false;
271
275 void showEvent( QShowEvent * );
276
281 Q_DECL_DEPRECATED void updateTitle() SIP_DEPRECATED;
282
286 void deleteFeatures( const QgsFeatureIds &fids );
287
291 void unlinkFeatures( const QgsFeatureIds &fids );
292
293 // Following virtual methods need to be protected so they can be overridden in bindings
294
301 virtual void updateUi();
302
307 Q_DECL_DEPRECATED virtual void setTitle( const QString &title ) SIP_DEPRECATED;
308
313 virtual void beforeSetRelationFeature( const QgsRelation &newRelation, const QgsFeature &newFeature );
314
319 virtual void afterSetRelationFeature();
320
325 virtual void beforeSetRelations( const QgsRelation &newRelation, const QgsRelation &newNmRelation );
326
331 virtual void afterSetRelations();
332};
333
334
344class GUI_EXPORT QgsAbstractRelationEditorConfigWidget : public QWidget
345{
346
347#ifdef SIP_RUN
349 if ( qobject_cast<QgsRelationEditorConfigWidget *>( sipCpp ) )
350 sipType = sipType_QgsRelationEditorConfigWidget;
351 else
352 sipType = 0;
353 SIP_END
354#endif
355
356 Q_OBJECT
357 public:
358
365 explicit QgsAbstractRelationEditorConfigWidget( const QgsRelation &relation, QWidget *parent SIP_TRANSFERTHIS );
366
372 virtual QVariantMap config() = 0;
373
379 virtual void setConfig( const QVariantMap &config ) = 0;
380
386 QgsVectorLayer *layer();
387
393 QgsRelation relation() const;
394
400 virtual void setNmRelation( const QgsRelation &nmRelation );
401
407 virtual QgsRelation nmRelation() const;
408
409 private:
410 QgsVectorLayer *mLayer = nullptr;
411 QgsRelation mRelation;
412 QgsRelation mNmRelation;
413};
414
415
417
418
426{
427 public:
428
433
435
439 virtual QString type() const = 0;
440
444 virtual QString name() const = 0;
445
456 virtual QgsAbstractRelationEditorWidget *create( const QVariantMap &config, QWidget *parent = nullptr ) const = 0 SIP_FACTORY;
457
467 virtual QgsAbstractRelationEditorConfigWidget *configWidget( const QgsRelation &relation, QWidget *parent ) const = 0 SIP_FACTORY;
468};
469
470#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