34 , mSavePointId( ( mBuffer->L->isEditCommandActive() && !mBuffer->L->dataProvider()->transaction()->savePoints().isEmpty() )
36 ? mBuffer->L->dataProvider()->transaction()->savePoints().last()
37 : mBuffer->L->dataProvider()->transaction()->createSavepoint( mError ) )
38 , mHasError( !mError.isEmpty() )
39 , mRecreateSavePoint( mBuffer->L->isEditCommandActive()
40 ? !mBuffer->L->dataProvider()->transaction()->lastSavePointIsDirty()
53 setText( text() +
" " + QObject::tr(
"failed" ) );
72 if ( savePointId.isEmpty() )
78 if ( mSavePointId.isEmpty() )
86 mSavePointId = savePointId;
109 static int sAddedIdLowWaterMark = -1;
112 mInitialFeatures << f;
114 sAddedIdLowWaterMark--;
115 mInitialFeatures.last().setId( sAddedIdLowWaterMark );
117 mFeatures = mInitialFeatures;
124 for (
const QgsFeature &f : qgis::as_const( mFeatures ) )
128 mFeatures = mInitialFeatures;
134 mFeatures = mInitialFeatures;
137 for (
const QgsFeature &f : qgis::as_const( mFeatures ) )
184 , mOldGeom( mBuffer->L->getFeature( mFid ).geometry() )
199 geomMap.insert( mFid, mNewGeom );
214 , mNewValue( newValue )
215 , mOldValue( mBuffer->L->getFeature( mFid ).attribute(
field ) )
230 map.insert( mField, mNewValue );
232 attribMap.insert( mFid, map );
281 , mField( mBuffer->L->fields()[ attr ] )
318 , mNewName( newName )
319 , mOldName( mBuffer->L->fields()[ mAttr ].name() )
328 map[ mAttr ] = mOldName;
343 map[ mAttr ] = mNewName;
357 , mTransaction( transaction )
410 , mNewValues( newValues )
411 , mOldValues( oldValues )
419 for (
auto it = mNewValues.constBegin(); it != mNewValues.constEnd(); ++it )
429 attribMap.insert( mFid, mNewValues );
432 for (
auto it = mNewValues.constBegin(); it != mNewValues.constEnd(); ++it )
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Encapsulate a field in an attribute table or data source.
A geometry is the spatial representation of a feature.
This class allows including a set of layers in a database-side transaction, provided the layer data p...
QList< QString > savePoints() const
returns savepoints
bool rollbackToSavepoint(const QString &name, QString &error)
rollback to save point, the save point is maintained and is "undertied"
virtual bool executeSql(const QString &sql, QString &error, bool isDirty=false, const QString &name=QString())=0
Execute the sql string.
QString createSavepoint(QString &error)
creates a save point returns empty string on error returns the last created savepoint if it's not dir...
virtual bool changeGeometryValues(const QgsGeometryMap &geometry_map)
Changes geometries of existing features.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
virtual bool changeAttributeValues(const QgsChangedAttributesMap &attr_map)
Changes attribute values of existing features.
virtual bool deleteFeatures(const QgsFeatureIds &id)
Deletes one or more features from the provider.
bool addFeatures(QgsFeatureList &flist, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features to the sink.
virtual bool addAttributes(const QList< QgsField > &attributes)
Adds new attributes to the provider.
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
virtual bool renameAttributes(const QgsFieldNameMap &renamedAttributes)
Renames existing attributes.
virtual bool deleteAttributes(const QgsAttributeIds &attributes)
Deletes existing attributes from the provider.
void attributeRenamed(int idx, const QString &newName)
Emitted when an attribute has been renamed.
void geometryChanged(QgsFeatureId fid, const QgsGeometry &geom)
Emitted when a feature's geometry is changed.
void featureDeleted(QgsFeatureId fid)
void attributeAdded(int idx)
void attributeDeleted(int idx)
void featureAdded(QgsFeatureId fid)
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &)
Base class for undo commands within a QgsVectorLayerEditBuffer.
QgsVectorLayerEditBuffer * mBuffer
Associated edit buffer.
QgsVectorLayerUndoPassthroughCommandAddAttribute(QgsVectorLayerEditBuffer *buffer, const QgsField &field)
Constructor for QgsVectorLayerUndoPassthroughCommandAddAttribute.
QgsFeatureList features() const
List of features (added feaures can be modified by default values from database)
QgsVectorLayerUndoPassthroughCommandAddFeatures(QgsVectorLayerEditBuffer *buffer, QgsFeatureList &features)
Constructor for QgsVectorLayerUndoPassthroughCommandAddFeatures.
QgsVectorLayerUndoPassthroughCommandChangeAttribute(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, int field, const QVariant &newValue)
Constructor for QgsVectorLayerUndoPassthroughCommandChangeAttribute.
QgsVectorLayerUndoPassthroughCommandChangeAttributes(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues=QgsAttributeMap())
Constructor for QgsVectorLayerUndoPassthroughCommandChangeAttributes.
QgsVectorLayerUndoPassthroughCommandChangeGeometry(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, const QgsGeometry &geom)
Constructor for QgsVectorLayerUndoPassthroughCommandChangeGeometry.
QgsVectorLayerUndoPassthroughCommandDeleteAttribute(QgsVectorLayerEditBuffer *buffer, int attr)
Constructor for QgsVectorLayerUndoCommandDeleteAttribute.
QgsVectorLayerUndoPassthroughCommandDeleteFeatures(QgsVectorLayerEditBuffer *buffer, const QgsFeatureIds &fids)
Constructor for QgsVectorLayerUndoPassthroughCommandDeleteFeatures.
QgsVectorLayerUndoPassthroughCommandRenameAttribute(QgsVectorLayerEditBuffer *buffer, int attr, const QString &newName)
Constructor for QgsVectorLayerUndoCommandRenameAttribute.
QgsVectorLayerUndoPassthroughCommandUpdate(QgsVectorLayerEditBuffer *buffer, QgsTransaction *transaction, const QString &sql, const QString &name)
Constructor for QgsVectorLayerUndoCommandUpdate.
Undo command for vector layer in transaction group mode.
QgsVectorLayerUndoPassthroughCommand(QgsVectorLayerEditBuffer *buffer, const QString &text, bool autocreate=true)
Constructor for QgsVectorLayerUndoPassthroughCommand.
QString errorMessage() const
Returns the error message or an empty string if there's none.
void setErrorMessage(const QString &errorMessage)
Sets the error message.
void setError()
Set error flag and append "failed" to text.
bool hasError() const
Returns error status.
bool setSavePoint(const QString &savePointId=QString())
Set the command savepoint or set error status.
bool rollBackToSavePoint()
Rollback command, release savepoint or set error status save point must be set prior to call error sa...
void layerModified()
Emitted when modifications has been done on layer.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
QMap< int, QString > QgsFieldNameMap
QMap< int, QVariant > QgsAttributeMap
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
QList< QgsFeature > QgsFeatureList
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QSet< int > QgsAttributeIds