QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsvectorlayereditbuffer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayereditbuffer.h
3  ---------------------
4  begin : Dezember 2012
5  copyright : (C) 2012 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSVECTORLAYEREDITBUFFER_H
16 #define QGSVECTORLAYEREDITBUFFER_H
17 
18 #include <QList>
19 #include <QSet>
20 
21 #include "qgsgeometry.h"
22 #include "qgsfeature.h"
23 #include "qgsfield.h"
24 #include "qgsrectangle.h"
25 #include "qgssnapper.h"
26 
28 
32 
33 class CORE_EXPORT QgsVectorLayerEditBuffer : public QObject
34 {
35  Q_OBJECT
36  public:
39 
41  virtual bool isModified() const;
42 
43 
48  virtual bool addFeature( QgsFeature& f );
49 
51  virtual bool addFeatures( QgsFeatureList& features );
52 
54  virtual bool deleteFeature( QgsFeatureId fid );
55 
57  virtual bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
58 
60  virtual bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
61 
64  virtual bool addAttribute( const QgsField &field );
65 
67  virtual bool deleteAttribute( int attr );
68 
69 
85  virtual bool commitChanges( QStringList& commitErrors );
86 
88  virtual void rollBack();
89 
90 
91 
93  inline const QgsFeatureMap& addedFeatures() { return mAddedFeatures; }
94 
96  inline const QgsChangedAttributesMap& changedAttributeValues() { return mChangedAttributeValues; }
97 
99  inline const QgsAttributeList& deletedAttributeIds() { return mDeletedAttributeIds; }
100 
102  inline const QList<QgsField>& addedAttributes() { return mAddedAttributes; }
103 
105  inline const QgsGeometryMap& changedGeometries() { return mChangedGeometries; }
106 
107  inline const QgsFeatureIds deletedFeatureIds() { return mDeletedFeatureIds; }
108  //QString dumpEditBuffer();
109 
110  protected slots:
111  void undoIndexChanged( int index );
112 
113  signals:
115  void layerModified();
116 
117  void featureAdded( QgsFeatureId fid );
118  void featureDeleted( QgsFeatureId fid );
119  void geometryChanged( QgsFeatureId fid, QgsGeometry &geom );
120  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
121  void attributeAdded( int idx );
122  void attributeDeleted( int idx );
123 
125  void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
126  void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
127  void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
128  void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
129  void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
130  void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
131 
132  protected:
133 
134  QgsVectorLayerEditBuffer() : L( NULL ) {}
135 
136  void updateFields( QgsFields& fields );
137 
139  void updateFeatureGeometry( QgsFeature &f );
140 
142  void updateChangedAttributes( QgsFeature &f );
143 
145  void handleAttributeAdded( int index );
146 
148  void handleAttributeDeleted( int index );
149 
150 
152  void updateAttributeMapIndex( QgsAttributeMap& attrs, int index, int offset ) const;
153 
154  void updateLayerFields();
155 
156  protected:
158  friend class QgsVectorLayer;
159 
167 
173 
176 
179 
182 
185 
188 
189 };
190 
191 #endif // QGSVECTORLAYEREDITBUFFER_H
const QgsGeometryMap & changedGeometries()
Changed geometries which are not commited.
static unsigned index
const QgsChangedAttributesMap & changedAttributeValues()
Changed attributes values which are not commited.
Container of fields for a vector layer.
Definition: qgsfield.h:173
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:75
QgsChangedAttributesMap mChangedAttributeValues
Changed attributes values which are not commited.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:162
QSet< int > QgsAttributeIds
QgsGeometryMap mChangedGeometries
Changed geometries which are not commited.
const QgsFeatureIds deletedFeatureIds()
QList< int > QgsAttributeList
QgsFeatureIds mDeletedFeatureIds
Deleted feature IDs which are not commited.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:38
const QList< QgsField > & addedAttributes()
added attributes fields which are not commited
const QgsFeatureMap & addedFeatures()
New features which are not commited.
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
QList< QgsField > mAddedAttributes
added attributes fields which are not commited
qint64 QgsFeatureId
Definition: qgsfeature.h:31
QgsFeatureMap mAddedFeatures
New features which are not commited.
Represents a vector layer which manages a vector based data sets.
const QgsAttributeList & deletedAttributeIds()
deleted attributes fields which are not commited.
QgsAttributeList mDeletedAttributeIds
deleted attributes fields which are not commited.