Class: QgsVectorLayerEditBuffer¶
Stores queued vector layer edit operations prior to committing changes to the layer’s data provider.
Class Hierarchy¶
Base classes¶
Subclasses¶
An edit buffer which directly passes commands through, used when a layer is within a transaction. |
- class qgis.core.QgsVectorLayerEditBuffer[source]¶
Bases:
QObject- virtual addAttribute(self, field: QgsField) bool[source]¶
Adds an attribute field (but does not commit it) returns
Trueif the field was added- Parameters:
field (QgsField)
- Return type:
bool
- virtual addFeature(self, f: QgsFeature) bool[source]¶
Adds a feature
- Parameters:
f (QgsFeature) – feature to add
- Return type:
bool
- Returns:
Truein case of success andFalsein case of error
- virtual addFeatures(self, features: Iterable[QgsFeature]) bool[source]¶
Insert a copy of the given features into the layer (but does not commit it)
- Parameters:
features (Iterable[QgsFeature])
- Return type:
bool
- addedAttributes(self) Any¶
Returns a list of added attributes fields which are not committed.
- Return type:
- addedFeatures(self) Any[source]¶
Returns a map of new features which are not committed.
See also
- Return type:
- allAddedOrEditedFeatures(self) Any[source]¶
Returns a list of the features IDs for all newly added or edited features in the buffer.
Added in version 3.20.
- Return type:
- signal attributeAdded[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal attributeDeleted[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal attributeRenamed[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal attributeValueChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- virtual changeAttributeValue(self, fid: int, field: int, newValue: Any, oldValue: Any = None) bool[source]¶
Changed an attribute value (but does not commit it)
- Parameters:
fid (int)
field (int)
newValue (Any)
oldValue (Any = None)
- Return type:
bool
- virtual changeAttributeValues(self, fid: int, newValues: Dict[int, Any], oldValues: Dict[int, Any]) bool[source]¶
Changes values of attributes (but does not commit it).
- virtual changeGeometry(self, fid: int, geom: QgsGeometry) bool[source]¶
Change feature’s geometry
- Parameters:
fid (int)
geom (QgsGeometry)
- Return type:
bool
- changedAttributeValues(self) Any[source]¶
Returns a map of features with changed attributes values which are not committed.
See also
- Return type:
- changedGeometries(self) Any[source]¶
Returns a map of features with changed geometries which are not committed.
See also
- Return type:
- virtual commitChanges(self, commitErrors: Iterable[str | None]) bool[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:
commitErrors (Iterable[Optional[str]])
- Return type:
bool
- signal committedAttributeValuesChanges[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal committedAttributesAdded[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal committedAttributesDeleted[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal committedAttributesRenamed[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal committedFeaturesAdded[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal committedFeaturesRemoved[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal committedGeometriesChanges[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- virtual deleteAttribute(self, attr: int) bool[source]¶
Deletes an attribute field (but does not commit it)
- Parameters:
attr (int)
- Return type:
bool
- virtual deleteFeature(self, fid: int) bool[source]¶
Delete a feature from the layer (but does not commit it)
- Parameters:
fid (int)
- Return type:
bool
- virtual deleteFeatures(self, fid: Any) bool[source]¶
Deletes a set of features from the layer (but does not commit it)
- Parameters:
fid (Any)
- Return type:
bool
- deletedAttributeIds(self) List[int][source]¶
Returns a list of deleted attributes fields which are not committed. The list is kept sorted.
See also
- Return type:
List[int]
- deletedFeatureIds(self) Any[source]¶
Returns a list of deleted feature IDs which are not committed.
See also
- Return type:
- editBufferGroup(self) QgsVectorLayerEditBufferGroup | None[source]¶
Returns the parent edit buffer group for this edit buffer, or None if not part of a group.
Added in version 3.26.
- Return type:
Optional[QgsVectorLayerEditBufferGroup]
- signal featureAdded[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal featureDeleted[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal geometryChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- handleAttributeAdded(self, index: int, field: QgsField)[source]¶
Update added and changed features after addition of an attribute
- Parameters:
index (int)
field (QgsField)
- handleAttributeDeleted(self, index: int)[source]¶
Update added and changed features after removal of an attribute
- Parameters:
index (int)
- isAttributeDeleted(self, index: int) bool[source]¶
Returns
Trueif the specified attribute has been deleted but not committed.- Parameters:
index (int) – attribute index
See also
- Return type:
bool
- isFeatureAdded(self, id: int) bool[source]¶
Returns
Trueif the specified feature ID has been added but not committed.- Parameters:
id (int) – feature ID
See also
- Return type:
bool
- isFeatureAttributesChanged(self, id: int) bool[source]¶
Returns
Trueif the specified feature ID has had an attribute changed but not committed.- Parameters:
id (int) – feature ID
See also
- Return type:
bool
- isFeatureDeleted(self, id: int) bool[source]¶
Returns
Trueif the specified feature ID has been deleted but not committed.- Parameters:
id (int) – feature ID
See also
- Return type:
bool
- isFeatureGeometryChanged(self, id: int) bool[source]¶
Returns
Trueif the specified feature ID has had its geometry changed but not committed.- Parameters:
id (int) – feature ID
See also
- Return type:
bool
- virtual isModified(self) bool[source]¶
Returns
Trueif the provider has been modified since the last commit- Return type:
bool
- signal layerModified[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- virtual renameAttribute(self, attr: int, newName: str | None) bool[source]¶
Renames an attribute field (but does not commit it)
- Parameters:
attr (int) – attribute index
newName (Optional[str]) – new name of field
- Return type:
bool
- setEditBufferGroup(self, editBufferGroup: QgsVectorLayerEditBufferGroup | None)[source]¶
Set the parent edit buffer group for this edit buffer.
Added in version 3.26.
- Parameters:
editBufferGroup (Optional[QgsVectorLayerEditBufferGroup])
- updateAttributeMapIndex(self, attrs: Dict[int, Any], index: int, offset: int)[source]¶
Updates an index in an attribute map to a new value (for updates of changed attributes)
- Parameters:
attrs (Dict[int, Any])
index (int)
offset (int)
- updateChangedAttributes(self, f: QgsFeature)[source]¶
Update feature with uncommitted attribute updates
- Parameters:
f (QgsFeature)
- updateFeatureGeometry(self, f: QgsFeature)[source]¶
Update feature with uncommitted geometry updates
- Parameters:
f (QgsFeature)