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() );
129 if ( other->id() !=
id() )
136 if ( merge->mFid != mFid )
139 mNewGeom = merge->mNewGeom;
152 it.value().setGeometry( mOldGeom );
186 it.value().setGeometry( mNewGeom );
199 , mFieldIndex( fieldIndex )
200 , mOldValue( oldValue )
201 , mNewValue( newValue )
202 , mFirstChange( true )
210 if ( it.value().attribute( mFieldIndex ).isValid() )
212 mOldValue = it.value().attribute( mFieldIndex );
213 mFirstChange =
false;
227 if ( it->contains( mFieldIndex ) )
230 mFirstChange =
false;
243 QVariant original = mOldValue;
257 it.value().setAttribute( mFieldIndex, mOldValue );
260 else if ( mFirstChange )
267 if ( !mOldValue.isValid() )
295 it.value().setAttribute( mFieldIndex, mNewValue );
346 , mFieldIndex( fieldIndex )
352 mFieldName = fields.
field( mFieldIndex ).
name();
354 if ( !mProviderField )
369 mDeletedValues.insert( f.
id(), f.
attribute( mFieldIndex ) );
376 if ( attrs.contains( mFieldIndex ) )
377 mDeletedValues.insert( it.key(), attrs[mFieldIndex] );
383 if ( mProviderField )
396 if ( !mOldName.isEmpty() )
409 for ( QMap<QgsFeatureId, QVariant>::const_iterator it = mDeletedValues.constBegin(); it != mDeletedValues.constEnd(); ++it )
414 attrs.insert( mFieldIndex, it.value() );
426 if ( mProviderField )
445 , mFieldIndex( fieldIndex )
446 , mOldName( layer()->fields().at( fieldIndex ).name() )
447 , mNewName( newName )
457 if ( mProviderField )
472 if ( mProviderField )
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
@ Provider
Field originates from the underlying data provider of the vector layer.
@ Join
Field originates from a joined layer.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFlags(Qgis::FeatureRequestFlags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets the feature ID that should be fetched.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Q_INVOKABLE bool setAttribute(int field, const QVariant &attr)
Sets an attribute's value by field index.
void setId(QgsFeatureId id)
Sets the feature id for this feature.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
QgsField field(int fieldIdx) const
Returns the field at particular index (must be in range 0..N-1).
Qgis::FieldOrigin fieldOrigin(int fieldIdx) const
Returns the field's origin (value from an enumeration).
int fieldOriginIndex(int fieldIdx) const
Returns the field's origin index (its meaning is specific to each type of origin).
A geometry is the spatial representation of a feature.
Stores queued vector layer edit operations prior to committing changes to the layer's data provider.
void attributeRenamed(int idx, const QString &newName)
Emitted when an attribute has been renamed.
QgsFeatureMap mAddedFeatures
New features which are not committed.
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.
QgsFieldNameMap mRenamedAttributes
Renamed attributes which are not committed.
QgsGeometryMap mChangedGeometries
Changed geometries which are not committed.
QgsAttributeList mDeletedAttributeIds
Deleted attributes fields which are not committed. The list is kept sorted.
QgsFeatureIds mDeletedFeatureIds
Deleted feature IDs which are not committed.
void featureDeleted(QgsFeatureId fid)
Emitted when a feature was deleted from the buffer.
void attributeAdded(int idx)
Emitted when an attribute was added to the buffer.
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &value)
Emitted when a feature's attribute value has been changed.
void attributeDeleted(int idx)
Emitted when an attribute was deleted from the buffer.
void featureAdded(QgsFeatureId fid)
Emitted when a feature has been added to the buffer.
QgsChangedAttributesMap mChangedAttributeValues
Changed attributes values which are not committed.
void handleAttributeAdded(int index)
Update added and changed features after addition of an attribute.
QList< QgsField > mAddedAttributes
Added attributes fields which are not committed.
QgsVectorLayerUndoCommandAddAttribute(QgsVectorLayerEditBuffer *buffer, const QgsField &field)
Constructor for QgsVectorLayerUndoCommandAddAttribute.
QgsVectorLayerUndoCommandAddFeature(QgsVectorLayerEditBuffer *buffer, QgsFeature &f)
Constructor for QgsVectorLayerUndoCommandAddFeature.
QgsVectorLayerUndoCommandChangeAttribute(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, int fieldIndex, const QVariant &newValue, const QVariant &oldValue)
Constructor for QgsVectorLayerUndoCommandChangeAttribute.
Undo command for modifying the geometry of a feature from a vector layer.
QgsVectorLayerUndoCommandChangeGeometry(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, const QgsGeometry &newGeom)
Constructor for QgsVectorLayerUndoCommandChangeGeometry.
bool mergeWith(const QUndoCommand *other) override
QgsVectorLayerUndoCommandDeleteAttribute(QgsVectorLayerEditBuffer *buffer, int fieldIndex)
Constructor for QgsVectorLayerUndoCommandDeleteAttribute.
QgsVectorLayerUndoCommandDeleteFeature(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid)
Constructor for QgsVectorLayerUndoCommandDeleteFeature.
QgsVectorLayerUndoCommandRenameAttribute(QgsVectorLayerEditBuffer *buffer, int fieldIndex, const QString &newName)
Constructor for QgsVectorLayerUndoCommandRenameAttribute.
Base class for undo commands within a QgsVectorLayerEditBuffer.
QgsVectorLayer * layer()
Returns the layer associated with the undo command.
QgsVectorLayerEditBuffer * mBuffer
Associated edit buffer.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
void setEditFormConfig(const QgsEditFormConfig &editFormConfig)
Sets the editFormConfig (configuration) of the form used to represent this vector layer.
QgsEditFormConfig editFormConfig
QMap< int, QVariant > QgsAttributeMap
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QList< int > QgsAttributeList
#define QgsDebugMsgLevel(str, level)