QGIS API Documentation 3.41.0-Master (af5edcb665c)
|
Stores queued vector layer edit operations prior to committing changes to the layer's data provider. More...
#include <qgsvectorlayereditbuffer.h>
Signals | |
void | attributeAdded (int idx) |
Emitted when an attribute was added to the buffer. | |
void | attributeDeleted (int idx) |
Emitted when an attribute was deleted from the buffer. | |
void | attributeRenamed (int idx, const QString &newName) |
Emitted when an attribute has been renamed. | |
void | attributeValueChanged (QgsFeatureId fid, int idx, const QVariant &value) |
Emitted when a feature's attribute value has been changed. | |
void | committedAttributesAdded (const QString &layerId, const QList< QgsField > &addedAttributes) |
Emitted after attribute addition has been committed to the layer. | |
void | committedAttributesDeleted (const QString &layerId, const QgsAttributeList &deletedAttributes) |
Emitted after attribute deletion has been committed to the layer. | |
void | committedAttributesRenamed (const QString &layerId, const QgsFieldNameMap &renamedAttributes) |
Emitted after committing an attribute rename. | |
void | committedAttributeValuesChanges (const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues) |
Emitted after feature attribute value changes have been committed to the layer. | |
void | committedFeaturesAdded (const QString &layerId, const QgsFeatureList &addedFeatures) |
Emitted after feature addition has been committed to the layer. | |
void | committedFeaturesRemoved (const QString &layerId, const QgsFeatureIds &deletedFeatureIds) |
Emitted after feature removal has been committed to the layer. | |
void | committedGeometriesChanges (const QString &layerId, const QgsGeometryMap &changedGeometries) |
Emitted after feature geometry changes have been committed to the layer. | |
void | featureAdded (QgsFeatureId fid) |
Emitted when a feature has been added to the buffer. | |
void | featureDeleted (QgsFeatureId fid) |
Emitted when a feature was deleted from the buffer. | |
void | geometryChanged (QgsFeatureId fid, const QgsGeometry &geom) |
Emitted when a feature's geometry is changed. | |
void | layerModified () |
Emitted when modifications has been done on layer. | |
Public Member Functions | |
QgsVectorLayerEditBuffer (QgsVectorLayer *layer) | |
virtual bool | addAttribute (const QgsField &field) |
Adds an attribute field (but does not commit it) returns true if the field was added. | |
QList< QgsField > | addedAttributes () const |
Returns a list of added attributes fields which are not committed. | |
QgsFeatureMap | addedFeatures () const |
Returns a map of new features which are not committed. | |
virtual bool | addFeature (QgsFeature &f) |
Adds a feature. | |
virtual bool | addFeatures (QgsFeatureList &features) |
Insert a copy of the given features into the layer (but does not commit it) | |
QgsFeatureIds | allAddedOrEditedFeatures () const |
Returns a list of the features IDs for all newly added or edited features in the buffer. | |
virtual bool | changeAttributeValue (QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant()) |
Changed an attribute value (but does not commit it) | |
virtual bool | changeAttributeValues (QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues) |
Changes values of attributes (but does not commit it). | |
QgsChangedAttributesMap | changedAttributeValues () const |
Returns a map of features with changed attributes values which are not committed. | |
QgsGeometryMap | changedGeometries () const |
Returns a map of features with changed geometries which are not committed. | |
virtual bool | changeGeometry (QgsFeatureId fid, const QgsGeometry &geom) |
Change feature's geometry. | |
virtual bool | commitChanges (QStringList &commitErrors) |
Attempts to commit any changes to disk. | |
virtual bool | deleteAttribute (int attr) |
Deletes an attribute field (but does not commit it) | |
QgsAttributeList | deletedAttributeIds () const |
Returns a list of deleted attributes fields which are not committed. | |
QgsFeatureIds | deletedFeatureIds () const |
Returns a list of deleted feature IDs which are not committed. | |
virtual bool | deleteFeature (QgsFeatureId fid) |
Delete a feature from the layer (but does not commit it) | |
virtual bool | deleteFeatures (const QgsFeatureIds &fid) |
Deletes a set of features from the layer (but does not commit it) | |
QgsVectorLayerEditBufferGroup * | editBufferGroup () const |
Returns the parent edit buffer group for this edit buffer, or nullptr if not part of a group. | |
bool | isAttributeDeleted (int index) const |
Returns true if the specified attribute has been deleted but not committed. | |
bool | isFeatureAdded (QgsFeatureId id) const |
Returns true if the specified feature ID has been added but not committed. | |
bool | isFeatureAttributesChanged (QgsFeatureId id) const |
Returns true if the specified feature ID has had an attribute changed but not committed. | |
bool | isFeatureDeleted (QgsFeatureId id) const |
Returns true if the specified feature ID has been deleted but not committed. | |
bool | isFeatureGeometryChanged (QgsFeatureId id) const |
Returns true if the specified feature ID has had its geometry changed but not committed. | |
virtual bool | isModified () const |
Returns true if the provider has been modified since the last commit. | |
virtual bool | renameAttribute (int attr, const QString &newName) |
Renames an attribute field (but does not commit it) | |
virtual void | rollBack () |
Stop editing and discard the edits. | |
void | setEditBufferGroup (QgsVectorLayerEditBufferGroup *editBufferGroup) |
Set the parent edit buffer group for this edit buffer. | |
void | updateFields (QgsFields &fields) |
Updates fields. | |
Protected Slots | |
void | undoIndexChanged (int index) |
Protected Member Functions | |
QgsVectorLayerEditBuffer ()=default | |
void | handleAttributeAdded (int index) |
Update added and changed features after addition of an attribute. | |
void | handleAttributeDeleted (int index) |
Update added and changed features after removal of an attribute. | |
void | updateAttributeMapIndex (QgsAttributeMap &attrs, int index, int offset) const |
Updates an index in an attribute map to a new value (for updates of changed attributes) | |
void | updateChangedAttributes (QgsFeature &f) |
Update feature with uncommitted attribute updates. | |
void | updateFeatureGeometry (QgsFeature &f) |
Update feature with uncommitted geometry updates. | |
void | updateLayerFields () |
Protected Attributes | |
QgsVectorLayer * | L = nullptr |
QList< QgsField > | mAddedAttributes |
Added attributes fields which are not committed. | |
QgsFeatureMap | mAddedFeatures |
New features which are not committed. | |
int | mBlockModifiedSignals = 0 |
QgsChangedAttributesMap | mChangedAttributeValues |
Changed attributes values which are not committed. | |
QgsGeometryMap | mChangedGeometries |
Changed geometries which are not committed. | |
QgsAttributeList | mDeletedAttributeIds |
Deleted attributes fields which are not committed. The list is kept sorted. | |
QgsFeatureIds | mDeletedFeatureIds |
Deleted feature IDs which are not committed. | |
QgsVectorLayerEditBufferGroup * | mEditBufferGroup = nullptr |
QgsFieldNameMap | mRenamedAttributes |
Renamed attributes which are not committed. | |
Stores queued vector layer edit operations prior to committing changes to the layer's data provider.
Definition at line 38 of file qgsvectorlayereditbuffer.h.
QgsVectorLayerEditBuffer::QgsVectorLayerEditBuffer | ( | QgsVectorLayer * | layer | ) |
Definition at line 43 of file qgsvectorlayereditbuffer.cpp.
|
protecteddefault |
|
virtual |
Adds an attribute field (but does not commit it) returns true
if the field was added.
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 304 of file qgsvectorlayereditbuffer.cpp.
|
inline |
Returns a list of added attributes fields which are not committed.
Definition at line 161 of file qgsvectorlayereditbuffer.h.
|
inline |
Returns a map of new features which are not committed.
Definition at line 115 of file qgsvectorlayereditbuffer.h.
|
virtual |
Adds a feature.
f | feature to add |
true
in case of success and false
in case of error Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 133 of file qgsvectorlayereditbuffer.cpp.
|
virtual |
Insert a copy of the given features into the layer (but does not commit it)
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 152 of file qgsvectorlayereditbuffer.cpp.
QgsFeatureIds QgsVectorLayerEditBuffer::allAddedOrEditedFeatures | ( | ) | const |
Returns a list of the features IDs for all newly added or edited features in the buffer.
Definition at line 484 of file qgsvectorlayereditbuffer.cpp.
|
signal |
Emitted when an attribute was added to the buffer.
|
signal |
Emitted when an attribute was deleted from the buffer.
|
signal |
Emitted when an attribute has been renamed.
idx | attribute index |
newName | new attribute name |
|
signal |
Emitted when a feature's attribute value has been changed.
|
virtual |
Changed an attribute value (but does not commit it)
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 282 of file qgsvectorlayereditbuffer.cpp.
|
virtual |
Changes values of attributes (but does not commit it).
true
if attributes are well updated, false
otherwise Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 256 of file qgsvectorlayereditbuffer.cpp.
|
inline |
Returns a map of features with changed attributes values which are not committed.
Definition at line 136 of file qgsvectorlayereditbuffer.h.
|
inline |
Returns a map of features with changed geometries which are not committed.
Definition at line 167 of file qgsvectorlayereditbuffer.h.
|
virtual |
Change feature's geometry.
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 235 of file qgsvectorlayereditbuffer.cpp.
|
virtual |
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.
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 372 of file qgsvectorlayereditbuffer.cpp.
|
signal |
Emitted after attribute addition has been committed to the layer.
|
signal |
Emitted after attribute deletion has been committed to the layer.
|
signal |
Emitted after committing an attribute rename.
layerId | ID of layer |
renamedAttributes | map of field index to new name |
|
signal |
Emitted after feature attribute value changes have been committed to the layer.
|
signal |
Emitted after feature addition has been committed to the layer.
|
signal |
Emitted after feature removal has been committed to the layer.
|
signal |
Emitted after feature geometry changes have been committed to the layer.
|
virtual |
Deletes an attribute field (but does not commit it)
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 327 of file qgsvectorlayereditbuffer.cpp.
|
inline |
Returns a list of deleted attributes fields which are not committed.
The list is kept sorted.
Definition at line 149 of file qgsvectorlayereditbuffer.h.
|
inline |
Returns a list of deleted feature IDs which are not committed.
Definition at line 180 of file qgsvectorlayereditbuffer.h.
|
virtual |
Delete a feature from the layer (but does not commit it)
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 183 of file qgsvectorlayereditbuffer.cpp.
|
virtual |
Deletes a set of features from the layer (but does not commit it)
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 212 of file qgsvectorlayereditbuffer.cpp.
QgsVectorLayerEditBufferGroup * QgsVectorLayerEditBuffer::editBufferGroup | ( | ) | const |
Returns the parent edit buffer group for this edit buffer, or nullptr if not part of a group.
Definition at line 89 of file qgsvectorlayereditbuffer.cpp.
|
signal |
Emitted when a feature has been added to the buffer.
|
signal |
Emitted when a feature was deleted from the buffer.
|
signal |
Emitted when a feature's geometry is changed.
fid | feature ID |
geom | new feature geometry |
|
protected |
Update added and changed features after addition of an attribute.
Definition at line 506 of file qgsvectorlayereditbuffer.cpp.
|
protected |
Update added and changed features after removal of an attribute.
Definition at line 540 of file qgsvectorlayereditbuffer.cpp.
|
inline |
Returns true
if the specified attribute has been deleted but not committed.
index | attribute index |
Definition at line 156 of file qgsvectorlayereditbuffer.h.
|
inline |
Returns true
if the specified feature ID has been added but not committed.
id | feature ID |
Definition at line 130 of file qgsvectorlayereditbuffer.h.
|
inline |
Returns true
if the specified feature ID has had an attribute changed but not committed.
id | feature ID |
Definition at line 143 of file qgsvectorlayereditbuffer.h.
|
inline |
Returns true
if the specified feature ID has been deleted but not committed.
id | feature ID |
Definition at line 187 of file qgsvectorlayereditbuffer.h.
|
inline |
Returns true
if the specified feature ID has had its geometry changed but not committed.
id | feature ID |
Definition at line 174 of file qgsvectorlayereditbuffer.h.
|
virtual |
Returns true
if the provider has been modified since the last commit.
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 49 of file qgsvectorlayereditbuffer.cpp.
|
signal |
Emitted when modifications has been done on layer.
|
virtual |
Renames an attribute field (but does not commit it)
attr | attribute index |
newName | new name of field |
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 349 of file qgsvectorlayereditbuffer.cpp.
|
virtual |
Stop editing and discard the edits.
Reimplemented in QgsVectorLayerEditPassthrough.
Definition at line 468 of file qgsvectorlayereditbuffer.cpp.
void QgsVectorLayerEditBuffer::setEditBufferGroup | ( | QgsVectorLayerEditBufferGroup * | editBufferGroup | ) |
Set the parent edit buffer group for this edit buffer.
Definition at line 94 of file qgsvectorlayereditbuffer.cpp.
|
protectedslot |
Definition at line 55 of file qgsvectorlayereditbuffer.cpp.
|
protected |
Updates an index in an attribute map to a new value (for updates of changed attributes)
Definition at line 586 of file qgsvectorlayereditbuffer.cpp.
|
protected |
Update feature with uncommitted attribute updates.
Definition at line 106 of file qgsvectorlayereditbuffer.cpp.
|
protected |
Update feature with uncommitted geometry updates.
Definition at line 99 of file qgsvectorlayereditbuffer.cpp.
void QgsVectorLayerEditBuffer::updateFields | ( | QgsFields & | fields | ) |
Updates fields.
Definition at line 67 of file qgsvectorlayereditbuffer.cpp.
|
protected |
Definition at line 599 of file qgsvectorlayereditbuffer.cpp.
|
friend |
Definition at line 362 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 366 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 313 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 318 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 314 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 317 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 316 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 319 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 315 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 320 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 322 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 328 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 323 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 326 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 327 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 325 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 329 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 324 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 330 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 331 of file qgsvectorlayereditbuffer.h.
|
protected |
Definition at line 311 of file qgsvectorlayereditbuffer.h.
|
protected |
Added attributes fields which are not committed.
Definition at line 350 of file qgsvectorlayereditbuffer.h.
|
protected |
New features which are not committed.
Definition at line 341 of file qgsvectorlayereditbuffer.h.
|
protected |
Definition at line 360 of file qgsvectorlayereditbuffer.h.
|
protected |
Changed attributes values which are not committed.
Definition at line 344 of file qgsvectorlayereditbuffer.h.
|
protected |
Changed geometries which are not committed.
Definition at line 356 of file qgsvectorlayereditbuffer.h.
|
protected |
Deleted attributes fields which are not committed. The list is kept sorted.
Definition at line 347 of file qgsvectorlayereditbuffer.h.
|
protected |
Deleted feature IDs which are not committed.
Note a feature can be added and then deleted again before the change is committed - in that case the added feature would be removed from mAddedFeatures only and not entered here.
Definition at line 338 of file qgsvectorlayereditbuffer.h.
|
protected |
Definition at line 358 of file qgsvectorlayereditbuffer.h.
|
protected |
Renamed attributes which are not committed.
Definition at line 353 of file qgsvectorlayereditbuffer.h.