Class: QgsVectorLayerEditBufferGroup¶
The edit buffer group manages a group of edit buffers.
Commands like commit and rollback are managed by the group invokes
individual addFeature()
, deleteFeature()
, … in the
correct order across all contained edit buffers.
Added in version 3.26.
Class Hierarchy¶
Base classes¶
Methods
Add a layer to this edit buffer group. |
|
Remove all layers from this edit buffer group. |
|
Attempts to commit any changes to disk. |
|
Returns |
|
Gets the set of layers currently managed by this edit buffer group. |
|
Gets the set of modified layers currently managed by this edit buffer group. |
|
Remove a layer from this edit buffer group. |
|
Stop editing and discard the edits |
|
Start editing |
- class qgis.core.QgsVectorLayerEditBufferGroup[source]¶
Bases:
QObject
- __init__(parent: QObject | None = None)
Constructor for
QgsEditBufferGroup
- Parameters:
parent (Optional[QObject] = None)
- addLayer(self, layer: QgsVectorLayer | None)[source]¶
Add a layer to this edit buffer group.
- Parameters:
layer (Optional[QgsVectorLayer])
- commitChanges(self, stopEditing: bool = True)[source]¶
Attempts to commit any changes to disk. Returns the result of the attempt. If a commit fails, the in-memory changes are left alone.
This allows editing to continue if the commit failed on e.g. a disallowed value in a Postgres database - the user can re-edit and try again.
The commits occur in distinct stages, (add attributes, add features, change attribute values, change geometries, delete features, delete attributes) so if a stage fails, it’s difficult to roll back cleanly. Therefore any error message also includes which stage failed so that the user has some chance of repairing the damage cleanly.
- Parameters:
stopEditing (bool = True) -> (bool) – if set to
False
, the layer will stay in editing mode. Otherwise the layer editing mode will be disabled if the commit is successful.- Returns:
True
on successcommitErrors: a list of descriptive errors if the commit fails.
- layers(self) Set[QgsVectorLayer] ¶
Gets the set of layers currently managed by this edit buffer group.
- Return type:
Set[QgsVectorLayer]
- Returns:
Layer set
- modifiedLayers(self) Set[QgsVectorLayer] ¶
Gets the set of modified layers currently managed by this edit buffer group.
- Return type:
Set[QgsVectorLayer]
- Returns:
Layer set
- removeLayer(self, layer: QgsVectorLayer | None)[source]¶
Remove a layer from this edit buffer group.
Added in version 3.42.
- Parameters:
layer (Optional[QgsVectorLayer])
- rollBack(self, stopEditing: bool = True)[source]¶
Stop editing and discard the edits
- Parameters:
stopEditing (bool = True) -> (bool) – if set to
False
, the layer will stay in editing mode. Otherwise the layer editing mode will be disabled if the rollback is successful.- Returns:
False
if errors occurred during rollbackrollbackErrors: a list of descriptive errors if the rollback fails.