QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
|
This class manages a set of relations between layers. More...
#include <qgsrelationmanager.h>
Public Slots | |
void | updateRelationsStatus () |
Updates relations status. More... | |
Signals | |
void | changed () |
Emitted when relations are added or removed to the manager. More... | |
void | relationsLoaded () |
Emitted when the relations were loaded after reading a project. More... | |
Public Member Functions | |
QgsRelationManager (QgsProject *project=nullptr) | |
Constructor for QgsRelationManager. More... | |
void | addPolymorphicRelation (const QgsPolymorphicRelation &polymorphicRelation) |
Adds a new polymorphic relation. More... | |
void | addRelation (const QgsRelation &relation) |
Add a relation. More... | |
void | clear () |
Remove any relation managed by this class. More... | |
QgsRelationContext | context () const |
Gets the relation context. More... | |
QgsPolymorphicRelation | polymorphicRelation (const QString &polymorphicRelationId) const |
Returns the list of relations associated with a polymorphic relation. More... | |
QMap< QString, QgsPolymorphicRelation > | polymorphicRelations () const |
Returns all the polymorphic relations. More... | |
QList< QgsRelation > | referencedRelations (const QgsVectorLayer *layer=nullptr) const |
Gets all relations where this layer is the referenced part (i.e. More... | |
QList< QgsRelation > | referencingRelations (const QgsVectorLayer *layer=nullptr, int fieldIdx=-2) const |
Gets all relations where the specified layer (and field) is the referencing part (i.e. More... | |
Q_INVOKABLE QgsRelation | relation (const QString &id) const |
Gets access to a relation by its id. More... | |
QMap< QString, QgsRelation > | relations () const |
Gets access to the relations managed by this class. More... | |
QList< QgsRelation > | relationsByName (const QString &name) const |
Returns a list of relations with matching names. More... | |
void | removePolymorphicRelation (const QString &polymorphicRelationId) |
Removes an existing polymorphic relation and it's generated relations. More... | |
void | removeRelation (const QgsRelation &relation) |
Remove a relation. More... | |
void | removeRelation (const QString &id) |
Remove a relation. More... | |
void | setPolymorphicRelations (const QList< QgsPolymorphicRelation > &relations) |
Sets the specified polymorphic relations and removes any polymorphic relations currently set. More... | |
void | setRelations (const QList< QgsRelation > &relations) |
Will set the specified relations and remove any relation currently set. More... | |
Static Public Member Functions | |
static QList< QgsRelation > | discoverRelations (const QList< QgsRelation > &existingRelations, const QList< QgsVectorLayer * > &layers) |
Discover all the relations available from the current layers. More... | |
This class manages a set of relations between layers.
Definition at line 35 of file qgsrelationmanager.h.
|
explicit |
Constructor for QgsRelationManager.
project | associated project (used to notify project of changes) |
Definition at line 23 of file qgsrelationmanager.cpp.
void QgsRelationManager::addPolymorphicRelation | ( | const QgsPolymorphicRelation & | polymorphicRelation | ) |
Adds a new polymorphic relation.
The generated relations are not available, they will be created automatically.
Definition at line 322 of file qgsrelationmanager.cpp.
void QgsRelationManager::addRelation | ( | const QgsRelation & | relation | ) |
Add a relation.
Invalid relations are added only if both referencing layer and referenced layer exist.
relation | The relation to add. |
Definition at line 58 of file qgsrelationmanager.cpp.
|
signal |
Emitted when relations are added or removed to the manager.
void QgsRelationManager::clear | ( | ) |
Remove any relation managed by this class.
Definition at line 112 of file qgsrelationmanager.cpp.
QgsRelationContext QgsRelationManager::context | ( | ) | const |
Gets the relation context.
Definition at line 38 of file qgsrelationmanager.cpp.
|
static |
Discover all the relations available from the current layers.
existingRelations | the existing relations to filter them out |
layers | the current layers |
Definition at line 292 of file qgsrelationmanager.cpp.
QgsPolymorphicRelation QgsRelationManager::polymorphicRelation | ( | const QString & | polymorphicRelationId | ) | const |
Returns the list of relations associated with a polymorphic relation.
Definition at line 317 of file qgsrelationmanager.cpp.
QMap< QString, QgsPolymorphicRelation > QgsRelationManager::polymorphicRelations | ( | ) | const |
Returns all the polymorphic relations.
Definition at line 312 of file qgsrelationmanager.cpp.
QList< QgsRelation > QgsRelationManager::referencedRelations | ( | const QgsVectorLayer * | layer = nullptr | ) | const |
Gets all relations where this layer is the referenced part (i.e.
the parent table with the primary key being referenced from another layer).
layer | The layer which should be searched for. |
Definition at line 156 of file qgsrelationmanager.cpp.
QList< QgsRelation > QgsRelationManager::referencingRelations | ( | const QgsVectorLayer * | layer = nullptr , |
int | fieldIdx = -2 |
||
) | const |
Gets all relations where the specified layer (and field) is the referencing part (i.e.
the child table with the foreign key).
layer | The layer which should be searched for. |
fieldIdx | The field which should be part of the foreign key. If not set will return all relations. |
Definition at line 118 of file qgsrelationmanager.cpp.
QgsRelation QgsRelationManager::relation | ( | const QString & | id | ) | const |
Gets access to a relation by its id.
id | The id to search for |
Definition at line 94 of file qgsrelationmanager.cpp.
QMap< QString, QgsRelation > QgsRelationManager::relations | ( | ) | const |
Gets access to the relations managed by this class.
Definition at line 53 of file qgsrelationmanager.cpp.
QList< QgsRelation > QgsRelationManager::relationsByName | ( | const QString & | name | ) | const |
Returns a list of relations with matching names.
name | relation name to search for. Searching is case insensitive. |
Definition at line 99 of file qgsrelationmanager.cpp.
|
signal |
Emitted when the relations were loaded after reading a project.
void QgsRelationManager::removePolymorphicRelation | ( | const QString & | polymorphicRelationId | ) |
Removes an existing polymorphic relation and it's generated relations.
Definition at line 334 of file qgsrelationmanager.cpp.
void QgsRelationManager::removeRelation | ( | const QgsRelation & | relation | ) |
Remove a relation.
relation | The relation to remove. |
Definition at line 88 of file qgsrelationmanager.cpp.
void QgsRelationManager::removeRelation | ( | const QString & | id | ) |
Remove a relation.
id | The id of the relation to remove. |
Definition at line 82 of file qgsrelationmanager.cpp.
void QgsRelationManager::setPolymorphicRelations | ( | const QList< QgsPolymorphicRelation > & | relations | ) |
Sets the specified polymorphic relations and removes any polymorphic relations currently set.
Will remove any generated relations and recreate them.
Definition at line 343 of file qgsrelationmanager.cpp.
void QgsRelationManager::setRelations | ( | const QList< QgsRelation > & | relations | ) |
Will set the specified relations and remove any relation currently set.
relations | A list of relations to set. |
Definition at line 43 of file qgsrelationmanager.cpp.
|
slot |
Updates relations status.
Definition at line 73 of file qgsrelationmanager.cpp.