QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
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 )
QgsVectorLayerUndoPassthroughCommand(QgsVectorLayerEditBuffer *buffer, const QString &text, bool autocreate=true)
Constructor for QgsVectorLayerUndoPassthroughCommand.
QList< QString > savePoints() const
returns savepoints
QSet< int > QgsAttributeIds
virtual bool deleteFeatures(const QgsFeatureIds &id)
Deletes one or more features from the provider.
QgsVectorLayerEditBuffer * mBuffer
Associated edit buffer.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
QgsVectorLayerUndoPassthroughCommandAddFeatures(QgsVectorLayerEditBuffer *buffer, QgsFeatureList &features)
Constructor for QgsVectorLayerUndoPassthroughCommandAddFeatures.
void layerModified()
Emitted when modifications has been done on layer.
bool rollBackToSavePoint()
Rollback command, release savepoint or set error status save point must be set prior to call error sa...
virtual bool changeAttributeValues(const QgsChangedAttributesMap &attr_map)
Changes attribute values 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 executeSql(const QString &sql, QString &error, bool isDirty=false, const QString &name=QString())=0
Execute the sql string.
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
QgsFeatureList features() const
List of features (added feaures can be modified by default values from database)
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Undo command for vector layer in transaction group mode.
QgsVectorLayerUndoPassthroughCommandChangeAttributes(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues=QgsAttributeMap())
Constructor for QgsVectorLayerUndoPassthroughCommandChangeAttributes.
bool hasError() const
Returns error status.
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &)
void geometryChanged(QgsFeatureId fid, const QgsGeometry &geom)
Emitted when a feature's geometry is changed.
QString errorMessage() const
Returns the error message or an empty string if there's none.
QgsVectorLayerUndoPassthroughCommandAddAttribute(QgsVectorLayerEditBuffer *buffer, const QgsField &field)
Constructor for QgsVectorLayerUndoPassthroughCommandAddAttribute.
bool setSavePoint(const QString &savePointId=QString())
Set the command savepoint or set error status.
QgsVectorLayerUndoPassthroughCommandChangeGeometry(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, const QgsGeometry &geom)
Constructor for QgsVectorLayerUndoPassthroughCommandChangeGeometry.
QgsVectorLayerUndoPassthroughCommandChangeAttribute(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, int field, const QVariant &newValue)
Constructor for QgsVectorLayerUndoPassthroughCommandChangeAttribute.
void featureDeleted(QgsFeatureId fid)
bool rollbackToSavepoint(const QString &name, QString &error)
rollback to save point, the save point is maintained and is "undertied"
virtual bool changeGeometryValues(const QgsGeometryMap &geometry_map)
Changes geometries of existing features.
void featureAdded(QgsFeatureId fid)
QgsVectorLayerUndoPassthroughCommandUpdate(QgsVectorLayerEditBuffer *buffer, QgsTransaction *transaction, const QString &sql, const QString &name)
Constructor for QgsVectorLayerUndoCommandUpdate.
QgsVectorLayerUndoPassthroughCommandDeleteAttribute(QgsVectorLayerEditBuffer *buffer, int attr)
Constructor for QgsVectorLayerUndoCommandDeleteAttribute.
virtual bool renameAttributes(const QgsFieldNameMap &renamedAttributes)
Renames existing attributes.
QList< QgsFeature > QgsFeatureList
QMap< int, QVariant > QgsAttributeMap
void attributeDeleted(int idx)
void setError()
Set error flag and append "failed" to text.
void attributeRenamed(int idx, const QString &newName)
Emitted when an attribute has been renamed.
void attributeAdded(int idx)
QSet< QgsFeatureId > QgsFeatureIds
Base class for undo commands within a QgsVectorLayerEditBuffer.
virtual bool deleteAttributes(const QgsAttributeIds &attributes)
Deletes existing attributes from the provider.
bool addFeatures(QgsFeatureList &flist, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features to the sink.
QgsVectorLayerUndoPassthroughCommandRenameAttribute(QgsVectorLayerEditBuffer *buffer, int attr, const QString &newName)
Constructor for QgsVectorLayerUndoCommandRenameAttribute.
QMap< int, QString > QgsFieldNameMap
virtual bool addAttributes(const QList< QgsField > &attributes)
Adds new attributes to the provider.
QString createSavepoint(QString &error)
creates a save point returns empty string on error returns the last created savepoint if it's not dir...
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
QgsVectorLayerUndoPassthroughCommandDeleteFeatures(QgsVectorLayerEditBuffer *buffer, const QgsFeatureIds &fids)
Constructor for QgsVectorLayerUndoPassthroughCommandDeleteFeatures.
void setErrorMessage(const QString &errorMessage)
Sets the error message.