Class: QgsVectorLayerEditBuffer¶
- class qgis.core.QgsVectorLayerEditBuffer(layer: QgsVectorLayer)¶
Bases:
PyQt5.QtCore.QObject
QgsVectorLayerEditBuffer() Constructor for QgsVectorLayerEditBuffer
Methods
Adds an attribute field (but does not commit it) returns
True
if the field was addedAdds a feature
Insert a copy of the given features into the layer (but does not commit it)
Returns a list of added attributes fields which are not committed.
Returns a map of new features which are not committed.
Returns a list of the features IDs for all newly added or edited features in the buffer.
Changed an attribute value (but does not commit it)
Changes values of attributes (but does not commit it).
Change feature's geometry
Returns a map of features with changed attributes values which are not committed.
Returns a map of features with changed geometries which are not committed.
Attempts to commit any changes to disk.
Deletes an attribute field (but does not commit it)
Delete a feature from the layer (but does not commit it)
Deletes a set of features from the layer (but does not commit it)
Returns a list of deleted attributes fields which are not committed.
Returns a list of deleted feature IDs which are not committed.
Update added and changed features after addition of an attribute
Update added and changed features after removal of an attribute
Returns
True
if the specified attribute has been deleted but not committed.Returns
True
if the specified feature ID has been added but not committed.Returns
True
if the specified feature ID has had an attribute changed but not committed.Returns
True
if the specified feature ID has been deleted but not committed.Returns
True
if the specified feature ID has had its geometry changed but not committed.Returns
True
if the provider has been modified since the last commitRenames an attribute field (but does not commit it)
Stop editing and discard the edits
- param index
Updates an index in an attribute map to a new value (for updates of changed attributes)
Update feature with uncommitted attribute updates
Update feature with uncommitted geometry updates
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
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 andFalse
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
- 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
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¶
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.
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¶
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
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¶
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
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)¶