1/************************************************************************ 2 * This file has been generated automatically from * 3 * * 4 * src/core/qgsvectorlayereditbuffer.h * 5 * * 6 * Do not edit manually ! Edit header and run scripts/sipify.pl again * 7 ************************************************************************/ 8 9 10 11 12typedef QMap<QgsFeatureId, QgsFeature> QgsFeatureMap; 13 14class QgsVectorLayerEditBuffer : QObject 15{ 16 17%TypeHeaderCode 18#include "qgsvectorlayereditbuffer.h" 19%End 20 public: 21 QgsVectorLayerEditBuffer( QgsVectorLayer *layer ); 22 23 virtual bool isModified() const; 24%Docstring 25Returns ``True`` if the provider has been modified since the last commit 26%End 27 28 29 virtual bool addFeature( QgsFeature &f ); 30%Docstring 31Adds a feature 32 33:param f: feature to add 34 35:return: ``True`` in case of success and ``False`` in case of error 36%End 37 38 virtual bool addFeatures( QgsFeatureList &features ); 39%Docstring 40Insert a copy of the given features into the layer (but does not commit it) 41%End 42 43 virtual bool deleteFeature( QgsFeatureId fid ); 44%Docstring 45Delete a feature from the layer (but does not commit it) 46%End 47 48 virtual bool deleteFeatures( const QgsFeatureIds &fid ); 49%Docstring 50Deletes a set of features from the layer (but does not commit it) 51%End 52 53 virtual bool changeGeometry( QgsFeatureId fid, const QgsGeometry &geom ); 54%Docstring 55Change feature's geometry 56%End 57 58 virtual bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() ); 59%Docstring 60Changed an attribute value (but does not commit it) 61%End 62 63 virtual bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues ); 64%Docstring 65Changes values of attributes (but does not commit it). 66 67:return: ``True`` if attributes are well updated, ``False`` otherwise 68 69.. versionadded:: 3.0 70%End 71 72 virtual bool addAttribute( const QgsField &field ); 73%Docstring 74Add an attribute field (but does not commit it) 75returns true if the field was added 76%End 77 78 virtual bool deleteAttribute( int attr ); 79%Docstring 80Delete an attribute field (but does not commit it) 81%End 82 83 virtual bool renameAttribute( int attr, const QString &newName ); 84%Docstring 85Renames an attribute field (but does not commit it) 86 87:param attr: attribute index 88:param newName: new name of field 89 90.. versionadded:: 2.16 91%End 92 93 virtual bool commitChanges( QStringList &commitErrors ); 94%Docstring 95Attempts to commit any changes to disk. Returns the result of the attempt. 96If a commit fails, the in-memory changes are left alone. 97 98This allows editing to continue if the commit failed on e.g. a 99disallowed value in a Postgres database - the user can re-edit and try 100again. 101 102The commits occur in distinct stages, 103(add attributes, add features, change attribute values, change 104geometries, delete features, delete attributes) 105so if a stage fails, it's difficult to roll back cleanly. 106Therefore any error message also includes which stage failed so 107that the user has some chance of repairing the damage cleanly. 108%End 109 110 virtual void rollBack(); 111%Docstring 112Stop editing and discard the edits 113%End 114 115 QgsFeatureMap addedFeatures() const; 116%Docstring 117Returns a map of new features which are not committed. 118 119.. seealso:: :py:func:`isFeatureAdded` 120%End 121 122 bool isFeatureAdded( QgsFeatureId id ) const; 123%Docstring 124Returns ``True`` if the specified feature ID has been added but not committed. 125 126:param id: feature ID 127 128.. seealso:: :py:func:`addedFeatures` 129 130.. versionadded:: 3.0 131%End 132 133 QgsChangedAttributesMap changedAttributeValues() const; 134%Docstring 135Returns a map of features with changed attributes values which are not committed. 136 137.. seealso:: :py:func:`isFeatureAttributesChanged` 138%End 139 140 bool isFeatureAttributesChanged( QgsFeatureId id ) const; 141%Docstring 142Returns ``True`` if the specified feature ID has had an attribute changed but not committed. 143 144:param id: feature ID 145 146.. seealso:: :py:func:`changedAttributeValues` 147 148.. versionadded:: 3.0 149%End 150 151 QgsAttributeList deletedAttributeIds() const; 152%Docstring 153Returns a list of deleted attributes fields which are not committed. The list is kept sorted. 154 155.. seealso:: :py:func:`isAttributeDeleted` 156%End 157 158 bool isAttributeDeleted( int index ) const; 159%Docstring 160Returns ``True`` if the specified attribute has been deleted but not committed. 161 162:param index: attribute index 163 164.. seealso:: :py:func:`deletedAttributeIds` 165 166.. versionadded:: 3.0 167%End 168 169 QList<QgsField> addedAttributes() const; 170%Docstring 171Returns a list of added attributes fields which are not committed. 172%End 173 174 QgsGeometryMap changedGeometries() const; 175%Docstring 176Returns a map of features with changed geometries which are not committed. 177 178.. seealso:: :py:func:`isFeatureGeometryChanged` 179%End 180 181 bool isFeatureGeometryChanged( QgsFeatureId id ) const; 182%Docstring 183Returns ``True`` if the specified feature ID has had its geometry changed but not committed. 184 185:param id: feature ID 186 187.. seealso:: :py:func:`changedGeometries` 188 189.. versionadded:: 3.0 190%End 191 192 QgsFeatureIds deletedFeatureIds() const; 193%Docstring 194Returns a list of deleted feature IDs which are not committed. 195 196.. seealso:: :py:func:`isFeatureDeleted` 197%End 198 199 bool isFeatureDeleted( QgsFeatureId id ) const; 200%Docstring 201Returns ``True`` if the specified feature ID has been deleted but not committed. 202 203:param id: feature ID 204 205.. seealso:: :py:func:`deletedFeatureIds` 206 207.. versionadded:: 3.0 208%End 209 210 211 protected slots: 212 void undoIndexChanged( int index ); 213 214 signals: 215 void layerModified(); 216%Docstring 217Emitted when modifications has been done on layer 218%End 219 220 void featureAdded( QgsFeatureId fid ); 221 void featureDeleted( QgsFeatureId fid ); 222 223 void geometryChanged( QgsFeatureId fid, const QgsGeometry &geom ); 224%Docstring 225Emitted when a feature's geometry is changed. 226 227:param fid: feature ID 228:param geom: new feature geometry 229%End 230 231 void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & ); 232 void attributeAdded( int idx ); 233 void attributeDeleted( int idx ); 234 235 void attributeRenamed( int idx, const QString &newName ); 236%Docstring 237Emitted when an attribute has been renamed 238 239:param idx: attribute index 240:param newName: new attribute name 241 242.. versionadded:: 2.16 243%End 244 245 void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes ); 246%Docstring 247Signals emitted after committing changes 248%End 249 void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes ); 250 251 void committedAttributesRenamed( const QString &layerId, const QgsFieldNameMap &renamedAttributes ); 252%Docstring 253Emitted after committing an attribute rename 254 255:param layerId: ID of layer 256:param renamedAttributes: map of field index to new name 257 258.. versionadded:: 2.16 259%End 260 void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures ); 261 void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds ); 262 void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues ); 263 void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries ); 264 265 protected: 266 267 QgsVectorLayerEditBuffer(); 268%Docstring 269Constructor for QgsVectorLayerEditBuffer 270%End 271 272 void updateFields( QgsFields &fields ); 273 274 void updateFeatureGeometry( QgsFeature &f ); 275%Docstring 276Update feature with uncommitted geometry updates 277%End 278 279 void updateChangedAttributes( QgsFeature &f ); 280%Docstring 281Update feature with uncommitted attribute updates 282%End 283 284 void handleAttributeAdded( int index ); 285%Docstring 286Update added and changed features after addition of an attribute 287%End 288 289 void handleAttributeDeleted( int index ); 290%Docstring 291Update added and changed features after removal of an attribute 292%End 293 294 void updateAttributeMapIndex( QgsAttributeMap &attrs, int index, int offset ) const; 295%Docstring 296Updates an index in an attribute map to a new value (for updates of changed attributes) 297%End 298 299 void updateLayerFields(); 300 301 protected: 302 303 304 305 306 307 308 309 310 311 312}; 313 314/************************************************************************ 315 * This file has been generated automatically from * 316 * * 317 * src/core/qgsvectorlayereditbuffer.h * 318 * * 319 * Do not edit manually ! Edit header and run scripts/sipify.pl again * 320 ************************************************************************/ 321