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; }
118 QString referencingLayerSource() const;
125 QString referencingLayerProvider() const;
135 QString referencingLayerName() const;
149 QString referencedLayerSource() const;
156 QString referencedLayerProvider() const;
166 QString referencedLayerName() const;
191 QString mappingTableSource() const;
198 QString mappingTableProvider() const;
208 QString mappingTableName() const;
215 QStringList referencingLayerFields()
const {
return mReferencingLayerFields; }
418 static void writeXml(
const QgsVectorLayer *layer, WeakRelationType type,
const QgsRelation &relation, QDomNode &node, QDomDocument &doc );
421 SIP_PYOBJECT __repr__();
424 QString leftIdentifier;
425 if ( !sipCpp->referencedLayer().source.isEmpty() )
426 leftIdentifier = sipCpp->referencedLayer().source;
428 QString rightIdentifier;
429 if ( !sipCpp->referencingLayer().source.isEmpty() )
430 rightIdentifier = sipCpp->referencingLayer().source;
433 if ( leftIdentifier.isEmpty() && rightIdentifier.isEmpty() )
434 str = QStringLiteral(
"<QgsWeakRelation: %1>" ).arg( sipCpp->id() );
436 str = QStringLiteral(
"<QgsWeakRelation: %1 - %2 -> %3>" ).arg( sipCpp->id(), leftIdentifier, rightIdentifier );
438 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
449 QString mRelationName;
452 QStringList mReferencingLayerFields;
453 QStringList mMappingReferencingLayerFields;
454 QStringList mReferencedLayerFields;
455 QStringList mMappingReferencedLayerFields;
458 QString mForwardPathLabel;
459 QString mBackwardPathLabel;
460 QString mRelatedTableType;
462 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.