Skip to content

Commit 032e082

Browse files
committed
Update doc and add python binding
1 parent 333cf42 commit 032e082

File tree

5 files changed

+49
-10
lines changed

5 files changed

+49
-10
lines changed

python/core/qgsvectorlayer.sip

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,39 @@ class QgsVectorLayer : QgsMapLayer
954954
*/
955955
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
956956

957+
/**
958+
* Changes attributes' values for a feature (but does not immediately
959+
* commit the changes).
960+
* The \a fid argument specifies the ID of the feature to be changed.
961+
*
962+
* The new values to be assigned to the fields are given by \a newValues.
963+
*
964+
* If a valid QVariant is specified for a field in \a oldValues, it will be
965+
* used as the field value in the case of an undo operation corresponding
966+
* to this attribute value change. If an invalid QVariant is used (the
967+
* default behavior), then the feature's current value will be
968+
* automatically retrieved and used. Note that this involves a feature
969+
* request to the underlying data provider, so it is more efficient to
970+
* explicitly pass an oldValue if it is already available.
971+
*
972+
* Returns true if feature's attributes was successfully changed.
973+
*
974+
* @note Calls to changeAttributeValues() are only valid for layers in
975+
* which edits have been enabled by a call to startEditing(). Changes made
976+
* to features using this method are not committed to the underlying data
977+
* provider until a commitChanges() call is made. Any uncommitted changes
978+
* can be discarded by calling rollBack().
979+
*
980+
* @see startEditing()
981+
* @see commitChanges()
982+
* @see changeGeometry()
983+
* @see updateFeature()
984+
* @see changeAttributeValue()
985+
*
986+
* @note added in QGIS 2.18
987+
*/
988+
bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues );
989+
957990
/** Add an attribute field (but does not commit it)
958991
* returns true if the field was added
959992
*/

python/core/qgsvectorlayereditbuffer.sip

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ class QgsVectorLayerEditBuffer : QObject
7070
/** Stop editing and discard the edits */
7171
virtual void rollBack();
7272

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

7580
/** New features which are not commited. */
7681
const QgsFeatureMap& addedFeatures();

python/core/qgsvectorlayereditpassthrough.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class QgsVectorLayerEditPassthrough : QgsVectorLayerEditBuffer
1212
bool deleteFeatures( const QgsFeatureIds& fids );
1313
bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
1414
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
15+
bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues );
1516
bool addAttribute( const QgsField &field );
1617
bool deleteAttribute( int attr );
1718
bool renameAttribute( int attr, const QString& newName );

src/core/qgsvectorlayer.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,19 +1364,19 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
13641364
*
13651365
* Returns true if feature's attributes was successfully changed.
13661366
*
1367-
* \note Calls to changeAttributeValues() are only valid for layers in
1367+
* @note Calls to changeAttributeValues() are only valid for layers in
13681368
* which edits have been enabled by a call to startEditing(). Changes made
13691369
* to features using this method are not committed to the underlying data
13701370
* provider until a commitChanges() call is made. Any uncommitted changes
13711371
* can be discarded by calling rollBack().
13721372
*
1373-
* \see startEditing()
1374-
* \see commitChanges()
1375-
* \see changeGeometry()
1376-
* \see updateFeature()
1377-
* \see changeAttributeValue()
1373+
* @see startEditing()
1374+
* @see commitChanges()
1375+
* @see changeGeometry()
1376+
* @see updateFeature()
1377+
* @see changeAttributeValue()
13781378
*
1379-
* \since QGIS 2.18
1379+
* @note added in QGIS 2.18
13801380
*/
13811381
bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues );
13821382

src/core/qgsvectorlayereditbuffer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class CORE_EXPORT QgsVectorLayerEditBuffer : public QObject
101101

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

0 commit comments

Comments
 (0)