QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgspolymorphicrelation.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspolymorphicrelation.h
3 --------------------------------------
4 Date : December 2020
5 Copyright : (C) 2020 Ivan Ivanov
6 Email : ivan 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 QGSPOLYMORPHICRELATION_H
17#define QGSPOLYMORPHICRELATION_H
18
19#include <QList>
20#include <QDomNode>
21#include <QPair>
22
23#include "qgis_core.h"
24#include "qgsfields.h"
25#include "qgsreadwritecontext.h"
26#include "qgsrelationcontext.h"
27#include "qgsrelation.h"
28
29#include "qgis_sip.h"
30
32class QgsFeature;
34class QgsAttributes;
35class QgsVectorLayer;
36class QgsPolymorphicRelationPrivate;
38
49class CORE_EXPORT QgsPolymorphicRelation
50{
51 Q_GADGET
52
53 Q_PROPERTY( QString id READ id WRITE setId )
54 Q_PROPERTY( QgsVectorLayer *referencingLayer READ referencingLayer )
55 Q_PROPERTY( QString referencedLayerField READ referencedLayerField )
56 Q_PROPERTY( QString referencedLayerExpression READ referencedLayerExpression )
57 Q_PROPERTY( QString name READ name WRITE setName )
58 Q_PROPERTY( bool isValid READ isValid )
59
60 public:
61
67
72
79
85 QgsPolymorphicRelation &operator=( const QgsPolymorphicRelation &other );
86
96 static QgsPolymorphicRelation createFromXml( const QDomNode &node, QgsReadWriteContext &context, const QgsRelationContext &relationContext = QgsRelationContext() );
97
104 void writeXml( QDomNode &node, QDomDocument &doc ) const;
105
109 void setId( const QString &id );
110
114 void setName( const QString &name );
115
119 void setReferencingLayer( const QString &id );
120
129 void addFieldPair( const QString &referencingField, const QString &referencedField );
130
139 void addFieldPair( const QgsRelation::FieldPair &fieldPair ) SIP_SKIP;
140
148 QString name() const;
149
155 QString id() const;
156
161 void generateId();
162
169 QString referencingLayerId() const;
170
177 QgsVectorLayer *referencingLayer() const;
178
186#ifndef SIP_RUN
187 QList< QgsRelation::FieldPair > fieldPairs() const;
188#else
189 QMap< QString, QString > fieldPairs() const;
190 % MethodCode
191 const QList< QgsRelation::FieldPair > &pairs = sipCpp->fieldPairs();
192 sipRes = new QMap< QString, QString >();
193 for ( const QgsRelation::FieldPair &pair : pairs )
194 {
195 sipRes->insert( pair.first, pair.second );
196 }
197 % End
198#endif
199
206 QgsAttributeList referencedFields( const QString &layerId ) const;
207
214 QgsAttributeList referencingFields() const;
215
222 bool isValid() const;
223
230 bool hasEqualDefinition( const QgsPolymorphicRelation &other ) const;
231
236 void updateRelationStatus();
237
241 void setReferencedLayerField( const QString &referencedLayerField );
242
246 QString referencedLayerField() const;
247
251 void setReferencedLayerExpression( const QString &expression );
252
256 QString referencedLayerExpression() const;
257
261 void setReferencedLayerIds( const QStringList &childRelationIds );
262
266 QStringList referencedLayerIds() const;
267
271 QList<QgsRelation> generateRelations() const;
272
276 QString layerRepresentation( const QgsVectorLayer *layer ) const;
277
281 Qgis::RelationshipStrength strength() const;
282
286 void setRelationStrength( Qgis::RelationshipStrength relationStrength );
287
288 private:
289
290 QExplicitlySharedDataPointer<QgsPolymorphicRelationPrivate> d;
291
292 QgsRelationContext mContext;
293
294};
295
296// Register QgsPolymorphicRelation for usage with QVariant
298
299#endif // QGSPOLYMORPHICRELATION_H
RelationshipStrength
Relationship strength.
Definition qgis.h:3033
A vector of attributes.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Wrapper for iterator of features from vector data provider or vector layer.
This class wraps a request for features to a vector layer (or directly its vector data provider).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:56
A polymorphic relation consists of the same properties like a normal relation except for the referenc...
The class is used as a container of context for various read/write operations on other objects.
Context for relations.
Defines a relation between matching fields of the two involved tables of a relation.
Definition qgsrelation.h:67
Represents a vector layer which manages a vector based data sets.
#define SIP_SKIP
Definition qgis_sip.h:126
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QList< int > QgsAttributeList
Definition qgsfield.h:27