QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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, QgsGeometry &geom)
 
void layerModified ()
 This signal is emitted when modifications has been done on layer. More...
 

Public Member Functions

 QgsVectorLayerEditBuffer (QgsVectorLayer *layer)
 
 ~QgsVectorLayerEditBuffer ()
 
virtual bool addAttribute (const QgsField &field)
 Add an attribute field (but does not commit it) returns true if the field was added. More...
 
const QList< QgsField > & addedAttributes ()
 Added attributes fields which are not commited. More...
 
const QgsFeatureMapaddedFeatures ()
 New features which are not commited. 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...
 
const QgsChangedAttributesMapchangedAttributeValues ()
 Changed attributes values which are not commited. More...
 
const QgsGeometryMapchangedGeometries ()
 Changed geometries which are not commited. More...
 
virtual bool changeGeometry (QgsFeatureId fid, 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...
 
const QgsAttributeListdeletedAttributeIds ()
 Deleted attributes fields which are not commited. More...
 
const QgsFeatureIds deletedFeatureIds ()
 
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...
 
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...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual ~QObject ()
 
bool blockSignals (bool block)
 
QObjectchild (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObjectparent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThreadthread () const
 

Protected Slots

void undoIndexChanged (int index)
 

Protected Member Functions

 QgsVectorLayerEditBuffer ()
 
bool adaptGeometry (QgsGeometry *geometry)
 Apply geometry modification basing on provider geometry type. 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 uncommited attribute updates. More...
 
void updateFeatureGeometry (QgsFeature &f)
 Update feature with uncommited geometry updates. More...
 
void updateFields (QgsFields &fields)
 
void updateLayerFields ()
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObjectsender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Protected Attributes

QgsVectorLayerL
 
QList< QgsFieldmAddedAttributes
 Added attributes fields which are not commited. More...
 
QgsFeatureMap mAddedFeatures
 New features which are not commited. More...
 
QgsChangedAttributesMap mChangedAttributeValues
 Changed attributes values which are not commited. More...
 
QgsGeometryMap mChangedGeometries
 Changed geometries which are not commited. More...
 
QgsAttributeList mDeletedAttributeIds
 Deleted attributes fields which are not commited. More...
 
QgsFeatureIds mDeletedFeatureIds
 Deleted feature IDs which are not commited. More...
 
QgsFieldNameMap mRenamedAttributes
 Renamed attributes which are not commited. More...
 

Friends

class QgsVectorLayer
 
class QgsVectorLayerUndoCommand
 
class QgsVectorLayerUndoCommandAddAttribute
 
class QgsVectorLayerUndoCommandAddFeature
 
class QgsVectorLayerUndoCommandChangeAttribute
 
class QgsVectorLayerUndoCommandChangeGeometry
 
class QgsVectorLayerUndoCommandDeleteAttribute
 
class QgsVectorLayerUndoCommandDeleteFeature
 
class QgsVectorLayerUndoCommandRenameAttribute
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Definition at line 36 of file qgsvectorlayereditbuffer.h.

Constructor & Destructor Documentation

◆ QgsVectorLayerEditBuffer() [1/2]

QgsVectorLayerEditBuffer::QgsVectorLayerEditBuffer ( QgsVectorLayer layer)

Definition at line 39 of file qgsvectorlayereditbuffer.cpp.

◆ ~QgsVectorLayerEditBuffer()

QgsVectorLayerEditBuffer::~QgsVectorLayerEditBuffer ( )

Definition at line 45 of file qgsvectorlayereditbuffer.cpp.

◆ QgsVectorLayerEditBuffer() [2/2]

QgsVectorLayerEditBuffer::QgsVectorLayerEditBuffer ( )
inlineprotected

Definition at line 165 of file qgsvectorlayereditbuffer.h.

Member Function Documentation

◆ adaptGeometry()

bool QgsVectorLayerEditBuffer::adaptGeometry ( QgsGeometry geometry)
protected

Apply geometry modification basing on provider geometry type.

Geometry is modified only if successful conversion is possible. adaptGeometry calls QgsVectorDataProvider::convertToProviderType() if necessary and that apply the modifications.

Parameters
geometrypointer to the geometry that should be adapted to provider
Returns
bool true if success. True: Input geometry is changed because conversion is applied or geometry is untouched if geometry conversion is not necessary. False: Conversion is not possible and geometry is untouched.
Note
added in QGIS 2.18.14

Definition at line 183 of file qgsvectorlayereditbuffer.cpp.

◆ addAttribute()

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 258 of file qgsvectorlayereditbuffer.cpp.

◆ addedAttributes()

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

Added attributes fields which are not commited.

Definition at line 119 of file qgsvectorlayereditbuffer.h.

◆ addedFeatures()

const QgsFeatureMap& QgsVectorLayerEditBuffer::addedFeatures ( )
inline

New features which are not commited.

Definition at line 110 of file qgsvectorlayereditbuffer.h.

◆ addFeature()

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 116 of file qgsvectorlayereditbuffer.cpp.

◆ addFeatures()

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 135 of file qgsvectorlayereditbuffer.cpp.

◆ attributeAdded

void QgsVectorLayerEditBuffer::attributeAdded ( int  idx)
signal

◆ attributeDeleted

void QgsVectorLayerEditBuffer::attributeDeleted ( int  idx)
signal

◆ attributeRenamed

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

Emitted when an attribute has been renamed.

Parameters
idxattribute index
newNamenew attribute name
Note
added in QGSI 2.16

◆ attributeValueChanged

void QgsVectorLayerEditBuffer::attributeValueChanged ( QgsFeatureId  fid,
int  idx,
const QVariant  
)
signal

◆ changeAttributeValue()

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 236 of file qgsvectorlayereditbuffer.cpp.

◆ changeAttributeValues()

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
Note
added in QGIS 2.18

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 780 of file qgsvectorlayereditbuffer.cpp.

◆ changedAttributeValues()

const QgsChangedAttributesMap& QgsVectorLayerEditBuffer::changedAttributeValues ( )
inline

Changed attributes values which are not commited.

Definition at line 113 of file qgsvectorlayereditbuffer.h.

◆ changedGeometries()

const QgsGeometryMap& QgsVectorLayerEditBuffer::changedGeometries ( )
inline

Changed geometries which are not commited.

Definition at line 122 of file qgsvectorlayereditbuffer.h.

◆ changeGeometry()

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

Change feature's geometry.

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 210 of file qgsvectorlayereditbuffer.cpp.

◆ commitChanges()

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 324 of file qgsvectorlayereditbuffer.cpp.

◆ committedAttributesAdded

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

◆ committedAttributesDeleted

void QgsVectorLayerEditBuffer::committedAttributesDeleted ( const QString layerId,
const QgsAttributeList deletedAttributes 
)
signal

Signals emitted after committing changes.

◆ committedAttributesRenamed

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
Note
added in QGIS 2.16

◆ committedAttributeValuesChanges

void QgsVectorLayerEditBuffer::committedAttributeValuesChanges ( const QString layerId,
const QgsChangedAttributesMap changedAttributesValues 
)
signal

◆ committedFeaturesAdded

void QgsVectorLayerEditBuffer::committedFeaturesAdded ( const QString layerId,
const QgsFeatureList addedFeatures 
)
signal

◆ committedFeaturesRemoved

void QgsVectorLayerEditBuffer::committedFeaturesRemoved ( const QString layerId,
const QgsFeatureIds deletedFeatureIds 
)
signal

◆ committedGeometriesChanges

void QgsVectorLayerEditBuffer::committedGeometriesChanges ( const QString layerId,
const QgsGeometryMap changedGeometries 
)
signal

◆ deleteAttribute()

bool QgsVectorLayerEditBuffer::deleteAttribute ( int  attr)
virtual

Delete an attribute field (but does not commit it)

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 280 of file qgsvectorlayereditbuffer.cpp.

◆ deletedAttributeIds()

const QgsAttributeList& QgsVectorLayerEditBuffer::deletedAttributeIds ( )
inline

Deleted attributes fields which are not commited.

The list is kept sorted.

Definition at line 116 of file qgsvectorlayereditbuffer.h.

◆ deletedFeatureIds()

const QgsFeatureIds QgsVectorLayerEditBuffer::deletedFeatureIds ( )
inline

Definition at line 124 of file qgsvectorlayereditbuffer.h.

◆ deleteFeature()

bool QgsVectorLayerEditBuffer::deleteFeature ( QgsFeatureId  fid)
virtual

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

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 152 of file qgsvectorlayereditbuffer.cpp.

◆ deleteFeatures()

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 172 of file qgsvectorlayereditbuffer.cpp.

◆ featureAdded

void QgsVectorLayerEditBuffer::featureAdded ( QgsFeatureId  fid)
signal

◆ featureDeleted

void QgsVectorLayerEditBuffer::featureDeleted ( QgsFeatureId  fid)
signal

◆ geometryChanged

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

◆ handleAttributeAdded()

void QgsVectorLayerEditBuffer::handleAttributeAdded ( int  index)
protected

Update added and changed features after addition of an attribute.

Definition at line 684 of file qgsvectorlayereditbuffer.cpp.

◆ handleAttributeDeleted()

void QgsVectorLayerEditBuffer::handleAttributeDeleted ( int  index)
protected

Update added and changed features after removal of an attribute.

Definition at line 717 of file qgsvectorlayereditbuffer.cpp.

◆ isModified()

bool QgsVectorLayerEditBuffer::isModified ( ) const
virtual

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

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 50 of file qgsvectorlayereditbuffer.cpp.

◆ layerModified

void QgsVectorLayerEditBuffer::layerModified ( )
signal

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

◆ renameAttribute()

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
Note
added in QGIS 2.16

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 302 of file qgsvectorlayereditbuffer.cpp.

◆ rollBack()

void QgsVectorLayerEditBuffer::rollBack ( )
virtual

Stop editing and discard the edits.

Reimplemented in QgsVectorLayerEditPassthrough.

Definition at line 651 of file qgsvectorlayereditbuffer.cpp.

◆ undoIndexChanged

void QgsVectorLayerEditBuffer::undoIndexChanged ( int  index)
protectedslot

Definition at line 56 of file qgsvectorlayereditbuffer.cpp.

◆ updateAttributeMapIndex()

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 762 of file qgsvectorlayereditbuffer.cpp.

◆ updateChangedAttributes()

void QgsVectorLayerEditBuffer::updateChangedAttributes ( QgsFeature f)
protected

Update feature with uncommited attribute updates.

Definition at line 92 of file qgsvectorlayereditbuffer.cpp.

◆ updateFeatureGeometry()

void QgsVectorLayerEditBuffer::updateFeatureGeometry ( QgsFeature f)
protected

Update feature with uncommited geometry updates.

Definition at line 85 of file qgsvectorlayereditbuffer.cpp.

◆ updateFields()

void QgsVectorLayerEditBuffer::updateFields ( QgsFields fields)
protected

Definition at line 64 of file qgsvectorlayereditbuffer.cpp.

◆ updateLayerFields()

void QgsVectorLayerEditBuffer::updateLayerFields ( )
protected

Definition at line 775 of file qgsvectorlayereditbuffer.cpp.

Friends And Related Function Documentation

◆ QgsVectorLayer

friend class QgsVectorLayer
friend

Definition at line 201 of file qgsvectorlayereditbuffer.h.

◆ QgsVectorLayerUndoCommand

friend class QgsVectorLayerUndoCommand
friend

Definition at line 203 of file qgsvectorlayereditbuffer.h.

◆ QgsVectorLayerUndoCommandAddAttribute

Definition at line 208 of file qgsvectorlayereditbuffer.h.

◆ QgsVectorLayerUndoCommandAddFeature

Definition at line 204 of file qgsvectorlayereditbuffer.h.

◆ QgsVectorLayerUndoCommandChangeAttribute

Definition at line 207 of file qgsvectorlayereditbuffer.h.

◆ QgsVectorLayerUndoCommandChangeGeometry

Definition at line 206 of file qgsvectorlayereditbuffer.h.

◆ QgsVectorLayerUndoCommandDeleteAttribute

Definition at line 209 of file qgsvectorlayereditbuffer.h.

◆ QgsVectorLayerUndoCommandDeleteFeature

Definition at line 205 of file qgsvectorlayereditbuffer.h.

◆ QgsVectorLayerUndoCommandRenameAttribute

Definition at line 210 of file qgsvectorlayereditbuffer.h.

Member Data Documentation

◆ L

QgsVectorLayer* QgsVectorLayerEditBuffer::L
protected

Definition at line 200 of file qgsvectorlayereditbuffer.h.

◆ mAddedAttributes

QList<QgsField> QgsVectorLayerEditBuffer::mAddedAttributes
protected

Added attributes fields which are not commited.

Definition at line 228 of file qgsvectorlayereditbuffer.h.

◆ mAddedFeatures

QgsFeatureMap QgsVectorLayerEditBuffer::mAddedFeatures
protected

New features which are not commited.

Definition at line 219 of file qgsvectorlayereditbuffer.h.

◆ mChangedAttributeValues

QgsChangedAttributesMap QgsVectorLayerEditBuffer::mChangedAttributeValues
protected

Changed attributes values which are not commited.

Definition at line 222 of file qgsvectorlayereditbuffer.h.

◆ mChangedGeometries

QgsGeometryMap QgsVectorLayerEditBuffer::mChangedGeometries
protected

Changed geometries which are not commited.

Definition at line 234 of file qgsvectorlayereditbuffer.h.

◆ mDeletedAttributeIds

QgsAttributeList QgsVectorLayerEditBuffer::mDeletedAttributeIds
protected

Deleted attributes fields which are not commited.

The list is kept sorted.

Definition at line 225 of file qgsvectorlayereditbuffer.h.

◆ mDeletedFeatureIds

QgsFeatureIds QgsVectorLayerEditBuffer::mDeletedFeatureIds
protected

Deleted feature IDs which are not commited.

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 216 of file qgsvectorlayereditbuffer.h.

◆ mRenamedAttributes

QgsFieldNameMap QgsVectorLayerEditBuffer::mRenamedAttributes
protected

Renamed attributes which are not commited.

Definition at line 231 of file qgsvectorlayereditbuffer.h.


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