16#ifndef QGSWEAKRELATION_H
17#define QGSWEAKRELATION_H
67 const QString &relationName,
69 const QString &referencingLayerId,
70 const QString &referencingLayerName,
71 const QString &referencingLayerSource,
72 const QString &referencingLayerProviderKey,
73 const QString &referencedLayerId,
74 const QString &referencedLayerName,
75 const QString &referencedLayerSource,
76 const QString &referencedLayerProviderKey
89 QList< QgsRelation > resolvedRelations(
const QgsProject *project )
const;
97 QString
id()
const {
return mRelationId; }
104 QString
name()
const {
return mRelationName; }
120 QString referencingLayerSource() const;
129 QString referencingLayerProvider() const;
139 QString referencingLayerName() const;
148 void setReferencingLayer( const QString &sourceUri, const QString &provider );
164 QString referencedLayerSource() const;
173 QString referencedLayerProvider() const;
183 QString referencedLayerName() const;
192 void setReferencedLayer( const QString &sourceUri, const QString &provider );
219 QString mappingTableSource() const;
228 QString mappingTableProvider() const;
238 QString mappingTableName() const;
247 void setMappingTable( const QString &sourceUri, const QString &provider );
254 QStringList referencingLayerFields()
const {
return mReferencingLayerFields; }
457 static void writeXml(
const QgsVectorLayer *layer, WeakRelationType type,
const QgsRelation &relation, QDomNode &node, QDomDocument &doc );
460 SIP_PYOBJECT __repr__();
463 QString leftIdentifier;
464 if ( !sipCpp->referencedLayer().source.isEmpty() )
465 leftIdentifier = sipCpp->referencedLayer().source;
467 QString rightIdentifier;
468 if ( !sipCpp->referencingLayer().source.isEmpty() )
469 rightIdentifier = sipCpp->referencingLayer().source;
472 if ( leftIdentifier.isEmpty() && rightIdentifier.isEmpty() )
473 str = QStringLiteral(
"<QgsWeakRelation: %1>" ).arg( sipCpp->id() );
475 str = QStringLiteral(
"<QgsWeakRelation: %1 - %2 -> %3>" ).arg( sipCpp->id(), leftIdentifier, rightIdentifier );
477 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
488 QString mRelationName;
491 QStringList mReferencingLayerFields;
492 QStringList mMappingReferencingLayerFields;
493 QStringList mReferencedLayerFields;
494 QStringList mMappingReferencedLayerFields;
497 QString mForwardPathLabel;
498 QString mBackwardPathLabel;
499 QString mRelatedTableType;
501 friend class TestQgsWeakRelation;
RelationshipStrength
Relationship strength.
@ Association
Loose relation, related elements are not part of the parent and a parent copy will not copy any child...
RelationshipCardinality
Relationship cardinality.
@ OneToMany
One to many relationship.
Resolves relative paths into absolute paths and vice versa.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Represents a vector layer which manages a vector based data sets.
The QgsWeakRelation class represent a QgsRelation with possibly unresolved layers or unmatched fields...
WeakRelationType
Enum to distinguish if the layer is referenced or referencing.
@ Referencing
The layer is referencing (or the "child" / "right" layer in the relationship)
QStringList mappingReferencingLayerFields() const
Returns the list of fields from the mappingTable() involved in the relationship.
void setForwardPathLabel(const QString &label)
Sets the label of the forward path for the relationship.
QgsWeakRelation()
Default constructor for an invalid relation.
void setMappingReferencingLayerFields(const QStringList &fields)
Sets the list of fields from the mappingTable() involved in the relationship.
void setBackwardPathLabel(const QString &label)
Sets the label of the backward path for the relationship.
QString relatedTableType() const
Returns the type string of the related table.
void setReferencingLayerFields(const QStringList &fields)
Sets the list of fields from the referencingLayer() involved in the relationship.
QString name() const
Returns the relationship's name.
QString backwardPathLabel() const
Returns the label of the backward path for the relationship.
void setMappingReferencedLayerFields(const QStringList &fields)
Sets the list of fields from the mappingTable() involved in the relationship.
QString id() const
Returns the relationship's ID.
QString forwardPathLabel() const
Returns the label of the forward path for the relationship.
Qgis::RelationshipCardinality cardinality() const
Returns the relationship's cardinality.
void setCardinality(Qgis::RelationshipCardinality cardinality)
Sets the relationship's cardinality.
QStringList referencedLayerFields() const
Returns the list of fields from the referencedLayer() involved in the relationship.
QStringList mappingReferencedLayerFields() const
Returns the list of fields from the mappingTable() involved in the relationship.
void setRelatedTableType(const QString &type)
Sets the type string of the related table.
void setReferencedLayerFields(const QStringList &fields)
Sets the list of fields from the referencedLayer() involved in the relationship.
MatchType
Flag for match type in weak resolution.