QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
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. | |
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. | |
QString | backwardPathLabel () const |
Returns the label of the backward path for the relationship. | |
Qgis::RelationshipCardinality | cardinality () const |
Returns the relationship's cardinality. | |
QString | forwardPathLabel () const |
Returns the label of the forward path for the relationship. | |
QString | id () const |
Returns the relationship's ID. | |
QStringList | mappingReferencedLayerFields () const |
Returns the list of fields from the mappingTable() involved in the relationship. | |
QStringList | mappingReferencingLayerFields () const |
Returns the list of fields from the mappingTable() involved in the relationship. | |
QgsVectorLayerRef | mappingTable () const |
Returns a weak reference to the mapping table, which forms the middle table in many-to-many relationships. | |
QString | mappingTableName () const |
Returns the layer name of the mapping table, which forms the middle table in many-to-many relationships. | |
QString | mappingTableProvider () const |
Returns the provider ID for the mapping table, which forms the middle table in many-to-many relationships. | |
QString | mappingTableSource () const |
Returns the source URI for the mapping table, which forms the middle table in many-to-many relationships. | |
QString | name () const |
Returns the relationship's name. | |
QgsVectorLayerRef | referencedLayer () const |
Returns a weak reference to the referenced (or "parent" / "left") layer. | |
QStringList | referencedLayerFields () const |
Returns the list of fields from the referencedLayer() involved in the relationship. | |
QString | referencedLayerName () const |
Returns the layer name of the referenced (or "parent" / "left") layer. | |
QString | referencedLayerProvider () const |
Returns the provider ID for the referenced (or "parent" / "left") layer. | |
QString | referencedLayerSource () const |
Returns the source URI for the referenced (or "parent" / "left") layer. | |
QgsVectorLayerRef | referencingLayer () const |
Returns a weak reference to the referencing (or "child" / "right") layer. | |
QStringList | referencingLayerFields () const |
Returns the list of fields from the referencingLayer() involved in the relationship. | |
QString | referencingLayerName () const |
Returns the layer name of the referencing (or "child" / "right") layer. | |
QString | referencingLayerProvider () const |
Returns the provider ID for the referencing (or "child" / "right") layer. | |
QString | referencingLayerSource () const |
Returns the source URI for the referencing (or "child" / "right") layer. | |
QString | relatedTableType () const |
Returns the type string of the related table. | |
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. | |
void | setBackwardPathLabel (const QString &label) |
Sets the label of the backward path for the relationship. | |
void | setCardinality (Qgis::RelationshipCardinality cardinality) |
Sets the relationship's cardinality. | |
void | setForwardPathLabel (const QString &label) |
Sets the label of the forward path for the relationship. | |
void | setMappingReferencedLayerFields (const QStringList &fields) |
Sets the list of fields from the mappingTable() involved in the relationship. | |
void | setMappingReferencingLayerFields (const QStringList &fields) |
Sets the list of fields from the mappingTable() involved in the relationship. | |
void | setMappingTable (const QgsVectorLayerRef &table) |
Sets a weak reference to the mapping table, which forms the middle table in many-to-many relationships. | |
void | setMappingTable (const QString &sourceUri, const QString &provider) |
Sets the source for the mapping table, which forms the middle table in many-to-many relationships, by sourceUri and provider ID. | |
void | setReferencedLayer (const QString &sourceUri, const QString &provider) |
Sets the source for the referenced (or "parent" / "left") layer, by sourceUri and provider ID. | |
void | setReferencedLayerFields (const QStringList &fields) |
Sets the list of fields from the referencedLayer() involved in the relationship. | |
void | setReferencingLayer (const QString &sourceUri, const QString &provider) |
Sets the source for the referencing (or "child" / "right") layer, by sourceUri and provider ID. | |
void | setReferencingLayerFields (const QStringList &fields) |
Sets the list of fields from the referencingLayer() involved in the relationship. | |
void | setRelatedTableType (const QString &type) |
Sets the type string of the related table. | |
Qgis::RelationshipStrength | strength () const |
Returns the strength of the relation. | |
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. | |
static void | writeXml (const QgsVectorLayer *layer, WeakRelationType type, const QgsRelation &relation, QDomNode &node, QDomDocument &doc) |
Writes a weak relation infoto an XML structure. | |
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 370 of file qgsweakrelation.h.
|
inline |
Returns the relationship's cardinality.
Definition at line 324 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 351 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 302 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 270 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 190 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 210 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 205 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 200 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 230 of file qgsweakrelation.cpp.
QgsVectorLayerRef QgsWeakRelation::referencedLayer | ( | ) | const |
Returns a weak reference to the referenced (or "parent" / "left") layer.
Definition at line 160 of file qgsweakrelation.cpp.
|
inline |
Returns the list of fields from the referencedLayer() involved in the relationship.
Definition at line 286 of file qgsweakrelation.h.
QString QgsWeakRelation::referencedLayerName | ( | ) | const |
Returns the layer name of the referenced (or "parent" / "left") layer.
Definition at line 175 of file qgsweakrelation.cpp.
QString QgsWeakRelation::referencedLayerProvider | ( | ) | const |
Returns the provider ID for the referenced (or "parent" / "left") layer.
Definition at line 170 of file qgsweakrelation.cpp.
QString QgsWeakRelation::referencedLayerSource | ( | ) | const |
Returns the source URI for the referenced (or "parent" / "left") layer.
Definition at line 165 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 254 of file qgsweakrelation.h.
QString QgsWeakRelation::referencingLayerName | ( | ) | const |
Returns the layer name of the referencing (or "child" / "right") layer.
Definition at line 151 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 421 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 408 of file qgsweakrelation.h.
|
inline |
Sets the relationship's cardinality.
Definition at line 332 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 389 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 311 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 279 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 195 of file qgsweakrelation.cpp.
void QgsWeakRelation::setMappingTable | ( | const QString & | sourceUri, |
const QString & | provider | ||
) |
Sets the source for the mapping table, which forms the middle table in many-to-many relationships, by sourceUri and provider ID.
Definition at line 219 of file qgsweakrelation.cpp.
void QgsWeakRelation::setReferencedLayer | ( | const QString & | sourceUri, |
const QString & | provider | ||
) |
Sets the source for the referenced (or "parent" / "left") layer, by sourceUri and provider ID.
Definition at line 184 of file qgsweakrelation.cpp.
|
inline |
Sets the list of fields from the referencedLayer() involved in the relationship.
Definition at line 293 of file qgsweakrelation.h.
void QgsWeakRelation::setReferencingLayer | ( | const QString & | sourceUri, |
const QString & | provider | ||
) |
Sets the source for the referencing (or "child" / "right") layer, by sourceUri and provider ID.
Definition at line 145 of file qgsweakrelation.cpp.
|
inline |
Sets the list of fields from the referencingLayer() involved in the relationship.
Definition at line 261 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 434 of file qgsweakrelation.h.
Qgis::RelationshipStrength QgsWeakRelation::strength | ( | ) | const |
Returns the strength of the relation.
Definition at line 225 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 298 of file qgsweakrelation.cpp.
|
friend |
Definition at line 501 of file qgsweakrelation.h.