QGIS API Documentation  3.4.15-Madeira (e83d02e274)
Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Friends | List of all members
QgsVectorLayerEditBuffer Class Reference

#include <qgsvectorlayereditbuffer.h>

Inheritance diagram for QgsVectorLayerEditBuffer:
Inheritance graph
[legend]

Signals

void attributeAdded (int idx)
 
void attributeDeleted (int idx)
 
void attributeRenamed (int idx, const QString &newName)
 Emitted when an attribute has been renamed. More...
 
void attributeValueChanged (QgsFeatureId fid, int idx, const QVariant &)
 
void committedAttributesAdded (const QString &layerId, const QList< QgsField > &addedAttributes)
 
void committedAttributesDeleted (const QString &layerId, const QgsAttributeList &deletedAttributes)
 Signals emitted after committing changes. More...
 
void committedAttributesRenamed (const QString &layerId, const QgsFieldNameMap &renamedAttributes)
 Emitted after committing an attribute rename. More...
 
void committedAttributeValuesChanges (const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
 
void committedFeaturesAdded (const QString &layerId, const QgsFeatureList &addedFeatures)
 
void committedFeaturesRemoved (const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
 
void committedGeometriesChanges (const QString &layerId, const QgsGeometryMap &changedGeometries)
 
void featureAdded (QgsFeatureId fid)
 
void featureDeleted (QgsFeatureId fid)
 
void geometryChanged (QgsFeatureId fid, const QgsGeometry &geom)
 Emitted when a feature's geometry is changed. More...
 
void layerModified ()
 This signal is emitted when modifications has been done on layer. More...
 

Public Member Functions

 QgsVectorLayerEditBuffer (QgsVectorLayer *layer)
 
virtual bool addAttribute (const QgsField &field)
 Add an attribute field (but does not commit it) returns true if the field was added. More...
 
QList< QgsFieldaddedAttributes () const
 Returns a list of added attributes fields which are not committed. More...
 
QgsFeatureMap addedFeatures () const
 Returns a map of new features which are not committed. More...
 
virtual bool addFeature (QgsFeature &f)
 Adds a feature. More...
 
virtual bool addFeatures (QgsFeatureList &features)
 Insert a copy of the given features into the layer (but does not commit it) More...
 
virtual bool changeAttributeValue (QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
 Changed an attribute value (but does not commit it) More...
 
virtual bool changeAttributeValues (QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues)
 Changes values of attributes (but does not commit it). More...
 
QgsChangedAttributesMap changedAttributeValues () const
 Returns a map of features with changed attributes values which are not committed. More...
 
QgsGeometryMap changedGeometries () const
 Returns a map of features with changed geometries which are not committed. More...
 
virtual bool changeGeometry (QgsFeatureId fid, const QgsGeometry &geom)
 Change feature's geometry. More...
 
virtual bool commitChanges (QStringList &commitErrors)
 Attempts to commit any changes to disk. More...
 
virtual bool deleteAttribute (int attr)
 Delete an attribute field (but does not commit it) More...
 
QgsAttributeList deletedAttributeIds () const
 Returns a list of deleted attributes fields which are not committed. More...
 
QgsFeatureIds deletedFeatureIds () const
 Returns a list of deleted feature IDs which are not committed. More...
 
virtual bool deleteFeature (QgsFeatureId fid)
 Delete a feature from the layer (but does not commit it) More...
 
virtual bool deleteFeatures (const QgsFeatureIds &fid)
 Deletes a set of features from the layer (but does not commit it) More...
 
bool isAttributeDeleted (int index) const
 Returns true if the specified attribute has been deleted but not committed. More...
 
bool isFeatureAdded (QgsFeatureId id) const
 Returns true if the specified feature ID has been added but not committed. More...
 
bool isFeatureAttributesChanged (QgsFeatureId id) const
 Returns true if the specified feature ID has had an attribute changed but not committed. More...
 
bool isFeatureDeleted (QgsFeatureId id) const
 Returns true if the specified feature ID has been deleted but not committed. More...
 
bool isFeatureGeometryChanged (QgsFeatureId id) const
 Returns true if the specified feature ID has had its geometry changed but not committed. More...
 
virtual bool isModified () const
 Returns true if the provider has been modified since the last commit. More...
 
virtual bool renameAttribute (int attr, const QString &newName)
 Renames an attribute field (but does not commit it) More...
 
virtual void rollBack ()
 Stop editing and discard the edits. More...
 

Protected Slots

void undoIndexChanged (int index)
 

Protected Member Functions

 QgsVectorLayerEditBuffer ()=default
 Constructor for QgsVectorLayerEditBuffer. More...
 
void handleAttributeAdded (int index)
 Update added and changed features after addition of an attribute. More...
 
void handleAttributeDeleted (int index)
 Update added and changed features after removal of an attribute. More...
 
void updateAttributeMapIndex (QgsAttributeMap &attrs, int index, int offset) const
 Updates an index in an attribute map to a new value (for updates of changed attributes) More...
 
void updateChangedAttributes (QgsFeature &f)
 Update feature with uncommitted attribute updates. More...
 
void updateFeatureGeometry (QgsFeature &f)
 Update feature with uncommitted geometry updates. More...
 
void updateFields (QgsFields &fields)
 
void updateLayerFields ()
 

Protected Attributes

QgsVectorLayerL = nullptr
 
QList< QgsFieldmAddedAttributes
 Added attributes fields which are not committed. More...
 
QgsFeatureMap mAddedFeatures
 New features which are not committed. More...
 
QgsChangedAttributesMap mChangedAttributeValues
 Changed attributes values which are not committed. More...
 
QgsGeometryMap mChangedGeometries
 Changed geometries which are not committed. More...
 
QgsAttributeList mDeletedAttributeIds
 Deleted attributes fields which are not committed. The list is kept sorted. More...
 
QgsFeatureIds mDeletedFeatureIds
 Deleted feature IDs which are not committed. More...
 
QgsFieldNameMap mRenamedAttributes
 Renamed attributes which are not committed. More...
 

Friends

class QgsGrassProvider
 
class QgsVectorLayer
 
class QgsVectorLayerUndoCommand
 
class QgsVectorLayerUndoCommandAddAttribute
 
class QgsVectorLayerUndoCommandAddFeature
 
class QgsVectorLayerUndoCommandChangeAttribute
 
class QgsVectorLayerUndoCommandChangeGeometry
 
class QgsVectorLayerUndoCommandDeleteAttribute
 
class QgsVectorLayerUndoCommandDeleteFeature
 
class QgsVectorLayerUndoCommandRenameAttribute
 
class QgsVectorLayerUndoPassthroughCommand
 
class QgsVectorLayerUndoPassthroughCommandAddAttribute
 
class QgsVectorLayerUndoPassthroughCommandAddFeatures
 
class QgsVectorLayerUndoPassthroughCommandChangeAttribute
 
class QgsVectorLayerUndoPassthroughCommandChangeAttributes
 
class QgsVectorLayerUndoPassthroughCommandChangeGeometry
 
class QgsVectorLayerUndoPassthroughCommandDeleteAttribute
 
class QgsVectorLayerUndoPassthroughCommandDeleteFeatures
 
class QgsVectorLayerUndoPassthroughCommandRenameAttribute
 
class QgsVectorLayerUndoPassthroughCommandUpdate
 

Detailed Description

Definition at line 36 of file qgsvectorlayereditbuffer.h.

Constructor & Destructor Documentation

QgsVectorLayerEditBuffer::QgsVectorLayerEditBuffer ( QgsVectorLayer layer)

Definition at line 38 of file qgsvectorlayereditbuffer.cpp.

QgsVectorLayerEditBuffer::QgsVectorLayerEditBuffer ( )
protecteddefault

Constructor for QgsVectorLayerEditBuffer.

Member Function Documentation

bool QgsVectorLayerEditBuffer::addAttribute ( const QgsField field)
virtual

Add an attribute field (but does not commit it) returns true if the field was added.

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 254 of file qgsvectorlayereditbuffer.cpp.

QList<QgsField> QgsVectorLayerEditBuffer::addedAttributes ( ) const
inline

Returns a list of added attributes fields which are not committed.

Definition at line 156 of file qgsvectorlayereditbuffer.h.

QgsFeatureMap QgsVectorLayerEditBuffer::addedFeatures ( ) const
inline

Returns a map of new features which are not committed.

See also
isFeatureAdded()

Definition at line 115 of file qgsvectorlayereditbuffer.h.

bool QgsVectorLayerEditBuffer::addFeature ( QgsFeature f)
virtual

Adds a feature.

Parameters
ffeature to add
Returns
True in case of success and False in case of error

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 115 of file qgsvectorlayereditbuffer.cpp.

bool QgsVectorLayerEditBuffer::addFeatures ( QgsFeatureList features)
virtual

Insert a copy of the given features into the layer (but does not commit it)

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 131 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::attributeAdded ( int  idx)
signal
void QgsVectorLayerEditBuffer::attributeDeleted ( int  idx)
signal
void QgsVectorLayerEditBuffer::attributeRenamed ( int  idx,
const QString &  newName 
)
signal

Emitted when an attribute has been renamed.

Parameters
idxattribute index
newNamenew attribute name
Since
QGIS 2.16
void QgsVectorLayerEditBuffer::attributeValueChanged ( QgsFeatureId  fid,
int  idx,
const QVariant &   
)
signal
bool QgsVectorLayerEditBuffer::changeAttributeValue ( QgsFeatureId  fid,
int  field,
const QVariant &  newValue,
const QVariant &  oldValue = QVariant() 
)
virtual

Changed an attribute value (but does not commit it)

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 232 of file qgsvectorlayereditbuffer.cpp.

bool QgsVectorLayerEditBuffer::changeAttributeValues ( QgsFeatureId  fid,
const QgsAttributeMap newValues,
const QgsAttributeMap oldValues 
)
virtual

Changes values of attributes (but does not commit it).

Returns
true if attributes are well updated, false otherwise
Since
QGIS 3.0

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 214 of file qgsvectorlayereditbuffer.cpp.

QgsChangedAttributesMap QgsVectorLayerEditBuffer::changedAttributeValues ( ) const
inline

Returns a map of features with changed attributes values which are not committed.

See also
isFeatureAttributesChanged()

Definition at line 129 of file qgsvectorlayereditbuffer.h.

QgsGeometryMap QgsVectorLayerEditBuffer::changedGeometries ( ) const
inline

Returns a map of features with changed geometries which are not committed.

See also
isFeatureGeometryChanged()

Definition at line 162 of file qgsvectorlayereditbuffer.h.

bool QgsVectorLayerEditBuffer::changeGeometry ( QgsFeatureId  fid,
const QgsGeometry geom 
)
virtual

Change feature's geometry.

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 193 of file qgsvectorlayereditbuffer.cpp.

bool QgsVectorLayerEditBuffer::commitChanges ( QStringList &  commitErrors)
virtual

Attempts to commit any changes to disk.

Returns the result of the attempt. If a commit fails, the in-memory changes are left alone.

This allows editing to continue if the commit failed on e.g. a disallowed value in a Postgres database - the user can re-edit and try again.

The commits occur in distinct stages, (add attributes, add features, change attribute values, change geometries, delete features, delete attributes) so if a stage fails, it's difficult to roll back cleanly. Therefore any error message also includes which stage failed so that the user has some chance of repairing the damage cleanly.

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 322 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::committedAttributesAdded ( const QString &  layerId,
const QList< QgsField > &  addedAttributes 
)
signal
void QgsVectorLayerEditBuffer::committedAttributesDeleted ( const QString &  layerId,
const QgsAttributeList deletedAttributes 
)
signal

Signals emitted after committing changes.

void QgsVectorLayerEditBuffer::committedAttributesRenamed ( const QString &  layerId,
const QgsFieldNameMap renamedAttributes 
)
signal

Emitted after committing an attribute rename.

Parameters
layerIdID of layer
renamedAttributesmap of field index to new name
Since
QGIS 2.16
void QgsVectorLayerEditBuffer::committedAttributeValuesChanges ( const QString &  layerId,
const QgsChangedAttributesMap changedAttributesValues 
)
signal
void QgsVectorLayerEditBuffer::committedFeaturesAdded ( const QString &  layerId,
const QgsFeatureList addedFeatures 
)
signal
void QgsVectorLayerEditBuffer::committedFeaturesRemoved ( const QString &  layerId,
const QgsFeatureIds deletedFeatureIds 
)
signal
void QgsVectorLayerEditBuffer::committedGeometriesChanges ( const QString &  layerId,
const QgsGeometryMap changedGeometries 
)
signal
bool QgsVectorLayerEditBuffer::deleteAttribute ( int  attr)
virtual

Delete an attribute field (but does not commit it)

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 277 of file qgsvectorlayereditbuffer.cpp.

QgsAttributeList QgsVectorLayerEditBuffer::deletedAttributeIds ( ) const
inline

Returns a list of deleted attributes fields which are not committed.

The list is kept sorted.

See also
isAttributeDeleted()

Definition at line 143 of file qgsvectorlayereditbuffer.h.

QgsFeatureIds QgsVectorLayerEditBuffer::deletedFeatureIds ( ) const
inline

Returns a list of deleted feature IDs which are not committed.

See also
isFeatureDeleted()

Definition at line 176 of file qgsvectorlayereditbuffer.h.

bool QgsVectorLayerEditBuffer::deleteFeature ( QgsFeatureId  fid)
virtual

Delete a feature from the layer (but does not commit it)

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 148 of file qgsvectorlayereditbuffer.cpp.

bool QgsVectorLayerEditBuffer::deleteFeatures ( const QgsFeatureIds fid)
virtual

Deletes a set of features from the layer (but does not commit it)

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 177 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::featureAdded ( QgsFeatureId  fid)
signal
void QgsVectorLayerEditBuffer::featureDeleted ( QgsFeatureId  fid)
signal
void QgsVectorLayerEditBuffer::geometryChanged ( QgsFeatureId  fid,
const QgsGeometry geom 
)
signal

Emitted when a feature's geometry is changed.

Parameters
fidfeature ID
geomnew feature geometry
void QgsVectorLayerEditBuffer::handleAttributeAdded ( int  index)
protected

Update added and changed features after addition of an attribute.

Definition at line 721 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::handleAttributeDeleted ( int  index)
protected

Update added and changed features after removal of an attribute.

Definition at line 754 of file qgsvectorlayereditbuffer.cpp.

bool QgsVectorLayerEditBuffer::isAttributeDeleted ( int  index) const
inline

Returns true if the specified attribute has been deleted but not committed.

Parameters
indexattribute index
See also
deletedAttributeIds()
Since
QGIS 3.0

Definition at line 151 of file qgsvectorlayereditbuffer.h.

bool QgsVectorLayerEditBuffer::isFeatureAdded ( QgsFeatureId  id) const
inline

Returns true if the specified feature ID has been added but not committed.

Parameters
idfeature ID
See also
addedFeatures()
Since
QGIS 3.0

Definition at line 123 of file qgsvectorlayereditbuffer.h.

bool QgsVectorLayerEditBuffer::isFeatureAttributesChanged ( QgsFeatureId  id) const
inline

Returns true if the specified feature ID has had an attribute changed but not committed.

Parameters
idfeature ID
See also
changedAttributeValues()
Since
QGIS 3.0

Definition at line 137 of file qgsvectorlayereditbuffer.h.

bool QgsVectorLayerEditBuffer::isFeatureDeleted ( QgsFeatureId  id) const
inline

Returns true if the specified feature ID has been deleted but not committed.

Parameters
idfeature ID
See also
deletedFeatureIds()
Since
QGIS 3.0

Definition at line 184 of file qgsvectorlayereditbuffer.h.

bool QgsVectorLayerEditBuffer::isFeatureGeometryChanged ( QgsFeatureId  id) const
inline

Returns true if the specified feature ID has had its geometry changed but not committed.

Parameters
idfeature ID
See also
changedGeometries()
Since
QGIS 3.0

Definition at line 170 of file qgsvectorlayereditbuffer.h.

bool QgsVectorLayerEditBuffer::isModified ( ) const
virtual

Returns true if the provider has been modified since the last commit.

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 44 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::layerModified ( )
signal

This signal is emitted when modifications has been done on layer.

bool QgsVectorLayerEditBuffer::renameAttribute ( int  attr,
const QString &  newName 
)
virtual

Renames an attribute field (but does not commit it)

Parameters
attrattribute index
newNamenew name of field
Since
QGIS 2.16

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 299 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::rollBack ( )
virtual

Stop editing and discard the edits.

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 688 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::undoIndexChanged ( int  index)
protectedslot

Definition at line 50 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::updateAttributeMapIndex ( QgsAttributeMap attrs,
int  index,
int  offset 
) const
protected

Updates an index in an attribute map to a new value (for updates of changed attributes)

Definition at line 799 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::updateChangedAttributes ( QgsFeature f)
protected

Update feature with uncommitted attribute updates.

Definition at line 88 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::updateFeatureGeometry ( QgsFeature f)
protected

Update feature with uncommitted geometry updates.

Definition at line 81 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::updateFields ( QgsFields fields)
protected

Definition at line 58 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::updateLayerFields ( )
protected

Definition at line 812 of file qgsvectorlayereditbuffer.cpp.

Friends And Related Function Documentation

friend class QgsGrassProvider
friend

Definition at line 306 of file qgsvectorlayereditbuffer.h.

friend class QgsVectorLayer
friend

Definition at line 259 of file qgsvectorlayereditbuffer.h.

friend class QgsVectorLayerUndoCommand
friend

Definition at line 261 of file qgsvectorlayereditbuffer.h.

Definition at line 266 of file qgsvectorlayereditbuffer.h.

Definition at line 262 of file qgsvectorlayereditbuffer.h.

Definition at line 265 of file qgsvectorlayereditbuffer.h.

Definition at line 264 of file qgsvectorlayereditbuffer.h.

Definition at line 267 of file qgsvectorlayereditbuffer.h.

Definition at line 263 of file qgsvectorlayereditbuffer.h.

Definition at line 268 of file qgsvectorlayereditbuffer.h.

Definition at line 270 of file qgsvectorlayereditbuffer.h.

Definition at line 276 of file qgsvectorlayereditbuffer.h.

Definition at line 271 of file qgsvectorlayereditbuffer.h.

Definition at line 274 of file qgsvectorlayereditbuffer.h.

Definition at line 275 of file qgsvectorlayereditbuffer.h.

Definition at line 273 of file qgsvectorlayereditbuffer.h.

Definition at line 277 of file qgsvectorlayereditbuffer.h.

Definition at line 272 of file qgsvectorlayereditbuffer.h.

Definition at line 278 of file qgsvectorlayereditbuffer.h.

Definition at line 279 of file qgsvectorlayereditbuffer.h.

Member Data Documentation

QgsVectorLayer* QgsVectorLayerEditBuffer::L = nullptr
protected

Definition at line 258 of file qgsvectorlayereditbuffer.h.

QList<QgsField> QgsVectorLayerEditBuffer::mAddedAttributes
protected

Added attributes fields which are not committed.

Definition at line 298 of file qgsvectorlayereditbuffer.h.

QgsFeatureMap QgsVectorLayerEditBuffer::mAddedFeatures
protected

New features which are not committed.

Definition at line 289 of file qgsvectorlayereditbuffer.h.

QgsChangedAttributesMap QgsVectorLayerEditBuffer::mChangedAttributeValues
protected

Changed attributes values which are not committed.

Definition at line 292 of file qgsvectorlayereditbuffer.h.

QgsGeometryMap QgsVectorLayerEditBuffer::mChangedGeometries
protected

Changed geometries which are not committed.

Definition at line 304 of file qgsvectorlayereditbuffer.h.

QgsAttributeList QgsVectorLayerEditBuffer::mDeletedAttributeIds
protected

Deleted attributes fields which are not committed. The list is kept sorted.

Definition at line 295 of file qgsvectorlayereditbuffer.h.

QgsFeatureIds QgsVectorLayerEditBuffer::mDeletedFeatureIds
protected

Deleted feature IDs which are not committed.

Note a feature can be added and then deleted again before the change is committed - in that case the added feature would be removed from mAddedFeatures only and not entered here.

Definition at line 286 of file qgsvectorlayereditbuffer.h.

QgsFieldNameMap QgsVectorLayerEditBuffer::mRenamedAttributes
protected

Renamed attributes which are not committed.

Definition at line 301 of file qgsvectorlayereditbuffer.h.


The documentation for this class was generated from the following files: