QGIS API Documentation 3.39.0-Master (9ea1ddbe645)
|
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. | |
QgsPolymorphicRelation (const QgsPolymorphicRelation &other) | |
Copies a relation. | |
QgsPolymorphicRelation (const QgsRelationContext &context) | |
Constructor with context. | |
~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. | |
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. | |
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. | |
void | generateId () |
Generate a (project-wide) unique id for this relation. | |
QList< QgsRelation > | generateRelations () const |
Returns a list of generated relations, based on the currently set referencedLayerIds() | |
bool | hasEqualDefinition (const QgsPolymorphicRelation &other) const |
Compares the two QgsRelation, ignoring the name and the ID. | |
QString | id () const |
A (project-wide) unique id for this relation. | |
bool | isValid () const |
Returns the validity of this relation. | |
QString | layerRepresentation (const QgsVectorLayer *layer) const |
Returns layer representation as evaluated string. | |
QString | name () const |
Returns a human readable name for this relation. | |
QgsPolymorphicRelation & | operator= (const QgsPolymorphicRelation &other) |
Copies a relation. | |
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. | |
QString | referencedLayerExpression () const |
Returns the expression to identify the parent layer. | |
QString | referencedLayerField () const |
Returns the field in the referencing layer where the referenced layer identifier is stored. | |
QStringList | referencedLayerIds () const |
Returns a list of layer ids to be used as potential referenced layers. | |
QgsAttributeList | referencingFields () const |
Returns a list of attributes used to form the referencing fields (foreign key) on the referencing (child) layer. | |
QgsVectorLayer * | referencingLayer () const |
Access the referencing (child) layer This is the layer which has the field(s) which point to another layer. | |
QString | referencingLayerId () const |
Access the referencing (child) layer's id This is the layer which has the field(s) which point to another layer. | |
void | setId (const QString &id) |
Set an id for this relation. | |
void | setName (const QString &name) |
Set a name for this relation. | |
void | setReferencedLayerExpression (const QString &expression) |
Sets the expression to identify the parent layer. | |
void | setReferencedLayerField (const QString &referencedLayerField) |
Sets the field in the referencing layer where the referenced layer identifier is stored. | |
void | setReferencedLayerIds (const QStringList &childRelationIds) |
Sets a list of layer ids to be used as potential referenced layers. | |
void | setReferencingLayer (const QString &id) |
Set the referencing (child) layer id. | |
void | setRelationStrength (Qgis::RelationshipStrength relationStrength) |
Sets the relation strength for all the generated normal relations. | |
Qgis::RelationshipStrength | strength () const |
Returns the relation strength for all the generated normal relations. | |
void | updateRelationStatus () |
Updates the validity status of this relation. | |
void | writeXml (QDomNode &node, QDomDocument &doc) const |
Writes a relation to an XML structure. | |
Static Public Member Functions | |
static QgsPolymorphicRelation | createFromXml (const QDomNode &node, QgsReadWriteContext &context, const QgsRelationContext &relationContext=QgsRelationContext()) |
Creates a relation from an XML structure. | |
Properties | |
QString | id |
bool | isValid |
QString | name |
QString | referencedLayerExpression |
QString | referencedLayerField |
QgsVectorLayer * | referencingLayer |
Friends | |
class | QgsRelationManager |
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 24 of file qgspolymorphicrelation.cpp.
|
default |
QgsPolymorphicRelation::QgsPolymorphicRelation | ( | const QgsRelationContext & | context | ) |
Constructor with context.
Creates an invalid relation.
Definition at line 29 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 37 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 149 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 142 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 50 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 181 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::generateId | ( | ) |
Generate a (project-wide) unique id for this relation.
Definition at line 161 of file qgspolymorphicrelation.cpp.
QList< QgsRelation > QgsPolymorphicRelation::generateRelations | ( | ) | const |
Returns a list of generated relations, based on the currently set referencedLayerIds()
Definition at line 376 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 223 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::id | ( | ) | const |
A (project-wide) unique id for this relation.
Definition at line 156 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 218 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::layerRepresentation | ( | const QgsVectorLayer * | layer | ) | const |
Returns layer representation as evaluated string.
Definition at line 428 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 320 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 43 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 186 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::referencedLayerExpression | ( | ) | const |
Returns the expression to identify the parent layer.
Definition at line 347 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 335 of file qgspolymorphicrelation.cpp.
QStringList QgsPolymorphicRelation::referencedLayerIds | ( | ) | const |
Returns a list of layer ids to be used as potential referenced layers.
Definition at line 359 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 206 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 176 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 171 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setId | ( | const QString & | id | ) |
Set an id for this relation.
Definition at line 123 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setName | ( | const QString & | name | ) |
Set a name for this relation.
Definition at line 310 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setReferencedLayerExpression | ( | const QString & | expression | ) |
Sets the expression to identify the parent layer.
Definition at line 340 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 328 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 352 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 134 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setRelationStrength | ( | Qgis::RelationshipStrength | relationStrength | ) |
Sets the relation strength for all the generated normal relations.
Definition at line 369 of file qgspolymorphicrelation.cpp.
Qgis::RelationshipStrength QgsPolymorphicRelation::strength | ( | ) | const |
Returns the relation strength for all the generated normal relations.
Definition at line 364 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 231 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 97 of file qgspolymorphicrelation.cpp.
|
friend |
Definition at line 288 of file qgspolymorphicrelation.h.
|
readwrite |
Definition at line 53 of file qgspolymorphicrelation.h.
|
read |
Definition at line 58 of file qgspolymorphicrelation.h.
|
readwrite |
Definition at line 57 of file qgspolymorphicrelation.h.
|
read |
Definition at line 56 of file qgspolymorphicrelation.h.
|
read |
Definition at line 55 of file qgspolymorphicrelation.h.
|
read |
Definition at line 54 of file qgspolymorphicrelation.h.