QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
|
The QgsWeakRelation class represent a QgsRelation with possibly unresolved layers or unmatched fields. More...
#include <qgsweakrelation.h>
Public Types | |
enum | WeakRelationType { Referencing , Referenced } |
Enum to distinguish if the layer is referenced or referencing. More... | |
Public Member Functions | |
QgsWeakRelation () | |
Default constructor for an invalid relation. More... | |
QgsWeakRelation (const QString &relationId, const QString &relationName, const Qgis::RelationshipStrength strength, const QString &referencingLayerId, const QString &referencingLayerName, const QString &referencingLayerSource, const QString &referencingLayerProviderKey, const QString &referencedLayerId, const QString &referencedLayerName, const QString &referencedLayerSource, const QString &referencedLayerProviderKey) | |
Creates a QgsWeakRelation. More... | |
QString | backwardPathLabel () const |
Returns the label of the backward path for the relationship. More... | |
Qgis::RelationshipCardinality | cardinality () const |
Returns the relationship's cardinality. More... | |
QString | forwardPathLabel () const |
Returns the label of the forward path for the relationship. More... | |
QString | id () const |
Returns the relationship's ID. More... | |
QStringList | mappingReferencedLayerFields () const |
Returns the list of fields from the mappingTable() involved in the relationship. More... | |
QStringList | mappingReferencingLayerFields () const |
Returns the list of fields from the mappingTable() involved in the relationship. More... | |
QgsVectorLayerRef | mappingTable () const |
Returns a weak reference to the mapping table, which forms the middle table in many-to-many relationships. More... | |
QString | mappingTableName () const |
Returns the layer name of the mapping table, which forms the middle table in many-to-many relationships. More... | |
QString | mappingTableProvider () const |
Returns the provider ID for the mapping table, which forms the middle table in many-to-many relationships. More... | |
QString | mappingTableSource () const |
Returns the source URI for the mapping table, which forms the middle table in many-to-many relationships. More... | |
QString | name () const |
Returns the relationship's name. More... | |
QgsVectorLayerRef | referencedLayer () const |
Returns a weak reference to the referenced (or "parent" / "left") layer. More... | |
QStringList | referencedLayerFields () const |
Returns the list of fields from the referencedLayer() involved in the relationship. More... | |
QString | referencedLayerName () const |
Returns the layer name of the referenced (or "parent" / "left") layer. More... | |
QString | referencedLayerProvider () const |
Returns the provider ID for the referenced (or "parent" / "left") layer. More... | |
QString | referencedLayerSource () const |
Returns the source URI for the referenced (or "parent" / "left") layer. More... | |
QgsVectorLayerRef | referencingLayer () const |
Returns a weak reference to the referencing (or "child" / "right") layer. More... | |
QStringList | referencingLayerFields () const |
Returns the list of fields from the referencingLayer() involved in the relationship. More... | |
QString | referencingLayerName () const |
Returns the layer name of the referencing (or "child" / "right") layer. More... | |
QString | referencingLayerProvider () const |
Returns the provider ID for the referencing (or "child" / "right") layer. More... | |
QString | referencingLayerSource () const |
Returns the source URI for the referencing (or "child" / "right") layer. More... | |
QString | relatedTableType () const |
Returns the type string of the related table. More... | |
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 without performing any kind of validity check. More... | |
void | setBackwardPathLabel (const QString &label) |
Sets the label of the backward path for the relationship. More... | |
void | setCardinality (Qgis::RelationshipCardinality cardinality) |
Sets the relationship's cardinality. More... | |
void | setForwardPathLabel (const QString &label) |
Sets the label of the forward path for the relationship. More... | |
void | setMappingReferencedLayerFields (const QStringList &fields) |
Sets the list of fields from the mappingTable() involved in the relationship. More... | |
void | setMappingReferencingLayerFields (const QStringList &fields) |
Sets the list of fields from the mappingTable() involved in the relationship. More... | |
void | setMappingTable (const QgsVectorLayerRef &table) |
Sets a weak reference to the mapping table, which forms the middle table in many-to-many relationships. More... | |
void | setReferencedLayerFields (const QStringList &fields) |
Sets the list of fields from the referencedLayer() involved in the relationship. More... | |
void | setReferencingLayerFields (const QStringList &fields) |
Sets the list of fields from the referencingLayer() involved in the relationship. More... | |
void | setRelatedTableType (const QString &type) |
Sets the type string of the related table. More... | |
Qgis::RelationshipStrength | strength () const |
Returns the strength of the relation. More... | |
Static Public Member Functions | |
static QgsWeakRelation | readXml (const QgsVectorLayer *layer, WeakRelationType type, const QDomNode &node, const QgsPathResolver resolver) |
Returns a weak relation for the given layer. More... | |
static void | writeXml (const QgsVectorLayer *layer, WeakRelationType type, const QgsRelation &relation, QDomNode &node, QDomDocument &doc) |
Writes a weak relation infoto an XML structure. More... | |
Friends | |
class | TestQgsWeakRelation |
The QgsWeakRelation class represent a QgsRelation with possibly unresolved layers or unmatched fields.
This class is used to store relation information attached to a layer style, a method to attempt relation resolution is also implemented and can be used to create a QgsRelation after the dependent layers are loaded and available.
In contrast to QgsRelation, QgsWeakRelation can be used to encapsulate information about a relationship which does not currently exist in a QGIS project. E.g. it can be used to represent a relationship which exists in a database backend (but not within a QGIS project). Accordingly, some properties available in QgsWeakRelation are included for informational purposes only, and cannot be translated to QgsRelations or respected in QGIS relationships.
Definition at line 42 of file qgsweakrelation.h.
Enum to distinguish if the layer is referenced or referencing.
Enumerator | |
---|---|
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) |
Definition at line 50 of file qgsweakrelation.h.
|
default |
Default constructor for an invalid relation.
QgsWeakRelation::QgsWeakRelation | ( | const QString & | relationId, |
const QString & | relationName, | ||
const Qgis::RelationshipStrength | strength, | ||
const QString & | referencingLayerId, | ||
const QString & | referencingLayerName, | ||
const QString & | referencingLayerSource, | ||
const QString & | referencingLayerProviderKey, | ||
const QString & | referencedLayerId, | ||
const QString & | referencedLayerName, | ||
const QString & | referencedLayerSource, | ||
const QString & | referencedLayerProviderKey | ||
) |
|
inline |
Returns the label of the backward path for the relationship.
The forward and backward path labels are free-form, user-friendly strings which can be used to generate descriptions of the relationship between features from the right and left tables.
E.g. when the left table contains buildings and the right table contains furniture, the forward path label could be "contains" and the backward path label could be "is located within". A client could then generate a user friendly description string such as "fire hose 1234 is located within building 15a".
Definition at line 331 of file qgsweakrelation.h.
|
inline |
Returns the relationship's cardinality.
Definition at line 285 of file qgsweakrelation.h.
|
inline |
Returns the label of the forward path for the relationship.
The forward and backward path labels are free-form, user-friendly strings which can be used to generate descriptions of the relationship between features from the right and left tables.
E.g. when the left table contains buildings and the right table contains furniture, the forward path label could be "contains" and the backward path label could be "is located within". A client could then generate a user friendly description string such as "fire hose 1234 is located within building 15a".
Definition at line 312 of file qgsweakrelation.h.
|
inline |
|
inline |
Returns the list of fields from the mappingTable() involved in the relationship.
These fields will be matched to the referencedLayerFields() in many-to-many joins.
Definition at line 263 of file qgsweakrelation.h.
|
inline |
Returns the list of fields from the mappingTable() involved in the relationship.
These fields will be matched to the referencingLayerFields() in many-to-many joins.
Definition at line 231 of file qgsweakrelation.h.
QgsVectorLayerRef QgsWeakRelation::mappingTable | ( | ) | const |
Returns a weak reference to the mapping table, which forms the middle table in many-to-many relationships.
Definition at line 178 of file qgsweakrelation.cpp.
QString QgsWeakRelation::mappingTableName | ( | ) | const |
Returns the layer name of the mapping table, which forms the middle table in many-to-many relationships.
Definition at line 198 of file qgsweakrelation.cpp.
QString QgsWeakRelation::mappingTableProvider | ( | ) | const |
Returns the provider ID for the mapping table, which forms the middle table in many-to-many relationships.
Definition at line 193 of file qgsweakrelation.cpp.
QString QgsWeakRelation::mappingTableSource | ( | ) | const |
Returns the source URI for the mapping table, which forms the middle table in many-to-many relationships.
Definition at line 188 of file qgsweakrelation.cpp.
|
inline |
|
static |
Returns a weak relation for the given layer.
layer | the layer of the weak relation |
type | determines if the layer is referencing or referenced |
node | the QDomNode |
resolver | the path resolver |
Definition at line 212 of file qgsweakrelation.cpp.
QgsVectorLayerRef QgsWeakRelation::referencedLayer | ( | ) | const |
Returns a weak reference to the referenced (or "parent" / "left") layer.
Definition at line 154 of file qgsweakrelation.cpp.
|
inline |
Returns the list of fields from the referencedLayer() involved in the relationship.
Definition at line 247 of file qgsweakrelation.h.
QString QgsWeakRelation::referencedLayerName | ( | ) | const |
Returns the layer name of the referenced (or "parent" / "left") layer.
Definition at line 169 of file qgsweakrelation.cpp.
QString QgsWeakRelation::referencedLayerProvider | ( | ) | const |
Returns the provider ID for the referenced (or "parent" / "left") layer.
Definition at line 164 of file qgsweakrelation.cpp.
QString QgsWeakRelation::referencedLayerSource | ( | ) | const |
Returns the source URI for the referenced (or "parent" / "left") layer.
Definition at line 159 of file qgsweakrelation.cpp.
QgsVectorLayerRef QgsWeakRelation::referencingLayer | ( | ) | const |
Returns a weak reference to the referencing (or "child" / "right") layer.
Definition at line 130 of file qgsweakrelation.cpp.
|
inline |
Returns the list of fields from the referencingLayer() involved in the relationship.
Definition at line 215 of file qgsweakrelation.h.
QString QgsWeakRelation::referencingLayerName | ( | ) | const |
Returns the layer name of the referencing (or "child" / "right") layer.
Definition at line 145 of file qgsweakrelation.cpp.
QString QgsWeakRelation::referencingLayerProvider | ( | ) | const |
Returns the provider ID for the referencing (or "child" / "right") layer.
Definition at line 140 of file qgsweakrelation.cpp.
QString QgsWeakRelation::referencingLayerSource | ( | ) | const |
Returns the source URI for the referencing (or "child" / "right") layer.
Definition at line 135 of file qgsweakrelation.cpp.
|
inline |
Returns the type string of the related table.
This a free-form string representing the type of related features, where the exact interpretation is format dependent. For instance, table types from GeoPackage relationships will directly reflect the categories from the GeoPackage related tables extension (i.e. "media", "simple attributes", "features", "attributes" and "tiles").
Definition at line 382 of file qgsweakrelation.h.
QList< QgsRelation > QgsWeakRelation::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 without performing any kind of validity check.
Definition at line 36 of file qgsweakrelation.cpp.
|
inline |
Sets the label of the backward path for the relationship.
The forward and backward path labels are free-form, user-friendly strings which can be used to generate descriptions of the relationship between features from the right and left tables.
E.g. when the left table contains buildings and the right table contains furniture, the forward path label could be "contains" and the backward path label could be "is located within". A client could then generate a user friendly description string such as "fire hose 1234 is located within building 15a".
Definition at line 369 of file qgsweakrelation.h.
|
inline |
Sets the relationship's cardinality.
Definition at line 293 of file qgsweakrelation.h.
|
inline |
Sets the label of the forward path for the relationship.
The forward and backward path labels are free-form, user-friendly strings which can be used to generate descriptions of the relationship between features from the right and left tables.
E.g. when the left table contains buildings and the right table contains furniture, the forward path label could be "contains" and the backward path label could be "is located within". A client could then generate a user friendly description string such as "fire hose 1234 is located within building 15a".
Definition at line 350 of file qgsweakrelation.h.
|
inline |
Sets the list of fields from the mappingTable() involved in the relationship.
These fields will be matched to the referencedLayerFields() in many-to-many joins.
Definition at line 272 of file qgsweakrelation.h.
|
inline |
Sets the list of fields from the mappingTable() involved in the relationship.
These fields will be matched to the referencingLayerFields() in many-to-many joins.
Definition at line 240 of file qgsweakrelation.h.
void QgsWeakRelation::setMappingTable | ( | const QgsVectorLayerRef & | table | ) |
Sets a weak reference to the mapping table, which forms the middle table in many-to-many relationships.
Definition at line 183 of file qgsweakrelation.cpp.
|
inline |
Sets the list of fields from the referencedLayer() involved in the relationship.
Definition at line 254 of file qgsweakrelation.h.
|
inline |
Sets the list of fields from the referencingLayer() involved in the relationship.
Definition at line 222 of file qgsweakrelation.h.
|
inline |
Sets the type string of the related table.
This a free-form string representing the type of related features, where the exact interpretation is format dependent. For instance, table types from GeoPackage relationships will directly reflect the categories from the GeoPackage related tables extension (i.e. "media", "simple attributes", "features", "attributes" and "tiles").
Definition at line 395 of file qgsweakrelation.h.
Qgis::RelationshipStrength QgsWeakRelation::strength | ( | ) | const |
Returns the strength of the relation.
Definition at line 207 of file qgsweakrelation.cpp.
|
static |
Writes a weak relation infoto an XML structure.
Used for saving .qgs projects
layer | the layer which we save the weak relation for |
type | determines if the layer is referencing or referenced |
relation | the relation to save as a weak relation |
node | The parent node in which the relation will be created |
doc | The document in which the relation will be saved |
Definition at line 280 of file qgsweakrelation.cpp.
|
friend |
Definition at line 462 of file qgsweakrelation.h.