16#ifndef QGSWEAKRELATION_H
17#define QGSWEAKRELATION_H
25using namespace Qt::StringLiterals;
70 const QString &relationName,
72 const QString &referencingLayerId,
75 const QString &referencingLayerProviderKey,
76 const QString &referencedLayerId,
79 const QString &referencedLayerProviderKey
100 QString
id()
const {
return mRelationId; }
107 QString
name()
const {
return mRelationName; }
123 QString referencingLayerSource() const;
132 QString referencingLayerProvider() const;
142 QString referencingLayerName() const;
151 void setReferencingLayer( const QString &sourceUri, const QString &provider );
167 QString referencedLayerSource() const;
176 QString referencedLayerProvider() const;
186 QString referencedLayerName() const;
195 void setReferencedLayer( const QString &sourceUri, const QString &provider );
222 QString mappingTableSource() const;
231 QString mappingTableProvider() const;
241 QString mappingTableName() const;
250 void setMappingTable( const QString &sourceUri, const QString &provider );
460 static void writeXml(
const QgsVectorLayer *layer, WeakRelationType type,
const QgsRelation &relation, QDomNode &node, QDomDocument &doc );
463 SIP_PYOBJECT __repr__();
466 QString leftIdentifier;
467 if ( !sipCpp->referencedLayer().source.isEmpty() )
468 leftIdentifier = sipCpp->referencedLayer().source;
470 QString rightIdentifier;
471 if ( !sipCpp->referencingLayer().source.isEmpty() )
472 rightIdentifier = sipCpp->referencingLayer().source;
475 if ( leftIdentifier.isEmpty() && rightIdentifier.isEmpty() )
476 str = u
"<QgsWeakRelation: %1>"_s.arg( sipCpp->id() );
478 str = u
"<QgsWeakRelation: %1 - %2 -> %3>"_s.arg( sipCpp->id(), leftIdentifier, rightIdentifier );
480 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
491 QString mRelationName;
494 QStringList mReferencingLayerFields;
495 QStringList mMappingReferencingLayerFields;
496 QStringList mReferencedLayerFields;
497 QStringList mMappingReferencedLayerFields;
500 QString mForwardPathLabel;
501 QString mBackwardPathLabel;
502 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