QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 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 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 ()
 
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...
 
bool addFeature (QgsFeature &f)
 Adds a feature. More...
 
bool addFeatures (QgsFeatureList &features)
 Insert a copy of the given features into the layer (but does not commit it) More...
 
bool changeAttributeValue (QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
 changed an attribute value (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...
 
bool changeGeometry (QgsFeatureId fid, QgsGeometry *geom)
 change feature's geometry More...
 
bool commitChanges (QStringList &commitErrors)
 Attempts to commit any changes to disk. More...
 
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 ()
 
bool deleteFeature (QgsFeatureId fid)
 delete a feature from the layer (but does not commit it) More...
 
bool isModified () const
 Returns true if the provider has been modified since the last commit. More...
 
void rollBack ()
 Stop editing and discard the edits. More...
 

Protected Slots

void undoIndexChanged (int index)
 

Protected Member Functions

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 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...
 

Friends

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

Detailed Description

Definition at line 33 of file qgsvectorlayereditbuffer.h.

Constructor & Destructor Documentation

QgsVectorLayerEditBuffer::QgsVectorLayerEditBuffer ( QgsVectorLayer layer)

Definition at line 24 of file qgsvectorlayereditbuffer.cpp.

QgsVectorLayerEditBuffer::~QgsVectorLayerEditBuffer ( )

Definition at line 30 of file qgsvectorlayereditbuffer.cpp.

Member Function Documentation

bool QgsVectorLayerEditBuffer::addAttribute ( const QgsField field)

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

Definition at line 193 of file qgsvectorlayereditbuffer.cpp.

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

added attributes fields which are not commited

Definition at line 102 of file qgsvectorlayereditbuffer.h.

const QgsFeatureMap& QgsVectorLayerEditBuffer::addedFeatures ( )
inline

New features which are not commited.

Definition at line 93 of file qgsvectorlayereditbuffer.h.

bool QgsVectorLayerEditBuffer::addFeature ( QgsFeature f)

Adds a feature.

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

Definition at line 96 of file qgsvectorlayereditbuffer.cpp.

bool QgsVectorLayerEditBuffer::addFeatures ( QgsFeatureList features)

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

Definition at line 112 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::attributeAdded ( int  idx)
signal
void QgsVectorLayerEditBuffer::attributeDeleted ( int  idx)
signal
void QgsVectorLayerEditBuffer::attributeValueChanged ( QgsFeatureId  fid,
int  idx,
const QVariant &   
)
signal
bool QgsVectorLayerEditBuffer::changeAttributeValue ( QgsFeatureId  fid,
int  field,
const QVariant &  newValue,
const QVariant &  oldValue = QVariant() 
)

changed an attribute value (but does not commit it)

Definition at line 172 of file qgsvectorlayereditbuffer.cpp.

const QgsChangedAttributesMap& QgsVectorLayerEditBuffer::changedAttributeValues ( )
inline

Changed attributes values which are not commited.

Definition at line 96 of file qgsvectorlayereditbuffer.h.

const QgsGeometryMap& QgsVectorLayerEditBuffer::changedGeometries ( )
inline

Changed geometries which are not commited.

Definition at line 105 of file qgsvectorlayereditbuffer.h.

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

change feature's geometry

Definition at line 149 of file qgsvectorlayereditbuffer.cpp.

bool QgsVectorLayerEditBuffer::commitChanges ( QStringList &  commitErrors)

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.

Definition at line 239 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::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)

delete an attribute field (but does not commit it)

Definition at line 216 of file qgsvectorlayereditbuffer.cpp.

const QgsAttributeList& QgsVectorLayerEditBuffer::deletedAttributeIds ( )
inline

deleted attributes fields which are not commited.

The list is kept sorted.

Definition at line 99 of file qgsvectorlayereditbuffer.h.

const QgsFeatureIds QgsVectorLayerEditBuffer::deletedFeatureIds ( )
inline

Definition at line 107 of file qgsvectorlayereditbuffer.h.

bool QgsVectorLayerEditBuffer::deleteFeature ( QgsFeatureId  fid)

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

Definition at line 128 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::featureAdded ( QgsFeatureId  fid)
signal
void QgsVectorLayerEditBuffer::featureDeleted ( QgsFeatureId  fid)
signal
void QgsVectorLayerEditBuffer::geometryChanged ( QgsFeatureId  fid,
QgsGeometry geom 
)
signal
void QgsVectorLayerEditBuffer::handleAttributeAdded ( int  index)
protected

update added and changed features after addition of an attribute

Definition at line 553 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::handleAttributeDeleted ( int  index)
protected

update added and changed features after removal of an attribute

Definition at line 570 of file qgsvectorlayereditbuffer.cpp.

bool QgsVectorLayerEditBuffer::isModified ( ) const

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

Definition at line 35 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::layerModified ( )
signal

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

void QgsVectorLayerEditBuffer::rollBack ( )

Stop editing and discard the edits.

Definition at line 520 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::undoIndexChanged ( int  index)
protectedslot

Definition at line 41 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 595 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::updateChangedAttributes ( QgsFeature f)
protected

Update feature with uncommited attribute updates.

Definition at line 71 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::updateFeatureGeometry ( QgsFeature f)
protected

Update feature with uncommited geometry updates.

Definition at line 64 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::updateFields ( QgsFields fields)
protected

Definition at line 49 of file qgsvectorlayereditbuffer.cpp.

void QgsVectorLayerEditBuffer::updateLayerFields ( )
protected

Definition at line 608 of file qgsvectorlayereditbuffer.cpp.

Friends And Related Function Documentation

friend class QgsVectorLayer
friend

Definition at line 156 of file qgsvectorlayereditbuffer.h.

friend class QgsVectorLayerUndoCommand
friend

Definition at line 158 of file qgsvectorlayereditbuffer.h.

Definition at line 163 of file qgsvectorlayereditbuffer.h.

Definition at line 159 of file qgsvectorlayereditbuffer.h.

Definition at line 162 of file qgsvectorlayereditbuffer.h.

Definition at line 161 of file qgsvectorlayereditbuffer.h.

Definition at line 164 of file qgsvectorlayereditbuffer.h.

Definition at line 160 of file qgsvectorlayereditbuffer.h.

Member Data Documentation

QgsVectorLayer* QgsVectorLayerEditBuffer::L
protected

Definition at line 155 of file qgsvectorlayereditbuffer.h.

QList<QgsField> QgsVectorLayerEditBuffer::mAddedAttributes
protected

added attributes fields which are not commited

Definition at line 182 of file qgsvectorlayereditbuffer.h.

QgsFeatureMap QgsVectorLayerEditBuffer::mAddedFeatures
protected

New features which are not commited.

Definition at line 173 of file qgsvectorlayereditbuffer.h.

QgsChangedAttributesMap QgsVectorLayerEditBuffer::mChangedAttributeValues
protected

Changed attributes values which are not commited.

Definition at line 176 of file qgsvectorlayereditbuffer.h.

QgsGeometryMap QgsVectorLayerEditBuffer::mChangedGeometries
protected

Changed geometries which are not commited.

Definition at line 185 of file qgsvectorlayereditbuffer.h.

QgsAttributeList QgsVectorLayerEditBuffer::mDeletedAttributeIds
protected

deleted attributes fields which are not commited.

The list is kept sorted.

Definition at line 179 of file qgsvectorlayereditbuffer.h.

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


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