30 static int sAddedIdLowWaterMark = -1;
33 sAddedIdLowWaterMark--;
35 QgsDebugMsgLevel(
"Assigned feature id " + QString::number( sAddedIdLowWaterMark ), 4 );
40 f.
setId( sAddedIdLowWaterMark );
74 mOldAddedFeature = it.value();
111 , mNewGeom( newGeom )
117 mOldGeom = ( it.value().geometry() );
132 if ( other->id() !=
id() )
139 if ( merge->mFid != mFid )
142 mNewGeom = merge->mNewGeom;
155 it.value().setGeometry( mOldGeom );
189 it.value().setGeometry( mNewGeom );
202 , mFieldIndex( fieldIndex )
203 , mOldValue( oldValue )
204 , mNewValue( newValue )
205 , mFirstChange( true )
212 if ( it.value().attribute( mFieldIndex ).isValid() )
214 mOldValue = it.value().attribute( mFieldIndex );
215 mFirstChange =
false;
221 mFirstChange =
false;
228 QVariant original = mOldValue;
235 it.value().setAttribute( mFieldIndex, mOldValue );
237 else if ( mFirstChange )
244 if ( !mOldValue.isValid() )
272 it.value().setAttribute( mFieldIndex, mNewValue );
323 , mFieldIndex( fieldIndex )
329 mFieldName = fields.
field( mFieldIndex ).
name();
331 if ( !mProviderField )
346 mDeletedValues.insert( f.
id(), f.
attribute( mFieldIndex ) );
353 if ( attrs.contains( mFieldIndex ) )
354 mDeletedValues.insert( it.key(), attrs[mFieldIndex] );
360 if ( mProviderField )
373 if ( !mOldName.isEmpty() )
386 for ( QMap<QgsFeatureId, QVariant>::const_iterator it = mDeletedValues.constBegin(); it != mDeletedValues.constEnd(); ++it )
391 attrs.insert( mFieldIndex, it.value() );
403 if ( mProviderField )
422 , mFieldIndex( fieldIndex )
423 , mOldName(
layer()->fields().at( fieldIndex ).name() )
424 , mNewName( newName )
434 if ( mProviderField )
449 if ( mProviderField )
Wrapper for iterator of features from vector data provider or vector layer.
void geometryChanged(QgsFeatureId fid, const QgsGeometry &geom)
Emitted when a feature's geometry is changed.
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...
QgsVectorLayerUndoCommandAddFeature(QgsVectorLayerEditBuffer *buffer, QgsFeature &f)
Constructor for QgsVectorLayerUndoCommandAddFeature.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
void attributeDeleted(int idx)
QgsVectorLayerEditBuffer * mBuffer
Associated edit buffer.
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 committed.
Field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsFieldNameMap mRenamedAttributes
Renamed attributes which are not committed.
QgsVectorLayerUndoCommandAddAttribute(QgsVectorLayerEditBuffer *buffer, const QgsField &field)
Constructor for QgsVectorLayerUndoCommandAddAttribute.
QgsVectorLayerUndoCommandDeleteAttribute(QgsVectorLayerEditBuffer *buffer, int fieldIndex)
Constructor for QgsVectorLayerUndoCommandDeleteAttribute.
void featureAdded(QgsFeatureId fid)
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets feature ID that should be fetched.
Undo command for modifying the geometry of a feature from a vector layer.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
QgsVectorLayerUndoCommandChangeAttribute(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, int fieldIndex, const QVariant &newValue, const QVariant &oldValue)
Constructor for QgsVectorLayerUndoCommandChangeAttribute.
void attributeAdded(int idx)
#define QgsDebugMsgLevel(str, level)
QgsVectorLayer * layer()
Returns the layer associated with the undo command.
int fieldOriginIndex(int fieldIdx) const
Gets field's origin index (its meaning is specific to each type of origin)
QMap< int, QVariant > QgsAttributeMap
QgsGeometryMap mChangedGeometries
Changed geometries which are not committed.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
void handleAttributeAdded(int index)
Update added and changed features after addition of an attribute.
QgsVectorLayerUndoCommandChangeGeometry(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, const QgsGeometry &newGeom)
Constructor for QgsVectorLayerUndoCommandChangeGeometry.
int count() const
Returns number of items.
QgsFeatureIds mDeletedFeatureIds
Deleted feature IDs which are not committed.
Encapsulate a field in an attribute table or data source.
void setId(QgsFeatureId id)
Sets the feature ID for this feature.
QgsVectorLayerUndoCommandRenameAttribute(QgsVectorLayerEditBuffer *buffer, int fieldIndex, const QString &newName)
Constructor for QgsVectorLayerUndoCommandRenameAttribute.
QgsField field(int fieldIdx) const
Gets field at particular index (must be in range 0..N-1)
QgsEditFormConfig editFormConfig
void attributeRenamed(int idx, const QString &newName)
Emitted when an attribute has been renamed.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QList< QgsField > mAddedAttributes
Added attributes fields which are not committed.
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &)
bool hasGeometry() const
Returns true if the feature has an associated geometry.
FieldOrigin fieldOrigin(int fieldIdx) const
Gets field's origin (value from an enumeration)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
bool mergeWith(const QUndoCommand *) override
QList< int > QgsAttributeList
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.
void setEditFormConfig(const QgsEditFormConfig &editFormConfig)
Set the editFormConfig (configuration) of the form used to represent this vector layer.
QgsFeatureMap mAddedFeatures
New features which are not committed.
QgsAttributeList mDeletedAttributeIds
Deleted attributes fields which are not committed. The list is kept sorted.
void featureDeleted(QgsFeatureId fid)
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.