QGIS API Documentation
3.0.2-Girona (307d082)
|
#include <qgsrelation.h>
Classes | |
class | FieldPair |
Defines a relation between matching fields of the two involved tables of a relation. More... | |
Public Types | |
enum | RelationStrength { Association, Composition } |
enum for the relation strength Association, Composition More... | |
Public Member Functions | |
QgsRelation ()=default | |
Default constructor. More... | |
void | addFieldPair (const QString &referencingField, const QString &referencedField) |
Add a field pairs which is part of this relation The first element of each pair are the field names of the foreign key. More... | |
void | addFieldPair (const FieldPair &fieldPair) |
Add a field pairs 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... | |
QgsFeature | getReferencedFeature (const QgsFeature &feature) const |
Creates a request to return the feature on the referenced (parent) layer which is referenced by the provided feature. More... | |
QgsFeatureRequest | getReferencedFeatureRequest (const QgsAttributes &attributes) const |
Creates a request to return the feature on the referenced (parent) layer which is referenced by the provided feature. More... | |
QgsFeatureRequest | getReferencedFeatureRequest (const QgsFeature &feature) const |
Creates a request to return the feature on the referenced (parent) layer which is referenced by the provided feature. More... | |
QgsFeatureIterator | getRelatedFeatures (const QgsFeature &feature) const |
Creates an iterator which returns all the features on the referencing (child) layer which have a foreign key pointing to the provided feature. More... | |
QString | getRelatedFeaturesFilter (const QgsFeature &feature) const |
Returns a filter expression which returns all the features on the referencing (child) layer which have a foreign key pointing to the provided feature. More... | |
QgsFeatureRequest | getRelatedFeaturesRequest (const QgsFeature &feature) const |
Creates a request to return all the features on the referencing (child) layer which have a foreign key pointing to the provided feature. More... | |
bool | hasEqualDefinition (const QgsRelation &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 | name () const |
Returns a human readable name for this relation. More... | |
QgsAttributeList | referencedFields () const |
Returns a list of attributes used to form the referenced fields (most likely primary key) on the referenced (parent) layer. More... | |
QgsVectorLayer * | referencedLayer () const |
Access the referenced (parent) layer. More... | |
QString | referencedLayerId () const |
Access the referenced (parent) layer's id. 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... | |
Q_INVOKABLE QString | resolveReferencedField (const QString &referencingField) const |
Get the referenced field counterpart given a referencing field. More... | |
Q_INVOKABLE QString | resolveReferencingField (const QString &referencedField) const |
Get the referencing field counterpart given a referenced field. 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 | setReferencedLayer (const QString &id) |
Set the referenced (parent) layer id. More... | |
void | setReferencingLayer (const QString &id) |
Set the referencing (child) layer id. More... | |
void | setStrength (RelationStrength strength) |
Set a strength for this relation. More... | |
RelationStrength | strength () const |
Returns the relation strength as a string. More... | |
void | writeXml (QDomNode &node, QDomDocument &doc) const |
Writes a relation to an XML structure. More... | |
Static Public Member Functions | |
static QgsRelation | createFromXml (const QDomNode &node) |
Creates a relation from an XML structure. More... | |
Properties | |
QString | id |
bool | isValid |
QString | name |
QgsVectorLayer | referencedLayer |
QgsVectorLayer | referencingLayer |
Definition at line 38 of file qgsrelation.h.
enum for the relation strength Association, Composition
Definition at line 55 of file qgsrelation.h.
|
default |
Default constructor.
Creates an invalid relation.
void QgsRelation::addFieldPair | ( | const QString & | referencingField, |
const QString & | referencedField | ||
) |
Add a field pairs 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 154 of file qgsrelation.cpp.
void QgsRelation::addFieldPair | ( | const FieldPair & | fieldPair | ) |
Add a field pairs 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 160 of file qgsrelation.cpp.
|
static |
Creates a relation from an XML structure.
Used for reading .qgs projects.
node | The dom node containing the relation information |
Definition at line 24 of file qgsrelation.cpp.
QList< QgsRelation::FieldPair > QgsRelation::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 272 of file qgsrelation.cpp.
void QgsRelation::generateId | ( | ) |
Generate a (project-wide) unique id for this relation.
Definition at line 242 of file qgsrelation.cpp.
QgsFeature QgsRelation::getReferencedFeature | ( | const QgsFeature & | feature | ) | const |
Creates a request to return the feature on the referenced (parent) layer which is referenced by the provided feature.
feature | A feature from the referencing (child) layer |
Definition at line 218 of file qgsrelation.cpp.
QgsFeatureRequest QgsRelation::getReferencedFeatureRequest | ( | const QgsAttributes & | attributes | ) | const |
Creates a request to return the feature on the referenced (parent) layer which is referenced by the provided feature.
attributes | An attribute vector containing the foreign key |
Definition at line 194 of file qgsrelation.cpp.
QgsFeatureRequest QgsRelation::getReferencedFeatureRequest | ( | const QgsFeature & | feature | ) | const |
Creates a request to return the feature on the referenced (parent) layer which is referenced by the provided feature.
feature | A feature from the referencing (child) layer |
Definition at line 213 of file qgsrelation.cpp.
QgsFeatureIterator QgsRelation::getRelatedFeatures | ( | const QgsFeature & | feature | ) | const |
Creates an iterator which returns all the features on the referencing (child) layer which have a foreign key pointing to the provided feature.
feature | A feature from the referenced (parent) layer |
Definition at line 166 of file qgsrelation.cpp.
QString QgsRelation::getRelatedFeaturesFilter | ( | const QgsFeature & | feature | ) | const |
Returns a filter expression which returns all the features on the referencing (child) layer which have a foreign key pointing to the provided feature.
feature | A feature from the referenced (parent) layer |
Definition at line 181 of file qgsrelation.cpp.
QgsFeatureRequest QgsRelation::getRelatedFeaturesRequest | ( | const QgsFeature & | feature | ) | const |
Creates a request to return all the features on the referencing (child) layer which have a foreign key pointing to the provided feature.
feature | A feature from the referenced (parent) layer |
Definition at line 171 of file qgsrelation.cpp.
bool QgsRelation::hasEqualDefinition | ( | const QgsRelation & | other | ) | const |
Compares the two QgsRelation, ignoring the name and the ID.
other | The other relation |
Definition at line 305 of file qgsrelation.cpp.
QString QgsRelation::id | ( | ) | const |
A (project-wide) unique id for this relation.
bool QgsRelation::isValid | ( | ) | const |
Returns the validity of this relation.
Don't use the information if it's not valid.
QString QgsRelation::name | ( | ) | const |
Returns a human readable name for this relation.
Mostly used as title for the children.
QgsAttributeList QgsRelation::referencedFields | ( | ) | const |
Returns a list of attributes used to form the referenced fields (most likely primary key) on the referenced (parent) layer.
Definition at line 277 of file qgsrelation.cpp.
QgsVectorLayer* QgsRelation::referencedLayer | ( | ) | const |
Access the referenced (parent) layer.
QString QgsRelation::referencedLayerId | ( | ) | const |
Access the referenced (parent) layer's id.
Definition at line 262 of file qgsrelation.cpp.
QgsAttributeList QgsRelation::referencingFields | ( | ) | const |
Returns a list of attributes used to form the referencing fields (foreign key) on the referencing (child) layer.
Definition at line 288 of file qgsrelation.cpp.
QgsVectorLayer* QgsRelation::referencingLayer | ( | ) | const |
Access the referencing (child) layer This is the layer which has the field(s) which point to another layer.
QString QgsRelation::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 252 of file qgsrelation.cpp.
QString QgsRelation::resolveReferencedField | ( | const QString & | referencingField | ) | const |
Get the referenced field counterpart given a referencing field.
Definition at line 310 of file qgsrelation.cpp.
QString QgsRelation::resolveReferencingField | ( | const QString & | referencedField | ) | const |
Get the referencing field counterpart given a referenced field.
Definition at line 320 of file qgsrelation.cpp.
void QgsRelation::setId | ( | const QString & | id | ) |
Set an id for this relation.
Definition at line 122 of file qgsrelation.cpp.
void QgsRelation::setName | ( | const QString & | name | ) |
Set a name for this relation.
Definition at line 129 of file qgsrelation.cpp.
void QgsRelation::setReferencedLayer | ( | const QString & | id | ) |
Set the referenced (parent) layer id.
This layer will be searched in the registry.
Definition at line 147 of file qgsrelation.cpp.
void QgsRelation::setReferencingLayer | ( | const QString & | id | ) |
Set the referencing (child) layer id.
This layer will be searched in the registry.
Definition at line 140 of file qgsrelation.cpp.
void QgsRelation::setStrength | ( | RelationStrength | strength | ) |
QgsRelation::RelationStrength QgsRelation::strength | ( | ) | const |
Returns the relation strength as a string.
Definition at line 232 of file qgsrelation.cpp.
void QgsRelation::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 95 of file qgsrelation.cpp.
|
readwrite |
Definition at line 42 of file qgsrelation.h.
|
read |
Definition at line 46 of file qgsrelation.h.
|
readwrite |
Definition at line 45 of file qgsrelation.h.
|
read |
Definition at line 44 of file qgsrelation.h.
|
read |
Definition at line 43 of file qgsrelation.h.