QGIS API Documentation 3.41.0-Master (cea29feecf2)
|
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 25 of file qgspolymorphicrelation.cpp.
|
default |
QgsPolymorphicRelation::QgsPolymorphicRelation | ( | const QgsRelationContext & | context | ) |
Constructor with context.
Creates an invalid relation.
Definition at line 30 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 38 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 150 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 143 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 51 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 182 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::generateId | ( | ) |
Generate a (project-wide) unique id for this relation.
Definition at line 162 of file qgspolymorphicrelation.cpp.
QList< QgsRelation > QgsPolymorphicRelation::generateRelations | ( | ) | const |
Returns a list of generated relations, based on the currently set referencedLayerIds()
Definition at line 377 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 224 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::id | ( | ) | const |
A (project-wide) unique id for this relation.
Definition at line 157 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 219 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::layerRepresentation | ( | const QgsVectorLayer * | layer | ) | const |
Returns layer representation as evaluated string.
Definition at line 429 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 321 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 44 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 187 of file qgspolymorphicrelation.cpp.
QString QgsPolymorphicRelation::referencedLayerExpression | ( | ) | const |
Returns the expression to identify the parent layer.
Definition at line 348 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 336 of file qgspolymorphicrelation.cpp.
QStringList QgsPolymorphicRelation::referencedLayerIds | ( | ) | const |
Returns a list of layer ids to be used as potential referenced layers.
Definition at line 360 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 207 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 177 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 172 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setId | ( | const QString & | id | ) |
Set an id for this relation.
Definition at line 124 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setName | ( | const QString & | name | ) |
Set a name for this relation.
Definition at line 311 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setReferencedLayerExpression | ( | const QString & | expression | ) |
Sets the expression to identify the parent layer.
Definition at line 341 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 329 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 353 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 135 of file qgspolymorphicrelation.cpp.
void QgsPolymorphicRelation::setRelationStrength | ( | Qgis::RelationshipStrength | relationStrength | ) |
Sets the relation strength for all the generated normal relations.
Definition at line 370 of file qgspolymorphicrelation.cpp.
Qgis::RelationshipStrength QgsPolymorphicRelation::strength | ( | ) | const |
Returns the relation strength for all the generated normal relations.
Definition at line 365 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 232 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 98 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.