QGIS API Documentation
2.2.0-Valmiera
|
#include <qgsvectorlayereditbuffer.h>
Signals | |
void | layerModified () |
This signal is emitted when modifications has been done on layer. | |
void | featureAdded (QgsFeatureId fid) |
void | featureDeleted (QgsFeatureId fid) |
void | geometryChanged (QgsFeatureId fid, QgsGeometry &geom) |
void | attributeValueChanged (QgsFeatureId fid, int idx, const QVariant &) |
void | attributeAdded (int idx) |
void | attributeDeleted (int idx) |
void | committedAttributesDeleted (const QString &layerId, const QgsAttributeList &deletedAttributes) |
Signals emitted after committing changes. | |
void | committedAttributesAdded (const QString &layerId, const QList< QgsField > &addedAttributes) |
void | committedFeaturesAdded (const QString &layerId, const QgsFeatureList &addedFeatures) |
void | committedFeaturesRemoved (const QString &layerId, const QgsFeatureIds &deletedFeatureIds) |
void | committedAttributeValuesChanges (const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues) |
void | committedGeometriesChanges (const QString &layerId, const QgsGeometryMap &changedGeometries) |
Public Member Functions | |
QgsVectorLayerEditBuffer (QgsVectorLayer *layer) | |
~QgsVectorLayerEditBuffer () | |
bool | isModified () const |
Returns true if the provider has been modified since the last commit. | |
bool | addFeature (QgsFeature &f) |
Adds a feature. | |
bool | addFeatures (QgsFeatureList &features) |
Insert a copy of the given features into the layer (but does not commit it) | |
bool | deleteFeature (QgsFeatureId fid) |
delete a feature from the layer (but does not commit it) | |
bool | changeGeometry (QgsFeatureId fid, QgsGeometry *geom) |
change feature's geometry | |
bool | changeAttributeValue (QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant()) |
changed an attribute value (but does not commit it) | |
bool | addAttribute (const QgsField &field) |
add an attribute field (but does not commit it) returns true if the field was added | |
bool | deleteAttribute (int attr) |
delete an attribute field (but does not commit it) | |
bool | commitChanges (QStringList &commitErrors) |
Attempts to commit any changes to disk. | |
void | rollBack () |
Stop editing and discard the edits. | |
const QgsFeatureMap & | addedFeatures () |
New features which are not commited. | |
const QgsChangedAttributesMap & | changedAttributeValues () |
Changed attributes values which are not commited. | |
const QgsAttributeList & | deletedAttributeIds () |
deleted attributes fields which are not commited. | |
const QList< QgsField > & | addedAttributes () |
added attributes fields which are not commited | |
const QgsGeometryMap & | changedGeometries () |
Changed geometries which are not commited. | |
const QgsFeatureIds | deletedFeatureIds () |
Protected Slots | |
void | undoIndexChanged (int index) |
Protected Member Functions | |
void | updateFields (QgsFields &fields) |
void | updateFeatureGeometry (QgsFeature &f) |
Update feature with uncommited geometry updates. | |
void | updateChangedAttributes (QgsFeature &f) |
Update feature with uncommited attribute updates. | |
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 | updateLayerFields () |
Protected Attributes | |
QgsVectorLayer * | L |
QgsFeatureIds | mDeletedFeatureIds |
Deleted feature IDs which are not commited. | |
QgsFeatureMap | mAddedFeatures |
New features which are not commited. | |
QgsChangedAttributesMap | mChangedAttributeValues |
Changed attributes values which are not commited. | |
QgsAttributeList | mDeletedAttributeIds |
deleted attributes fields which are not commited. | |
QList< QgsField > | mAddedAttributes |
added attributes fields which are not commited | |
QgsGeometryMap | mChangedGeometries |
Changed geometries which are not commited. |
Definition at line 33 of file qgsvectorlayereditbuffer.h.
QgsVectorLayerEditBuffer::QgsVectorLayerEditBuffer | ( | QgsVectorLayer * | layer | ) |
Definition at line 24 of file qgsvectorlayereditbuffer.cpp.
References L, undoIndexChanged(), and QgsMapLayer::undoStack().
QgsVectorLayerEditBuffer::~QgsVectorLayerEditBuffer | ( | ) |
Definition at line 30 of file qgsvectorlayereditbuffer.cpp.
bool QgsVectorLayerEditBuffer::addAttribute | ( | const QgsField & | field | ) |
add an attribute field (but does not commit it) returns true if the field was added
Definition at line 192 of file qgsvectorlayereditbuffer.cpp.
References QgsVectorDataProvider::AddAttributes, QgsVectorDataProvider::capabilities(), QgsFields::count(), QgsVectorLayer::dataProvider(), L, QgsField::name(), QgsVectorLayer::pendingFields(), QgsVectorLayerUndoCommandAddAttribute, QgsVectorDataProvider::supportedType(), and QgsMapLayer::undoStack().
Referenced by QgsVectorLayer::addAttribute().
|
inline |
added attributes fields which are not commited
Definition at line 104 of file qgsvectorlayereditbuffer.h.
Referenced by QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator().
|
inline |
New features which are not commited.
Definition at line 95 of file qgsvectorlayereditbuffer.h.
Referenced by QgsFeatureListModel::data(), QgsAttributeTableFilterModel::filterAcceptsRow(), and QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator().
bool QgsVectorLayerEditBuffer::addFeature | ( | QgsFeature & | f | ) |
Adds a feature.
f | feature to add |
Definition at line 96 of file qgsvectorlayereditbuffer.cpp.
References QgsVectorDataProvider::AddFeatures, QgsFeature::attributes(), QgsVectorDataProvider::capabilities(), QgsFields::count(), QgsVectorLayer::dataProvider(), L, QgsVectorLayer::mUpdatedFields, QgsVectorLayerUndoCommandAddFeature, and QgsMapLayer::undoStack().
Referenced by QgsVectorLayer::addFeature(), and addFeatures().
bool QgsVectorLayerEditBuffer::addFeatures | ( | QgsFeatureList & | features | ) |
Insert a copy of the given features into the layer (but does not commit it)
Definition at line 112 of file qgsvectorlayereditbuffer.cpp.
References addFeature(), QgsVectorDataProvider::AddFeatures, QgsVectorDataProvider::capabilities(), QgsVectorLayer::dataProvider(), L, and QgsVectorLayer::updateExtents().
Referenced by QgsVectorLayer::addFeatures(), and QgsVectorLayerEditUtils::splitFeatures().
|
signal |
|
signal |
|
signal |
bool QgsVectorLayerEditBuffer::changeAttributeValue | ( | QgsFeatureId | fid, |
int | field, | ||
const QVariant & | newValue, | ||
const QVariant & | oldValue = QVariant() |
||
) |
changed an attribute value (but does not commit it)
Definition at line 172 of file qgsvectorlayereditbuffer.cpp.
References QgsVectorDataProvider::capabilities(), QgsVectorDataProvider::ChangeAttributeValues, QgsFields::count(), QgsVectorLayer::dataProvider(), FID_IS_NEW, QgsFields::fieldOrigin(), L, mAddedFeatures, QgsFields::OriginJoin, QgsVectorLayer::pendingFields(), QgsVectorLayerUndoCommandChangeAttribute, and QgsMapLayer::undoStack().
Referenced by QgsVectorLayer::changeAttributeValue().
|
inline |
Changed attributes values which are not commited.
Definition at line 98 of file qgsvectorlayereditbuffer.h.
Referenced by QgsFeatureListModel::data(), QgsAttributeTableFilterModel::filterAcceptsRow(), and QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator().
|
inline |
Changed geometries which are not commited.
Definition at line 107 of file qgsvectorlayereditbuffer.h.
Referenced by QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator().
bool QgsVectorLayerEditBuffer::changeGeometry | ( | QgsFeatureId | fid, |
QgsGeometry * | geom | ||
) |
change feature's geometry
Definition at line 149 of file qgsvectorlayereditbuffer.cpp.
References QgsVectorDataProvider::capabilities(), QgsVectorDataProvider::ChangeGeometries, QgsVectorLayer::dataProvider(), FID_IS_NEW, QgsVectorLayer::hasGeometryType(), L, mAddedFeatures, QgsVectorLayerUndoCommandChangeGeometry, and QgsMapLayer::undoStack().
Referenced by QgsVectorLayerEditUtils::addPart(), QgsVectorLayerEditUtils::addRing(), QgsVectorLayer::changeGeometry(), QgsVectorLayerEditUtils::deleteVertex(), QgsVectorLayerEditUtils::insertVertex(), QgsVectorLayerEditUtils::moveVertex(), QgsVectorLayerEditUtils::splitFeatures(), QgsVectorLayerEditUtils::splitParts(), and QgsVectorLayerEditUtils::translateFeature().
bool QgsVectorLayerEditBuffer::commitChanges | ( | QStringList & | commitErrors | ) |
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.
Definition at line 238 of file qgsvectorlayereditbuffer.cpp.
References QgsVectorDataProvider::AddAttributes, QgsVectorDataProvider::addAttributes(), QgsVectorDataProvider::AddFeatures, QgsVectorDataProvider::addFeatures(), QgsFeature::attributes(), QgsVectorDataProvider::capabilities(), QgsVectorDataProvider::ChangeAttributeValues, QgsVectorDataProvider::changeAttributeValues(), QgsVectorDataProvider::ChangeGeometries, QgsVectorDataProvider::changeGeometryValues(), QgsVectorDataProvider::clearErrors(), committedAttributesAdded(), committedAttributesDeleted(), committedAttributeValuesChanges(), committedFeaturesAdded(), committedFeaturesRemoved(), committedGeometriesChanges(), QgsFields::count(), QgsVectorDataProvider::createSpatialIndex(), QgsVectorLayer::dataProvider(), QgsVectorDataProvider::DeleteAttributes, QgsVectorDataProvider::deleteAttributes(), QgsVectorDataProvider::DeleteFeatures, QgsVectorDataProvider::deleteFeatures(), QgsVectorDataProvider::errors(), featureAdded(), featureDeleted(), FID_TO_STRING, QgsVectorDataProvider::hasErrors(), QgsMapLayer::id(), QgsFeature::id(), L, mAddedAttributes, mAddedFeatures, mChangedAttributeValues, mChangedGeometries, mDeletedAttributeIds, mDeletedFeatureIds, QgsVectorLayer::mSelectedFeatureIds, QgsField::name(), QgsVectorLayer::pendingFields(), QgsVectorLayer::providerType(), QgsFields::size(), QgsVectorLayer::storageType(), tr, and QgsVectorLayer::updateFields().
Referenced by QgsVectorLayer::commitChanges().
|
signal |
Referenced by commitChanges().
|
signal |
|
signal |
Referenced by commitChanges().
|
signal |
Referenced by commitChanges().
|
signal |
Referenced by commitChanges().
|
signal |
Referenced by commitChanges().
bool QgsVectorLayerEditBuffer::deleteAttribute | ( | int | attr | ) |
delete an attribute field (but does not commit it)
Definition at line 215 of file qgsvectorlayereditbuffer.cpp.
References QgsVectorDataProvider::capabilities(), QgsFields::count(), QgsVectorLayer::dataProvider(), QgsVectorDataProvider::DeleteAttributes, QgsFields::fieldOrigin(), QgsFields::fieldOriginIndex(), L, mDeletedAttributeIds, QgsFields::OriginJoin, QgsFields::OriginProvider, QgsVectorLayer::pendingFields(), QgsVectorLayerUndoCommandDeleteAttribute, and QgsMapLayer::undoStack().
Referenced by QgsVectorLayer::deleteAttribute().
|
inline |
deleted attributes fields which are not commited.
The list is kept sorted.
Definition at line 101 of file qgsvectorlayereditbuffer.h.
Referenced by QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator().
|
inline |
Definition at line 109 of file qgsvectorlayereditbuffer.h.
Referenced by QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator().
bool QgsVectorLayerEditBuffer::deleteFeature | ( | QgsFeatureId | fid | ) |
delete a feature from the layer (but does not commit it)
Definition at line 128 of file qgsvectorlayereditbuffer.cpp.
References QgsVectorDataProvider::capabilities(), QgsVectorLayer::dataProvider(), QgsVectorDataProvider::DeleteFeatures, FID_IS_NEW, L, mAddedFeatures, mDeletedFeatureIds, QgsVectorLayerUndoCommandDeleteFeature, and QgsMapLayer::undoStack().
Referenced by QgsVectorLayer::deleteFeature().
|
signal |
|
signal |
|
signal |
|
protected |
update added and changed features after addition of an attribute
Definition at line 544 of file qgsvectorlayereditbuffer.cpp.
References mAddedFeatures, mChangedAttributeValues, and updateAttributeMapIndex().
Referenced by QgsVectorLayerUndoCommandAddAttribute::redo(), and QgsVectorLayerUndoCommandDeleteAttribute::undo().
|
protected |
update added and changed features after removal of an attribute
Definition at line 561 of file qgsvectorlayereditbuffer.cpp.
References mAddedFeatures, mChangedAttributeValues, and updateAttributeMapIndex().
Referenced by QgsVectorLayerUndoCommandDeleteAttribute::redo(), and QgsVectorLayerUndoCommandAddAttribute::undo().
bool QgsVectorLayerEditBuffer::isModified | ( | ) | const |
Returns true if the provider has been modified since the last commit.
Definition at line 35 of file qgsvectorlayereditbuffer.cpp.
References L, and QgsMapLayer::undoStack().
Referenced by QgsVectorLayer::isModified(), and rollBack().
|
signal |
This signal is emitted when modifications has been done on layer.
Referenced by undoIndexChanged().
void QgsVectorLayerEditBuffer::rollBack | ( | ) |
Stop editing and discard the edits.
Definition at line 511 of file qgsvectorlayereditbuffer.cpp.
References isModified(), L, mAddedAttributes, mAddedFeatures, mChangedAttributeValues, mChangedGeometries, mDeletedAttributeIds, and QgsMapLayer::undoStack().
Referenced by QgsVectorLayer::rollBack().
|
protectedslot |
Definition at line 41 of file qgsvectorlayereditbuffer.cpp.
References layerModified(), and QgsDebugMsg.
Referenced by QgsVectorLayerEditBuffer().
|
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.
Referenced by handleAttributeAdded(), and handleAttributeDeleted().
|
protected |
Update feature with uncommited attribute updates.
Definition at line 71 of file qgsvectorlayereditbuffer.cpp.
References QgsFeature::attributes(), QgsFeature::id(), mAddedAttributes, mChangedAttributeValues, and mDeletedAttributeIds.
|
protected |
Update feature with uncommited geometry updates.
Definition at line 64 of file qgsvectorlayereditbuffer.cpp.
References QgsFeature::id(), mChangedGeometries, and QgsFeature::setGeometry().
|
protected |
Definition at line 49 of file qgsvectorlayereditbuffer.cpp.
References QgsFields::append(), mAddedAttributes, mDeletedAttributeIds, QgsFields::OriginEdit, and QgsFields::remove().
Referenced by QgsVectorLayer::updateFields().
|
protected |
Definition at line 599 of file qgsvectorlayereditbuffer.cpp.
References L, and QgsVectorLayer::updateFields().
Referenced by QgsVectorLayerUndoCommandAddAttribute::redo(), QgsVectorLayerUndoCommandDeleteAttribute::redo(), QgsVectorLayerUndoCommandAddAttribute::undo(), and QgsVectorLayerUndoCommandDeleteAttribute::undo().
|
friend |
Definition at line 160 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 162 of file qgsvectorlayereditbuffer.h.
|
friend |
Definition at line 167 of file qgsvectorlayereditbuffer.h.
Referenced by addAttribute().
|
friend |
Definition at line 163 of file qgsvectorlayereditbuffer.h.
Referenced by addFeature().
|
friend |
Definition at line 166 of file qgsvectorlayereditbuffer.h.
Referenced by changeAttributeValue().
|
friend |
Definition at line 165 of file qgsvectorlayereditbuffer.h.
Referenced by changeGeometry().
|
friend |
Definition at line 168 of file qgsvectorlayereditbuffer.h.
Referenced by deleteAttribute().
|
friend |
Definition at line 164 of file qgsvectorlayereditbuffer.h.
Referenced by deleteFeature().
|
protected |
Definition at line 159 of file qgsvectorlayereditbuffer.h.
Referenced by addAttribute(), addFeature(), addFeatures(), changeAttributeValue(), changeGeometry(), commitChanges(), deleteAttribute(), deleteFeature(), isModified(), QgsVectorLayerEditBuffer(), rollBack(), and updateLayerFields().
|
protected |
added attributes fields which are not commited
Definition at line 186 of file qgsvectorlayereditbuffer.h.
Referenced by commitChanges(), QgsVectorLayerUndoCommandDeleteAttribute::QgsVectorLayerUndoCommandDeleteAttribute(), QgsVectorLayerUndoCommandAddAttribute::redo(), QgsVectorLayerUndoCommandDeleteAttribute::redo(), rollBack(), QgsVectorLayerUndoCommandAddAttribute::undo(), QgsVectorLayerUndoCommandDeleteAttribute::undo(), updateChangedAttributes(), and updateFields().
|
protected |
New features which are not commited.
Definition at line 177 of file qgsvectorlayereditbuffer.h.
Referenced by changeAttributeValue(), changeGeometry(), commitChanges(), deleteFeature(), QgsVectorLayer::extent(), handleAttributeAdded(), handleAttributeDeleted(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayer::pendingFeatureCount(), QgsVectorLayerUndoCommandChangeAttribute::QgsVectorLayerUndoCommandChangeAttribute(), QgsVectorLayerUndoCommandChangeGeometry::QgsVectorLayerUndoCommandChangeGeometry(), QgsVectorLayerUndoCommandDeleteAttribute::QgsVectorLayerUndoCommandDeleteAttribute(), QgsVectorLayerUndoCommandDeleteFeature::QgsVectorLayerUndoCommandDeleteFeature(), QgsVectorLayerUndoCommandAddFeature::redo(), QgsVectorLayerUndoCommandDeleteFeature::redo(), QgsVectorLayerUndoCommandChangeGeometry::redo(), QgsVectorLayerUndoCommandChangeAttribute::redo(), rollBack(), QgsVectorLayerUndoCommandAddFeature::undo(), QgsVectorLayerUndoCommandDeleteFeature::undo(), QgsVectorLayerUndoCommandChangeGeometry::undo(), QgsVectorLayerUndoCommandChangeAttribute::undo(), QgsVectorLayerUndoCommandDeleteAttribute::undo(), and QgsVectorLayer::uniqueValues().
|
protected |
Changed attributes values which are not commited.
Definition at line 180 of file qgsvectorlayereditbuffer.h.
Referenced by commitChanges(), handleAttributeAdded(), handleAttributeDeleted(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayerUndoCommandChangeAttribute::QgsVectorLayerUndoCommandChangeAttribute(), QgsVectorLayerUndoCommandDeleteAttribute::QgsVectorLayerUndoCommandDeleteAttribute(), QgsVectorLayerUndoCommandChangeAttribute::redo(), rollBack(), QgsVectorLayerUndoCommandChangeAttribute::undo(), QgsVectorLayerUndoCommandDeleteAttribute::undo(), QgsVectorLayer::uniqueValues(), and updateChangedAttributes().
|
protected |
Changed geometries which are not commited.
Definition at line 189 of file qgsvectorlayereditbuffer.h.
Referenced by commitChanges(), QgsVectorLayer::extent(), QgsVectorLayerUndoCommandChangeGeometry::QgsVectorLayerUndoCommandChangeGeometry(), QgsVectorLayerUndoCommandChangeGeometry::redo(), rollBack(), QgsVectorLayerUndoCommandChangeGeometry::undo(), and updateFeatureGeometry().
|
protected |
deleted attributes fields which are not commited.
The list is kept sorted.
Definition at line 183 of file qgsvectorlayereditbuffer.h.
Referenced by commitChanges(), deleteAttribute(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayerUndoCommandDeleteAttribute::redo(), rollBack(), QgsVectorLayerUndoCommandDeleteAttribute::undo(), QgsVectorLayer::uniqueValues(), updateChangedAttributes(), and updateFields().
|
protected |
Deleted feature IDs which are not commited.
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 174 of file qgsvectorlayereditbuffer.h.
Referenced by commitChanges(), deleteFeature(), QgsVectorLayer::extent(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayer::pendingFeatureCount(), QgsVectorLayerUndoCommandDeleteFeature::redo(), QgsVectorLayerUndoCommandDeleteFeature::undo(), and QgsVectorLayer::uniqueValues().