Class: QgsVectorLayerEditBuffer

class qgis.core.QgsVectorLayerEditBuffer(layer: QgsVectorLayer)

Bases: PyQt5.QtCore.QObject

QgsVectorLayerEditBuffer() Constructor for QgsVectorLayerEditBuffer

Methods

addAttribute

Adds an attribute field (but does not commit it) returns True if the field was added

addFeature

Adds a feature

addFeatures

Insert a copy of the given features into the layer (but does not commit it)

addedAttributes

Returns a list of added attributes fields which are not committed.

addedFeatures

Returns a map of new features which are not committed.

allAddedOrEditedFeatures

Returns a list of the features IDs for all newly added or edited features in the buffer.

changeAttributeValue

Changed an attribute value (but does not commit it)

changeAttributeValues

Changes values of attributes (but does not commit it).

changeGeometry

Change feature's geometry

changedAttributeValues

Returns a map of features with changed attributes values which are not committed.

changedGeometries

Returns a map of features with changed geometries which are not committed.

childEvent

commitChanges

Attempts to commit any changes to disk.

connectNotify

customEvent

deleteAttribute

Deletes an attribute field (but does not commit it)

deleteFeature

Delete a feature from the layer (but does not commit it)

deleteFeatures

Deletes a set of features from the layer (but does not commit it)

deletedAttributeIds

Returns a list of deleted attributes fields which are not committed.

deletedFeatureIds

Returns a list of deleted feature IDs which are not committed.

disconnectNotify

editBufferGroup

Returns the parent edit buffer group for this edit buffer, or None if not part of a group.

handleAttributeAdded

Update added and changed features after addition of an attribute

handleAttributeDeleted

Update added and changed features after removal of an attribute

isAttributeDeleted

Returns True if the specified attribute has been deleted but not committed.

isFeatureAdded

Returns True if the specified feature ID has been added but not committed.

isFeatureAttributesChanged

Returns True if the specified feature ID has had an attribute changed but not committed.

isFeatureDeleted

Returns True if the specified feature ID has been deleted but not committed.

isFeatureGeometryChanged

Returns True if the specified feature ID has had its geometry changed but not committed.

isModified

Returns True if the provider has been modified since the last commit

isSignalConnected

receivers

renameAttribute

Renames an attribute field (but does not commit it)

rollBack

Stop editing and discard the edits

sender

senderSignalIndex

setEditBufferGroup

Set the parent edit buffer group for this edit buffer.

timerEvent

undoIndexChanged

param index:

updateAttributeMapIndex

Updates an index in an attribute map to a new value (for updates of changed attributes)

updateChangedAttributes

Update feature with uncommitted attribute updates

updateFeatureGeometry

Update feature with uncommitted geometry updates

updateLayerFields

Signals

attributeAdded

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

attributeDeleted

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

attributeRenamed

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

attributeValueChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

committedAttributeValuesChanges

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

committedAttributesAdded

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

committedAttributesDeleted

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

committedAttributesRenamed

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

committedFeaturesAdded

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

committedFeaturesRemoved

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

committedGeometriesChanges

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

featureAdded

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

featureDeleted

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

geometryChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

layerModified

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

addAttribute(self, field: QgsField) bool

Adds an attribute field (but does not commit it) returns True if the field was added

Parameters:

field (QgsField) –

Return type:

bool

addFeature(self, f: QgsFeature) bool

Adds a feature

Parameters:

f (QgsFeature) – feature to add

Return type:

bool

Returns:

True in case of success and False in case of error

addFeatures(self, features: Iterable[QgsFeature]) bool

Insert a copy of the given features into the layer (but does not commit it)

Parameters:

features (Iterable[QgsFeature]) –

Return type:

bool

addedAttributes(self) object

Returns a list of added attributes fields which are not committed.

Return type:

object

addedFeatures(self) object

Returns a map of new features which are not committed.

See also

isFeatureAdded()

Return type:

object

allAddedOrEditedFeatures(self) object

Returns a list of the features IDs for all newly added or edited features in the buffer.

New in version 3.20.

Return type:

object

attributeAdded

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

attributeDeleted

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

attributeRenamed

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

attributeValueChanged

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

changeAttributeValue(self, fid: int, field: int, newValue: Any, oldValue: Any = None) bool

Changed an attribute value (but does not commit it)

Parameters:
  • fid (int) –

  • field (int) –

  • newValue (Any) –

  • oldValue (Any = None) –

Return type:

bool

changeAttributeValues(self, fid: int, newValues: Dict[int, Any], oldValues: Dict[int, Any]) bool

