QGIS API Documentation  3.17.0-Master (3b262f2a79)
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
QgsWeakRelation Class Reference

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 (const QString &relationId, const QString &relationName, const QgsRelation::RelationStrength 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, const QList< QgsRelation::FieldPair > &fieldPairs)
 Creates a QgsWeakRelation. More...
 
QList< QgsRelation::FieldPairfieldPairs () const
 Returns the list of field pairs. More...
 
QgsVectorLayerRef referencedLayer () const
 Returns a weak reference to the referenced layer. More...
 
QgsVectorLayerRef referencingLayer () const
 Returns a weak reference to the referencing layer. More...
 
QgsRelation resolvedRelation (const QgsProject *project, QgsVectorLayerRef::MatchType matchType=QgsVectorLayerRef::MatchType::All) const
 Resolves a weak relation in the given project returning a possibly invalid QgsRelation and without performing any kind of validity check. More...
 
QgsRelation::RelationStrength 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
 

Detailed Description

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.

Note
not available in Python bindings
Since
QGIS 3.12

Definition at line 38 of file qgsweakrelation.h.

Member Enumeration Documentation

◆ WeakRelationType

Enum to distinguish if the layer is referenced or referencing.

Since
QGIS 3.16
Enumerator
Referencing 

The layer is referencing.

Referenced 

The layer is referenced.

Definition at line 46 of file qgsweakrelation.h.

Constructor & Destructor Documentation

◆ QgsWeakRelation()

QgsWeakRelation::QgsWeakRelation ( const QString &  relationId,
const QString &  relationName,
const QgsRelation::RelationStrength  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,
const QList< QgsRelation::FieldPair > &  fieldPairs 
)

Creates a QgsWeakRelation.

Definition at line 22 of file qgsweakrelation.cpp.

Member Function Documentation

◆ fieldPairs()

QList< QgsRelation::FieldPair > QgsWeakRelation::fieldPairs ( ) const

Returns the list of field pairs.

Definition at line 75 of file qgsweakrelation.cpp.

◆ readXml()

QgsWeakRelation QgsWeakRelation::readXml ( const QgsVectorLayer layer,
WeakRelationType  type,
const QDomNode &  node,
const QgsPathResolver  resolver 
)
static

Returns a weak relation for the given layer.

Parameters
layerthe layer of the weak relation
typedetermines if the layer is referencing or referenced
nodethe QDomNode
resolverthe path resolver
Since
QGIS 3.16

Definition at line 80 of file qgsweakrelation.cpp.

◆ referencedLayer()

QgsVectorLayerRef QgsWeakRelation::referencedLayer ( ) const

Returns a weak reference to the referenced layer.

Definition at line 65 of file qgsweakrelation.cpp.

◆ referencingLayer()

QgsVectorLayerRef QgsWeakRelation::referencingLayer ( ) const

Returns a weak reference to the referencing layer.

Definition at line 60 of file qgsweakrelation.cpp.

◆ resolvedRelation()

QgsRelation QgsWeakRelation::resolvedRelation ( const QgsProject project,
QgsVectorLayerRef::MatchType  matchType = QgsVectorLayerRef::MatchType::All 
) const

Resolves a weak relation in the given project returning a possibly invalid QgsRelation and without performing any kind of validity check.

Note
Client code should never assume that the returned relation is valid and the layer components are not NULL.

Definition at line 35 of file qgsweakrelation.cpp.

◆ strength()

QgsRelation::RelationStrength QgsWeakRelation::strength ( ) const

Returns the strength of the relation.

Definition at line 70 of file qgsweakrelation.cpp.

◆ writeXml()

void QgsWeakRelation::writeXml ( const QgsVectorLayer layer,
WeakRelationType  type,
const QgsRelation relation,
QDomNode &  node,
QDomDocument &  doc 
)
static

Writes a weak relation infoto an XML structure.

Used for saving .qgs projects

Parameters
layerthe layer which we save the weak relation for
typedetermines if the layer is referencing or referenced
relationthe relation to save as a weak relation
nodeThe parent node in which the relation will be created
docThe document in which the relation will be saved
Since
QGIS 3.16

Definition at line 139 of file qgsweakrelation.cpp.

Friends And Related Function Documentation

◆ TestQgsWeakRelation

friend class TestQgsWeakRelation
friend

Definition at line 130 of file qgsweakrelation.h.


The documentation for this class was generated from the following files: