QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
A polymorphic relation consists of the same properties like a normal relation except for the referenced layer which is calculated based on one or several fields of the referencing layer. More...
#include <qgspolymorphicrelation.h>
Public Member Functions | |
QgsPolymorphicRelation () | |
Default constructor. More... | |
QgsPolymorphicRelation (const QgsPolymorphicRelation &other) | |
Copies a relation. More... | |
QgsPolymorphicRelation (const QgsRelationContext &context) | |
Constructor with context. More... | |
~QgsPolymorphicRelation () | |
void | addFieldPair (const QgsRelation::FieldPair &fieldPair) |
Add a field pair which is part of this relation The first element of each pair are the field names of the foreign key. More... | |
void | addFieldPair (const QString &referencingField, const QString &referencedField) |
Add a field pair which is part of this relation The first element of each pair are the field names of the foreign key. More... | |
QList< QgsRelation::FieldPair > | fieldPairs () const |
Returns the field pairs which form this relation The first element of each pair are the field names of the foreign key. More... | |
void | generateId () |
Generate a (project-wide) unique id for this relation. More... | |
QList< QgsRelation > | generateRelations () const |
Returns a list of generated relations, based on the currently set referencedLayerIds() More... | |
bool | hasEqualDefinition (const QgsPolymorphicRelation &other) const |
Compares the two QgsRelation, ignoring the name and the ID. More... | |
QString | id () const |
A (project-wide) unique id for this relation. More... | |
bool | isValid () const |
Returns the validity of this relation. More... | |
QString | layerRepresentation (const QgsVectorLayer *layer) const |
Returns layer representation as evaluated string. More... | |
QString | name () const |
Returns a human readable name for this relation. More... | |
QgsPolymorphicRelation & | operator= (const QgsPolymorphicRelation &other) |
Copies a relation. More... | |
QgsAttributeList | referencedFields (const QString &layerId) const |
Returns a list of attributes used to form the referenced fields (most likely primary key) on the referenced (parent) layer. More... | |
QString | referencedLayerExpression () const |
Returns the expression to identify the parent layer. More... | |
QString | referencedLayerField () const |
Returns the field in the referencing layer where the referenced layer identifier is stored. More... | |
QStringList | referencedLayerIds () const |
Returns a list of layer ids to be used as potential referenced layers. More... | |
QgsAttributeList | referencingFields () const |
Returns a list of attributes used to form the referencing fields (foreign key) on the referencing (child) layer. More... | |
QgsVectorLayer * | referencingLayer () const |
Access the referencing (child) layer This is the layer which has the field(s) which point to another layer. More... | |
QString | referencingLayerId () const |
Access the referencing (child) layer's id This is the layer which has the field(s) which point to another layer. More... | |
void | setId (const QString &id) |
Set an id for this relation. More... | |
void | setName (const QString &name) |
Set a name for this relation. More... | |
void | setReferencedLayerExpression (const QString &expression) |
Sets the expression to identify the parent layer. More... | |
void | setReferencedLayerField (const QString &referencedLayerField) |
Sets the field in the referencing layer where the referenced layer identifier is stored. More... | |
void | setReferencedLayerIds (const QStringList &childRelationIds) |
Sets a list of layer ids to be used as potential referenced layers. More... | |
void | setReferencingLayer (const QString &id) |
Set the referencing (child) layer id. More... | |
void | setRelationStrength (QgsRelation::RelationStrength relationStrength) |
Sets the relation strength for all the generated normal relations. More... | |
QgsRelation::RelationStrength | strength () const |
Returns the relation strength for all the generated normal relations. More... | |
void | updateRelationStatus () |
Updates the validity status of this relation. More... | |
void | writeXml (QDomNode &node, QDomDocument &doc) const |
Writes a relation to an XML structure. More... | |
Static Public Member Functions | |
static QgsPolymorphicRelation | createFromXml (const QDomNode &node, QgsReadWriteContext &context, const QgsRelationContext &relationContext=QgsRelationContext()) |
Creates a relation from an XML structure. More... | |
Properties | |
Q_GADGET QString | id |
bool | isValid |
QString | name |
QString | referencedLayerExpression |
QString | referencedLayerField |
QgsVectorLayer * | referencingLayer |
A polymorphic relation consists of the same properties like a normal relation except for the referenced layer which is calculated based on one or several fields of the referencing layer.
In its most simple form, the referencing layer will just insert the layer name of the referenced layer into this field. To be more precise, a polymorphic relation is a set of normal relations having the same referencing layer but having the referenced layer dynamically defined. The polymorphic setting of the layer is solved by using an expression which has to match some properties of the the referenced layer like the table name, schema, uri, layer id, ...
Definition at line 49 of file qgspolymorphicrelation.h.
QgsPolymorphicRelation::QgsPolymorphicRelation | ( | ) |
Default constructor.
Creates an invalid relation.
Definition at line 26 of file qgspolymorphicrelation.cpp.
|
default |
QgsPolymorphicRelation::QgsPolymorphicRelation | ( | const QgsRelationContext & | context | ) |
Constructor with context.
Creates an invalid relation.
Definition at line 31 of file qgspolymorphicrelation.cpp.
QgsPolymorphicRelation::QgsPolymorphicRelation | ( | const QgsPolymorphicRelation & | other | ) |
Copies a relation.
This makes a shallow copy, relations are implicitly shared and only duplicated when the copy is changed.
Definition at line 39 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::addFieldPair | ( | const QgsRelation::FieldPair & | fieldPair | ) |
Add a field pair which is part of this relation The first element of each pair are the field names of the foreign key.
The second element of each pair are the field names of the matching primary key.
fieldPair | A pair of two strings |
Definition at line 151 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::addFieldPair | ( | const QString & | referencingField, |
const QString & | referencedField | ||
) |
Add a field pair which is part of this relation The first element of each pair are the field names of the foreign key.
The second element of each pair are the field names of the matching primary key.
referencingField | The field name on the referencing (child) layer (FK) |
referencedField | The field name on the referenced (parent) layer (PK) |
Definition at line 144 of file qgspolymorphicrelation.cpp.
|
static |
Creates a relation from an XML structure.
Used for reading .qgs projects.
node | The dom node containing the relation information |
context | to pass project translator |
relationContext | a relation context |
Definition at line 52 of file qgspolymorphicrelation.cpp.
QList< QgsRelation::FieldPair > QgsPolymorphicRelation::fieldPairs | ( | ) | const |
Returns the field pairs which form this relation The first element of each pair are the field names of the foreign key.
The second element of each pair are the field names of the matching primary key.
Definition at line 183 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::generateId | ( | ) |
Generate a (project-wide) unique id for this relation.
Definition at line 163 of file qgspolymorphicrelation.cpp.
QList< QgsRelation > QgsPolymorphicRelation::generateRelations | ( | ) | const |
Returns a list of generated relations, based on the currently set referencedLayerIds()
Definition at line 378 of file qgspolymorphicrelation.cpp.
bool QgsPolymorphicRelation::hasEqualDefinition | ( | const QgsPolymorphicRelation & | other | ) | const |
Compares the two QgsRelation, ignoring the name and the ID.
other | The other relation |
true
if they are similar Definition at line 225 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::id | ( | ) | const |
A (project-wide) unique id for this relation.
Definition at line 158 of file qgspolymorphicrelation.cpp.
bool QgsPolymorphicRelation::isValid | ( | ) | const |
Returns the validity of this relation.
Don't use the information if it's not valid. A relation is considered valid if both referenced and referencig layers are valid.
true
if the relation is valid Definition at line 220 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::layerRepresentation | ( | const QgsVectorLayer * | layer | ) | const |
Returns layer representation as evaluated string.
Definition at line 412 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::name | ( | ) | const |
Returns a human readable name for this relation.
Mostly used as title for the children.
Definition at line 322 of file qgspolymorphicrelation.cpp.
QgsPolymorphicRelation & QgsPolymorphicRelation::operator= | ( | const QgsPolymorphicRelation & | other | ) |
Copies a relation.
This makes a shallow copy, relations are implicitly shared and only duplicated when the copy is changed.
Definition at line 45 of file qgspolymorphicrelation.cpp.
QgsAttributeList QgsPolymorphicRelation::referencedFields | ( | const QString & | layerId | ) | const |
Returns a list of attributes used to form the referenced fields (most likely primary key) on the referenced (parent) layer.
Definition at line 188 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::referencedLayerExpression | ( | ) | const |
Returns the expression to identify the parent layer.
Definition at line 349 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::referencedLayerField | ( | ) | const |
Returns the field in the referencing layer where the referenced layer identifier is stored.
Definition at line 337 of file qgspolymorphicrelation.cpp.
QStringList QgsPolymorphicRelation::referencedLayerIds | ( | ) | const |
Returns a list of layer ids to be used as potential referenced layers.
Definition at line 361 of file qgspolymorphicrelation.cpp.
QgsAttributeList QgsPolymorphicRelation::referencingFields | ( | ) | const |
Returns a list of attributes used to form the referencing fields (foreign key) on the referencing (child) layer.
Definition at line 208 of file qgspolymorphicrelation.cpp.
QgsVectorLayer * QgsPolymorphicRelation::referencingLayer | ( | ) | const |
Access the referencing (child) layer This is the layer which has the field(s) which point to another layer.
Definition at line 178 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::referencingLayerId | ( | ) | const |
Access the referencing (child) layer's id This is the layer which has the field(s) which point to another layer.
Definition at line 173 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setId | ( | const QString & | id | ) |
Set an id for this relation.
Definition at line 125 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setName | ( | const QString & | name | ) |
Set a name for this relation.
Definition at line 312 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setReferencedLayerExpression | ( | const QString & | expression | ) |
Sets the expression to identify the parent layer.
Definition at line 342 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setReferencedLayerField | ( | const QString & | referencedLayerField | ) |
Sets the field in the referencing layer where the referenced layer identifier is stored.
Definition at line 330 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setReferencedLayerIds | ( | const QStringList & | childRelationIds | ) |
Sets a list of layer ids to be used as potential referenced layers.
Definition at line 354 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setReferencingLayer | ( | const QString & | id | ) |
Set the referencing (child) layer id.
This layer will be searched in the registry.
Definition at line 136 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setRelationStrength | ( | QgsRelation::RelationStrength | relationStrength | ) |
Sets the relation strength for all the generated normal relations.
Definition at line 371 of file qgspolymorphicrelation.cpp.
QgsRelation::RelationStrength QgsPolymorphicRelation::strength | ( | ) | const |
Returns the relation strength for all the generated normal relations.
Definition at line 366 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::updateRelationStatus | ( | ) |
Updates the validity status of this relation.
Will be called internally whenever a member is changed.
Definition at line 233 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::writeXml | ( | QDomNode & | node, |
QDomDocument & | doc | ||
) | const |
Writes a relation to an XML structure.
Used for saving .qgs projects
node | The parent node in which the relation will be created |
doc | The document in which the relation will be saved |
Definition at line 99 of file qgspolymorphicrelation.cpp.
|
readwrite |
Definition at line 51 of file qgspolymorphicrelation.h.
|
read |
Definition at line 51 of file qgspolymorphicrelation.h.
|
readwrite |
Definition at line 51 of file qgspolymorphicrelation.h.
|
read |
Definition at line 51 of file qgspolymorphicrelation.h.
|
read |
Definition at line 51 of file qgspolymorphicrelation.h.
|
read |
Definition at line 51 of file qgspolymorphicrelation.h.