Changes values of attributes (but does not commit it).

Return type:

bool

Returns:

True if attributes are well updated, False otherwise

Parameters:
  • fid (int) –

  • newValues (Dict[int) –

  • oldValues (Dict[int) –

changeGeometry(self, fid: int, geom: QgsGeometry) bool

Change feature’s geometry

Parameters:
Return type:

bool

changedAttributeValues(self) object

Returns a map of features with changed attributes values which are not committed.

Return type:

object

changedGeometries(self) object

Returns a map of features with changed geometries which are not committed.

Return type:

object

childEvent(self, QChildEvent)
commitChanges(self, commitErrors: Iterable[str]) bool

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[str]) –

Return type:

bool

committedAttributeValuesChanges

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

committedAttributesAdded

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

committedAttributesDeleted

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

committedAttributesRenamed

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

committedFeaturesAdded

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

committedFeaturesRemoved

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

committedGeometriesChanges

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
deleteAttribute(self, attr: int) bool

Deletes an attribute field (but does not commit it)

Parameters:

attr (int) –

Return type:

bool

deleteFeature(self, fid: int) bool

Delete a feature from the layer (but does not commit it)

Parameters:

fid (int) –

Return type:

bool

deleteFeatures(self, fid: object) bool

Deletes a set of features from the layer (but does not commit it)

Parameters:

fid (object) –

Return type:

bool

deletedAttributeIds(self) List[int]

Returns a list of deleted attributes fields which are not committed. The list is kept sorted.

Return type:

List[int]

deletedFeatureIds(self) object

Returns a list of deleted feature IDs which are not committed.

Return type:

object

disconnectNotify(self, QMetaMethod)
editBufferGroup(self) QgsVectorLayerEditBufferGroup

Returns the parent edit buffer group for this edit buffer, or None if not part of a group.

New in version 3.26.

Return type:

QgsVectorLayerEditBufferGroup

featureAdded

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

featureDeleted

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

geometryChanged

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

handleAttributeAdded(self, index: int)

Update added and changed features after addition of an attribute

Parameters:

index (int) –

handleAttributeDeleted(self, index: int)

Update added and changed features after removal of an attribute

Parameters:

index (int) –

isAttributeDeleted(self, index: int) bool

Returns True if the specified attribute has been deleted but not committed.

Parameters:

index (int) – attribute index

Return type:

bool

isFeatureAdded(self, id: int) bool

Returns True if the specified feature ID has been added but not committed.

Parameters:

id (int) – feature ID

See also

addedFeatures()

Return type:

bool

isFeatureAttributesChanged(self, id: int) bool

Returns True if the specified feature ID has had an attribute changed but not committed.

Parameters:

id (int) – feature ID

Return type:

bool

isFeatureDeleted(self, id: int) bool

Returns True if the specified feature ID has been deleted but not committed.

Parameters:

id (int) – feature ID

Return type:

bool

isFeatureGeometryChanged(self, id: int) bool

Returns True if the specified feature ID has had its geometry changed but not committed.

Parameters:

id (int) – feature ID

Return type:

bool

isModified(self) bool

Returns True if the provider has been modified since the last commit

Return type:

bool

isSignalConnected(self, QMetaMethod) bool
layerModified

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

receivers(self, PYQT_SIGNAL) int
renameAttribute(self, attr: int, newName: str) bool

Renames an attribute field (but does not commit it)

Parameters:
  • attr (int) – attribute index

  • newName (str) – new name of field

Return type:

bool

rollBack(self)

Stop editing and discard the edits

sender(self) QObject
senderSignalIndex(self) int
setEditBufferGroup(self, editBufferGroup: QgsVectorLayerEditBufferGroup)

Set the parent edit buffer group for this edit buffer.

New in version 3.26.

Parameters:

editBufferGroup (QgsVectorLayerEditBufferGroup) –

timerEvent(self, QTimerEvent)
undoIndexChanged(self, index: int)
Parameters:

index (int) –

updateAttributeMapIndex(self, attrs: Dict[int, Any], index: int, offset: int)

Updates an index in an attribute map to a new value (for updates of changed attributes)

Parameters:
  • attrs (Dict[int) –

  • index (int) –

  • offset (int) –

updateChangedAttributes(self, f: QgsFeature)

Update feature with uncommitted attribute updates

Parameters:

f (QgsFeature) –

updateFeatureGeometry(self, f: QgsFeature)

Update feature with uncommitted geometry updates

Parameters:

f (QgsFeature) –

updateLayerFields(self)