Class: QgsVectorLayerEditBuffer

class qgis.core.QgsVectorLayerEditBuffer(layer: QgsVectorLayer)

Bases: PyQt5.QtCore.QObject

QgsVectorLayerEditBuffer() Constructor for QgsVectorLayerEditBuffer

Enums

Methods

addAttribute Add 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.
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 Delete 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
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
timerEvent
undoIndexChanged
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
updateFields
updateLayerFields

Signals

attributeAdded attributeAdded(self, int) [signal]
attributeDeleted attributeDeleted(self, int) [signal]
attributeRenamed Emitted when an attribute has been renamed
attributeValueChanged attributeValueChanged(self, int, int, Any) [signal]
committedAttributeValuesChanges committedAttributeValuesChanges(self, str, object) [signal]
committedAttributesAdded committedAttributesAdded(self, str, object) [signal]
committedAttributesDeleted Signals emitted after committing changes [signal]
committedAttributesRenamed Emitted after committing an attribute rename
committedFeaturesAdded committedFeaturesAdded(self, str, object) [signal]
committedFeaturesRemoved committedFeaturesRemoved(self, str, object) [signal]
committedGeometriesChanges committedGeometriesChanges(self, str, object) [signal]
featureAdded featureAdded(self, int) [signal]
featureDeleted featureDeleted(self, int) [signal]
geometryChanged Emitted when a feature’s geometry is changed.
layerModified Emitted when modifications has been done on layer [signal]

Attributes

addAttribute(self, field: QgsField) → bool

Add an attribute field (but does not commit it) returns true if the field was added

addFeature(self, f: QgsFeature) → bool

Adds a feature

Parameters:f – feature to add
Returns:True in case of success and False in case of error
addFeatures(self, features: object) → bool

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

addedAttributes(self) → object

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

addedFeatures(self) → object

Returns a map of new features which are not committed.

See also

isFeatureAdded()

attributeAdded

attributeAdded(self, int) [signal]

attributeDeleted

attributeDeleted(self, int) [signal]

attributeRenamed

Emitted when an attribute has been renamed

Parameters:
  • idx – attribute index
  • newName – new attribute name

New in version 2.16: [signal]

attributeValueChanged

attributeValueChanged(self, int, int, Any) [signal]

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

Changed an attribute value (but does not commit it)

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

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

Returns:True if attributes are well updated, False otherwise

New in version 3.0.

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

Change feature’s geometry

changedAttributeValues(self) → object

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

changedGeometries(self) → object

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

childEvent()
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.

committedAttributeValuesChanges

committedAttributeValuesChanges(self, str, object) [signal]

committedAttributesAdded

committedAttributesAdded(self, str, object) [signal]

committedAttributesDeleted

Signals emitted after committing changes [signal]

committedAttributesRenamed

Emitted after committing an attribute rename

Parameters:
  • layerId – ID of layer
  • renamedAttributes – map of field index to new name

New in version 2.16: [signal]

committedFeaturesAdded

committedFeaturesAdded(self, str, object) [signal]

committedFeaturesRemoved

committedFeaturesRemoved(self, str, object) [signal]

committedGeometriesChanges

committedGeometriesChanges(self, str, object) [signal]

connectNotify()
customEvent()
deleteAttribute(self, attr: int) → bool

Delete an attribute field (but does not commit it)

deleteFeature(self, fid: int) → bool

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

deleteFeatures(self, fid: object) → bool

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

deletedAttributeIds(self) → List[int]

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

deletedFeatureIds(self) → object

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

disconnectNotify()
featureAdded

featureAdded(self, int) [signal]

featureDeleted

featureDeleted(self, int) [signal]

geometryChanged

Emitted when a feature’s geometry is changed.

Parameters:
  • fid – feature ID
  • geom – new feature geometry [signal]
handleAttributeAdded(self, index: int)

Update added and changed features after addition of an attribute

handleAttributeDeleted(self, index: int)

Update added and changed features after removal of an attribute

isAttributeDeleted(self, index: int) → bool

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

Parameters:index – attribute index

New in version 3.0.

isFeatureAdded(self, id: int) → bool

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

Parameters:id – feature ID

See also

addedFeatures()

New in version 3.0.

isFeatureAttributesChanged(self, id: int) → bool

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

Parameters:id – feature ID

New in version 3.0.

isFeatureDeleted(self, id: int) → bool

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

Parameters:id – feature ID

New in version 3.0.

isFeatureGeometryChanged(self, id: int) → bool

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

Parameters:id – feature ID

New in version 3.0.

isModified(self) → bool

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

isSignalConnected()
layerModified

Emitted when modifications has been done on layer [signal]

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

Renames an attribute field (but does not commit it)

Parameters:
  • attr – attribute index
  • newName – new name of field

New in version 2.16.

rollBack(self)

Stop editing and discard the edits

sender()
senderSignalIndex()
timerEvent()
undoIndexChanged(self, 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)

updateChangedAttributes(self, f: QgsFeature)

Update feature with uncommitted attribute updates

updateFeatureGeometry(self, f: QgsFeature)

Update feature with uncommitted geometry updates

updateFields(self, fields: QgsFields)
updateLayerFields(self)