Class: QgsRelationManager¶
-
class
qgis.core.
QgsRelationManager
(project: QgsProject = None)¶ Bases:
PyQt5.QtCore.QObject
Constructor for QgsRelationManager.
- Parameters
project – associated project (used to notify project of changes)
This class manages a set of relations between layers.
Enums
Methods
Add a relation.
Remove any relation managed by this class.
Discover all the relations available from the current layers.
Gets all relations where this layer is the referenced part (i.e.
Gets all relations where the specified layer (and field) is the referencing part (i.e.
Gets access to a relation by its id.
Gets access to the relations managed by this class.
Returns a list of relations with matching names.
Remove a relation.
Will set the specified relations and remove any relation currently set.
Updates relations status
Signals
Emitted when relations are added or removed to the manager.
Emitted when the relations were loaded after reading a project [signal]
Attributes
-
addRelation
(self, relation: QgsRelation)¶ Add a relation. Invalid relations are added only if both referencing layer and referenced layer exist.
- Parameters
relation – The relation to add.
-
changed
¶ Emitted when relations are added or removed to the manager.
New in version 2.5: [signal]
-
childEvent
()¶
-
clear
(self)¶ Remove any relation managed by this class.
-
connectNotify
()¶
-
customEvent
()¶
-
disconnectNotify
()¶
-
discoverRelations
(existingRelations: Iterable[QgsRelation], layers: Iterable[QgsVectorLayer]) → List[QgsRelation]¶ Discover all the relations available from the current layers.
- Parameters
existingRelations – the existing relations to filter them out
layers – the current layers
- Returns
the list of discovered relations
New in version 3.0.
-
isSignalConnected
()¶
-
receivers
()¶
-
referencedRelations
(self, layer: QgsVectorLayer = None) → List[QgsRelation]¶ Gets all relations where this layer is the referenced part (i.e. the parent table with the primary key being referenced from another layer).
- Parameters
layer – The layer which should be searched for.
- Returns
A list of relations where the specified layer is the referenced part.
-
referencingRelations
(self, layer: QgsVectorLayer = None, fieldIdx: int = -2) → List[QgsRelation]¶ Gets all relations where the specified layer (and field) is the referencing part (i.e. the child table with the foreign key).
- Parameters
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.
- Returns
A list of relations matching the given layer and fieldIdx.
-
relation
(self, id: str) → QgsRelation¶ Gets access to a relation by its id.
- Parameters
id – The id to search for
- Returns
A relation. Invalid if not found.
See also
-
relations
(self) → Dict[str, QgsRelation]¶ Gets access to the relations managed by this class.
- Returns
A QMap where the key is the relation id, the value the relation object.
-
relationsByName
(self, name: str) → List[QgsRelation]¶ Returns a list of relations with matching names.
- Parameters
name – relation name to search for. Searching is case insensitive.
- Returns
a list of matching relations
See also
New in version 2.16.
-
relationsLoaded
¶ Emitted when the relations were loaded after reading a project [signal]
-
removeRelation
(self, id: str)¶ Remove a relation.
- Parameters
id – The id of the relation to remove.
removeRelation(self, relation: QgsRelation) Remove a relation.
- Parameters
relation – The relation to remove.
-
sender
()¶
-
senderSignalIndex
()¶
-
setRelations
(self, relations: Iterable[QgsRelation])¶ Will set the specified relations and remove any relation currently set.
- Parameters
relations – A list of relations to set.
-
timerEvent
()¶
-
updateRelationsStatus
(self)¶ Updates relations status