Class: QgsVectorLayerEditBuffer¶
-
class
qgis.core.
QgsVectorLayerEditBuffer
(layer: QgsVectorLayer)¶ Bases:
PyQt5.QtCore.QObject
QgsVectorLayerEditBuffer() Constructor for QgsVectorLayerEditBuffer
- Parameters
layer –
-
addAttribute
(self, field: QgsField) → bool¶ Add 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
- Return type
object
-
attributeAdded
¶ attributeAdded(self, idx: int) [signal]
- Parameters
idx (int) –
-
attributeDeleted
¶ attributeDeleted(self, idx: int) [signal]
- Parameters
idx (int) –
-
attributeRenamed
¶ Emitted when an attribute has been renamed
- Parameters
idx (int) – attribute index
newName (str) – new attribute name
New in version 2.16: [signal]
-
attributeValueChanged
¶ attributeValueChanged(self, fid: int, idx: int, a2: Any) [signal]
- Parameters
fid (int) –
idx (int) –
a2 (Any) –
-
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
New in version 3.0.
- Parameters
fid (int) –
newValues (Dict[int) –
oldValues (Dict[int) –
-
changeGeometry
(self, fid: int, geom: QgsGeometry) → bool¶ Change feature’s geometry
- Parameters
fid (int) –
geom (QgsGeometry) –
- Return type
bool
-
changedAttributeValues
(self) → object¶ Returns a map of features with changed attributes values which are not committed.
See also
- Return type
object
-
changedGeometries
(self) → object¶ Returns a map of features with changed geometries which are not committed.
See also
- 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
¶ committedAttributeValuesChanges(self, layerId: str, changedAttributesValues: object) [signal]
- Parameters
layerId (str) –
changedAttributesValues (object) –
-
committedAttributesAdded
¶ committedAttributesAdded(self, layerId: str, addedAttributes: object) [signal]
- Parameters
layerId (str) –
addedAttributes (object) –
-
committedAttributesDeleted
¶ Signals emitted after committing changes [signal]
- Parameters
layerId (str) –
deletedAttributes (Iterable[int]) –
-
committedAttributesRenamed
¶ Emitted after committing an attribute rename
- Parameters
layerId (str) – ID of layer
renamedAttributes (Dict[int) – map of field index to new name
New in version 2.16: [signal]
-
committedFeaturesAdded
¶ committedFeaturesAdded(self, layerId: str, addedFeatures: Iterable[QgsFeature]) [signal]
- Parameters
layerId (str) –
addedFeatures (Iterable[QgsFeature]) –
-
committedFeaturesRemoved
¶ committedFeaturesRemoved(self, layerId: str, deletedFeatureIds: object) [signal]
- Parameters
layerId (str) –
deletedFeatureIds (object) –
-
committedGeometriesChanges
¶ committedGeometriesChanges(self, layerId: str, changedGeometries: object) [signal]
- Parameters
layerId (str) –
changedGeometries (object) –
-
connectNotify
(self, QMetaMethod)¶
-
customEvent
(self, QEvent)¶
-
deleteAttribute
(self, attr: int) → bool¶ Delete 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.
See also
- Return type
List[int]
-
deletedFeatureIds
(self) → object¶ Returns a list of deleted feature IDs which are not committed.
See also
- Return type
object
-
disconnectNotify
(self, QMetaMethod)¶
-
featureAdded
¶ featureAdded(self, fid: int) [signal]
- Parameters
fid (int) –
-
featureDeleted
¶ featureDeleted(self, fid: int) [signal]
- Parameters
fid (int) –
-
geometryChanged
¶ Emitted when a feature’s geometry is changed.
- Parameters
fid (int) – feature ID
geom (QgsGeometry) – new feature geometry [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
See also
New in version 3.0.
- 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
New in version 3.0.
- 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
See also
New in version 3.0.
- 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
See also
New in version 3.0.
- 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
See also
New in version 3.0.
- 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
¶ Emitted when modifications has been done on layer [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
New in version 2.16.
- Return type
bool
-
rollBack
(self)¶ Stop editing and discard the edits
-
sender
(self) → QObject¶
-
senderSignalIndex
(self) → int¶
-
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)¶