Skip to content

Commit

Permalink
Update doc and add python binding
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Apr 6, 2018
1 parent 333cf42 commit 032e082
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
33 changes: 33 additions & 0 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -954,6 +954,39 @@ class QgsVectorLayer : QgsMapLayer
*/
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );

/**
* Changes attributes' values for a feature (but does not immediately
* commit the changes).
* The \a fid argument specifies the ID of the feature to be changed.
*
* The new values to be assigned to the fields are given by \a newValues.
*
* If a valid QVariant is specified for a field in \a oldValues, it will be
* used as the field value in the case of an undo operation corresponding
* to this attribute value change. If an invalid QVariant is used (the
* default behavior), then the feature's current value will be
* automatically retrieved and used. Note that this involves a feature
* request to the underlying data provider, so it is more efficient to
* explicitly pass an oldValue if it is already available.
*
* Returns true if feature's attributes was successfully changed.
*
* @note Calls to changeAttributeValues() are only valid for layers in
* which edits have been enabled by a call to startEditing(). Changes made
* to features using this method are not committed to the underlying data
* provider until a commitChanges() call is made. Any uncommitted changes
* can be discarded by calling rollBack().
*
* @see startEditing()
* @see commitChanges()
* @see changeGeometry()
* @see updateFeature()
* @see changeAttributeValue()
*
* @note added in QGIS 2.18
*/
bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues );

/** Add an attribute field (but does not commit it)
* returns true if the field was added
*/
Expand Down
7 changes: 6 additions & 1 deletion python/core/qgsvectorlayereditbuffer.sip
Expand Up @@ -70,7 +70,12 @@ class QgsVectorLayerEditBuffer : QObject
/** Stop editing and discard the edits */
virtual void rollBack();


/**
* Changes values of attributes (but does not commit it).
* @return true if attributes are well updated, false otherwise
* @note added in QGIS 2.18
*/
virtual bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues );

/** New features which are not commited. */
const QgsFeatureMap& addedFeatures();
Expand Down
1 change: 1 addition & 0 deletions python/core/qgsvectorlayereditpassthrough.sip
Expand Up @@ -12,6 +12,7 @@ class QgsVectorLayerEditPassthrough : QgsVectorLayerEditBuffer
bool deleteFeatures( const QgsFeatureIds& fids );
bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues );
bool addAttribute( const QgsField &field );
bool deleteAttribute( int attr );
bool renameAttribute( int attr, const QString& newName );
Expand Down
14 changes: 7 additions & 7 deletions src/core/qgsvectorlayer.h
Expand Up @@ -1364,19 +1364,19 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*
* Returns true if feature's attributes was successfully changed.
*
* \note Calls to changeAttributeValues() are only valid for layers in
* @note Calls to changeAttributeValues() are only valid for layers in
* which edits have been enabled by a call to startEditing(). Changes made
* to features using this method are not committed to the underlying data
* provider until a commitChanges() call is made. Any uncommitted changes
* can be discarded by calling rollBack().
*
* \see startEditing()
* \see commitChanges()
* \see changeGeometry()
* \see updateFeature()
* \see changeAttributeValue()
* @see startEditing()
* @see commitChanges()
* @see changeGeometry()
* @see updateFeature()
* @see changeAttributeValue()
*
* \since QGIS 2.18
* @note added in QGIS 2.18
*/
bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues );

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayereditbuffer.h
Expand Up @@ -101,8 +101,8 @@ class CORE_EXPORT QgsVectorLayerEditBuffer : public QObject

/**
* Changes values of attributes (but does not commit it).
* \returns true if attributes are well updated, false otherwise
* \since QGIS 2.18
* @return true if attributes are well updated, false otherwise
* @note added in QGIS 2.18
*/
virtual bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues );

Expand Down

0 comments on commit 032e082

Please sign in to comment.