30 static int addedIdLowWaterMark = -1;
33 addedIdLowWaterMark--;
80 mOldAddedFeature = it.value();
122 mOldGeom = ( it.value().constGeometry() ?
new QgsGeometry( *it.value().constGeometry() ) :
nullptr );
129 mOldGeom = ( changedAlready && cachedGeom ) ?
new QgsGeometry( geom ) :
nullptr;
142 if ( other->
id() !=
id() )
149 if ( merge->mFid != mFid )
153 mNewGeom = merge->mNewGeom;
154 merge->mNewGeom =
nullptr;
172 it.value().setGeometry( *mOldGeom );
209 it.value().setGeometry( *mNewGeom );
223 , mFieldIndex( fieldIndex )
224 , mOldValue( oldValue )
225 , mNewValue( newValue )
226 , mFirstChange( true )
233 if ( it.value().attribute( mFieldIndex ).isValid() )
235 mOldValue = it.
value().attribute( mFieldIndex );
236 mFirstChange =
false;
242 mFirstChange =
false;
256 it.value().setAttribute( mFieldIndex, mOldValue );
258 else if ( mFirstChange )
293 it.value().setAttribute( mFieldIndex, mNewValue );
344 , mFieldIndex( fieldIndex )
352 if ( !mProviderField )
374 if ( attrs.
contains( mFieldIndex ) )
375 mDeletedValues.
insert( it.key(), attrs[mFieldIndex] );
381 if ( mProviderField )
412 attrs.
insert( mFieldIndex, it.value() );
423 if ( mProviderField )
443 , mFieldIndex( fieldIndex )
444 , mOldName(
layer()->fields().at( fieldIndex ).name() )
445 , mNewName( newName )
Wrapper for iterator of features from vector data provider or vector layer.
void handleAttributeDeleted(int index)
Update added and changed features after removal of an attribute.
field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
QgsVectorLayerUndoCommandAddFeature(QgsVectorLayerEditBuffer *buffer, QgsFeature &f)
Constructor for QgsVectorLayerUndoCommandAddFeature.
bool contains(const Key &key) const
QMap< int, QVariant > QgsAttributeMap
virtual void redo() override
virtual int id() const override
virtual void undo() override
void attributeDeleted(int idx)
virtual void redo() override
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
const_iterator constBegin() const
QgsVectorLayerEditBuffer * mBuffer
Associated edit buffer.
QgsGeometryCache * cache()
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Base class for undo commands within a QgsVectorLayerEditBuffer.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index.
QgsChangedAttributesMap mChangedAttributeValues
Changed attributes values which are not commited.
const_iterator constFind(const Key &key) const
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
~QgsVectorLayerUndoCommandChangeGeometry()
field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
const_iterator insert(const T &value)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsFieldNameMap mRenamedAttributes
Renamed attributes which are not commited.
QgsVectorLayerUndoCommandAddAttribute(QgsVectorLayerEditBuffer *buffer, const QgsField &field)
Constructor for QgsVectorLayerUndoCommandAddAttribute.
int count() const
Return number of items.
virtual void undo() override
QgsEditFormConfig * editFormConfig() const
Get the configuration of the form used to represent this vector layer.
QgsFields fields() const
Returns the list of fields of this layer.
QgsVectorLayerUndoCommandDeleteAttribute(QgsVectorLayerEditBuffer *buffer, int fieldIndex)
Constructor for QgsVectorLayerUndoCommandDeleteAttribute.
int fieldOriginIndex(int fieldIdx) const
Get field's origin index (its meaning is specific to each type of origin)
virtual void redo() override
void featureAdded(QgsFeatureId fid)
virtual void undo() override
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Set feature ID that should be fetched.
void removeGeometry(QgsFeatureId fid)
get rid of the cached geometry
Undo command for modifying the geometry of a feature from a vector layer.
QString number(int n, int base)
void append(const T &value)
void setFeatureId(QgsFeatureId id)
Sets the feature ID for this feature.
QgsVectorLayerUndoCommandChangeAttribute(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, int fieldIndex, const QVariant &newValue, const QVariant &oldValue)
Constructor for QgsVectorLayerUndoCommandChangeAttribute.
void attributeAdded(int idx)
void geometryChanged(QgsFeatureId fid, QgsGeometry &geom)
bool geometry(QgsFeatureId fid, QgsGeometry &geometry)
fetch geometry from cache, return true if successful
QgsVectorLayer * layer()
Returns the layer associated with the undo command.
virtual void undo() override
const_iterator constEnd() const
QgsGeometryMap mChangedGeometries
Changed geometries which are not commited.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
void handleAttributeAdded(int index)
Update added and changed features after addition of an attribute.
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched.
QgsFeatureIds mDeletedFeatureIds
Deleted feature IDs which are not commited.
Encapsulate a field in an attribute table or data source.
QgsVectorLayerUndoCommandRenameAttribute(QgsVectorLayerEditBuffer *buffer, int fieldIndex, const QString &newName)
Constructor for QgsVectorLayerUndoCommandRenameAttribute.
void attributeRenamed(int idx, const QString &newName)
Emitted when an attribute has been renamed.
QgsFeatureId id() const
Get the feature ID for this feature.
virtual void undo() override
QgsGeometry * geometry()
Get the geometry object associated with this feature.
virtual void redo() override
QList< QgsField > mAddedAttributes
Added attributes fields which are not commited.
bool remove(const T &value)
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &)
void insert(int i, const T &value)
virtual void redo() override
void cacheGeometry(QgsFeatureId fid, const QgsGeometry &geom)
store a geometry in the cache
virtual void redo() override
iterator insert(const Key &key, const T &value)
QgsVectorLayerUndoCommandChangeGeometry(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, QgsGeometry *newGeom)
Constructor for QgsVectorLayerUndoCommandChangeGeometry.
virtual bool mergeWith(const QUndoCommand *) override
QgsVectorLayerUndoCommandDeleteFeature(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid)
Constructor for QgsVectorLayerUndoCommandDeleteFeature.
bool nextFeature(QgsFeature &f)
Geometry is not required. It may still be returned if e.g. required for a filter condition.
QgsFeatureMap mAddedFeatures
New features which are not commited.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
bool removeOne(const T &value)
QgsAttributeList mDeletedAttributeIds
Deleted attributes fields which are not commited.
iterator find(const Key &key)
void featureDeleted(QgsFeatureId fid)
virtual void redo() override
virtual void undo() override
const T value(const Key &key) const
int remove(const Key &key)
virtual void undo() override