16#ifndef QGSWEAKRELATION_H
17#define QGSWEAKRELATION_H
66 const QString &relationName,
68 const QString &referencingLayerId,
71 const QString &referencingLayerProviderKey,
72 const QString &referencedLayerId,
75 const QString &referencedLayerProviderKey
96 QString
id()
const {
return mRelationId; }
103 QString
name()
const {
return mRelationName; }
119 QString referencingLayerSource() const;
128 QString referencingLayerProvider() const;
138 QString referencingLayerName() const;
147 void setReferencingLayer( const QString &sourceUri, const QString &provider );
163 QString referencedLayerSource() const;
172 QString referencedLayerProvider() const;
182 QString referencedLayerName() const;
191 void setReferencedLayer( const QString &sourceUri, const QString &provider );
218 QString mappingTableSource() const;
227 QString mappingTableProvider() const;
237 QString mappingTableName() const;
246 void setMappingTable( const QString &sourceUri, const QString &provider );
456 static void writeXml(
const QgsVectorLayer *layer, WeakRelationType type,
const QgsRelation &relation, QDomNode &node, QDomDocument &doc );
459 SIP_PYOBJECT __repr__();
462 QString leftIdentifier;
463 if ( !sipCpp->referencedLayer().source.isEmpty() )
464 leftIdentifier = sipCpp->referencedLayer().source;
466 QString rightIdentifier;
467 if ( !sipCpp->referencingLayer().source.isEmpty() )
468 rightIdentifier = sipCpp->referencingLayer().source;
471 if ( leftIdentifier.isEmpty() && rightIdentifier.isEmpty() )
472 str = QStringLiteral(
"<QgsWeakRelation: %1>" ).arg( sipCpp->id() );
474 str = QStringLiteral(
"<QgsWeakRelation: %1 - %2 -> %3>" ).arg( sipCpp->id(), leftIdentifier, rightIdentifier );
476 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
487 QString mRelationName;
490 QStringList mReferencingLayerFields;
491 QStringList mMappingReferencingLayerFields;
492 QStringList mReferencedLayerFields;
493 QStringList mMappingReferencedLayerFields;
496 QString mForwardPathLabel;
497 QString mBackwardPathLabel;
498 QString mRelatedTableType;
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 relationship between two vector layers.
Represents a vector layer which manages a vector based dataset.
Represent a QgsRelation with possibly unresolved layers or unmatched fields.
QList< QgsRelation > resolvedRelations(const QgsProject *project, QgsVectorLayerRef::MatchType matchType=QgsVectorLayerRef::MatchType::All) const
Resolves a weak relation in the given project returning a list of possibly invalid QgsRelations and w...
WeakRelationType
Enum to distinguish if the layer is referenced or referencing.
@ Referencing
The layer is referencing (or the "child" / "right" layer in the relationship).
@ Referenced
The layer is referenced (or the "parent" / "left" left 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.
QString referencedLayerName() const
Returns the layer name of the referenced (or "parent" / "left") layer.
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 referencedLayerSource() const
Returns the source URI for the referenced (or "parent" / "left") layer.
QString referencingLayerSource() const
Returns the source URI for the referencing (or "child" / "right") layer.
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.
friend class TestQgsWeakRelation
QString referencingLayerName() const
Returns the layer name of the referencing (or "child" / "right") layer.
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.
QStringList referencingLayerFields() const
Returns the list of fields from the referencingLayer() involved in the relationship.
void setReferencedLayerFields(const QStringList &fields)
Sets the list of fields from the referencedLayer() involved in the relationship.
Qgis::RelationshipStrength strength() const
Returns the strength of the relation.
_LayerRef< QgsVectorLayer > QgsVectorLayerRef