Skip to content

Commit 0736bf7

Browse files
committedJul 14, 2016
Rename edit buffer methods to is..., add tests
1 parent dc10c8f commit 0736bf7

File tree

7 files changed

+415
-23
lines changed

7 files changed

+415
-23
lines changed
 

‎python/core/qgsvectorlayereditbuffer.sip

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,42 +70,70 @@ class QgsVectorLayerEditBuffer : QObject
7070
/** Stop editing and discard the edits */
7171
virtual void rollBack();
7272

73-
/** Returns a map of new features which are not committed. */
73+
/** Returns a map of new features which are not committed.
74+
* @see isFeatureAdded()
75+
*/
7476
QgsFeatureMap addedFeatures() const;
7577

7678
/** Returns true if the specified feature ID has been added but not committed.
7779
* @param id feature ID
7880
* @note added in QGIS 3.0
81+
* @see addedFeatures()
7982
*/
80-
bool featureIsAdded( QgsFeatureId id ) const;
83+
bool isFeatureAdded( QgsFeatureId id ) const;
8184

82-
/** Returns a map of features with changed attributes values which are not committed */
85+
/** Returns a map of features with changed attributes values which are not committed.
86+
* @see isFeatureAttributesChanged()
87+
*/
8388
QgsChangedAttributesMap changedAttributeValues() const;
8489

8590
/** Returns true if the specified feature ID has had an attribute changed but not committed.
8691
* @param id feature ID
8792
* @note added in QGIS 3.0
93+
* @see changedAttributeValues()
8894
*/
89-
bool featureHasAttributeChanges( QgsFeatureId id ) const;
95+
bool isFeatureAttributesChanged( QgsFeatureId id ) const;
9096

91-
/** Returns a list of deleted attributes fields which are not committed. The list is kept sorted. */
97+
/** Returns a list of deleted attributes fields which are not committed. The list is kept sorted.
98+
* @see isAttributeDeleted()
99+
*/
92100
QgsAttributeList deletedAttributeIds() const;
93101

102+
/** Returns true if the specified attribute has been deleted but not committed.
103+
* @param index attribute index
104+
* @note added in QGIS 3.0
105+
* @see deletedAttributeIds()
106+
*/
107+
bool isAttributeDeleted( int index ) const;
108+
94109
/** Returns a list of added attributes fields which are not committed */
95110
QList<QgsField> addedAttributes() const;
96111

97-
/** Returns a map of features with changed geometries which are not committed. */
112+
/** Returns a map of features with changed geometries which are not committed.
113+
* @see hasFeatureGeometryChange()
114+
*/
98115
QgsGeometryMap changedGeometries() const;
99116

100117
/** Returns true if the specified feature ID has had its geometry changed but not committed.
101118
* @param id feature ID
102119
* @note added in QGIS 3.0
120+
* @see changedGeometries()
103121
*/
104-
bool featureHasGeometryChange( QgsFeatureId id ) const;
122+
bool isFeatureGeometryChanged( QgsFeatureId id ) const;
105123

106-
/** Returns a list of deleted feature IDs which are not committed. */
124+
/** Returns a list of deleted feature IDs which are not committed.
125+
* @see isFeatureDeleted()
126+
*/
107127
QgsFeatureIds deletedFeatureIds() const;
108128

129+
/** Returns true if the specified feature ID has been deleted but not committed.
130+
* @param id feature ID
131+
* @note added in QGIS 3.0
132+
* @see deletedFeatureIds()
133+
*/
134+
bool isFeatureDeleted( QgsFeatureId id ) const;
135+
136+
109137
//QString dumpEditBuffer();
110138

111139
protected slots:

‎src/core/qgsvectorlayereditbuffer.h

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,42 +99,70 @@ class CORE_EXPORT QgsVectorLayerEditBuffer : public QObject
9999
/** Stop editing and discard the edits */
100100
virtual void rollBack();
101101

102-
/** Returns a map of new features which are not committed. */
102+
/** Returns a map of new features which are not committed.
103+
* @see isFeatureAdded()
104+
*/
103105
QgsFeatureMap addedFeatures() const { return mAddedFeatures; }
104106

105107
/** Returns true if the specified feature ID has been added but not committed.
106108
* @param id feature ID
107109
* @note added in QGIS 3.0
110+
* @see addedFeatures()
108111
*/
109-
bool featureIsAdded( QgsFeatureId id ) const { return mAddedFeatures.contains( id ); }
112+
bool isFeatureAdded( QgsFeatureId id ) const { return mAddedFeatures.contains( id ); }
110113

111-
/** Returns a map of features with changed attributes values which are not committed */
114+
/** Returns a map of features with changed attributes values which are not committed.
115+
* @see isFeatureAttributesChanged()
116+
*/
112117
QgsChangedAttributesMap changedAttributeValues() const { return mChangedAttributeValues; }
113118

114119
/** Returns true if the specified feature ID has had an attribute changed but not committed.
115120
* @param id feature ID
116121
* @note added in QGIS 3.0
122+
* @see changedAttributeValues()
117123
*/
118-
bool featureHasAttributeChanges( QgsFeatureId id ) const { return mChangedAttributeValues.contains( id ); }
124+
bool isFeatureAttributesChanged( QgsFeatureId id ) const { return mChangedAttributeValues.contains( id ); }
119125

120-
/** Returns a list of deleted attributes fields which are not committed. The list is kept sorted. */
126+
/** Returns a list of deleted attributes fields which are not committed. The list is kept sorted.
127+
* @see isAttributeDeleted()
128+
*/
121129
QgsAttributeList deletedAttributeIds() const { return mDeletedAttributeIds; }
122130

123-
/** Returns a list of added attributes fields which are not committed */
131+
/** Returns true if the specified attribute has been deleted but not committed.
132+
* @param index attribute index
133+
* @note added in QGIS 3.0
134+
* @see deletedAttributeIds()
135+
*/
136+
bool isAttributeDeleted( int index ) const { return mDeletedAttributeIds.contains( index ); }
137+
138+
/** Returns a list of added attributes fields which are not committed.
139+
*/
124140
QList<QgsField> addedAttributes() const { return mAddedAttributes; }
125141

126-
/** Returns a map of features with changed geometries which are not committed. */
142+
/** Returns a map of features with changed geometries which are not committed.
143+
* @see hasFeatureGeometryChange()
144+
*/
127145
QgsGeometryMap changedGeometries() const { return mChangedGeometries; }
128146

129147
/** Returns true if the specified feature ID has had its geometry changed but not committed.
130148
* @param id feature ID
131149
* @note added in QGIS 3.0
150+
* @see changedGeometries()
132151
*/
133-
bool featureHasGeometryChange( QgsFeatureId id ) const { return mChangedGeometries.contains( id ); }
152+
bool isFeatureGeometryChanged( QgsFeatureId id ) const { return mChangedGeometries.contains( id ); }
134153

135-
/** Returns a list of deleted feature IDs which are not committed. */
154+
/** Returns a list of deleted feature IDs which are not committed.
155+
* @see isFeatureDeleted()
156+
*/
136157
QgsFeatureIds deletedFeatureIds() const { return mDeletedFeatureIds; }
137158

159+
/** Returns true if the specified feature ID has been deleted but not committed.
160+
* @param id feature ID
161+
* @note added in QGIS 3.0
162+
* @see deletedFeatureIds()
163+
*/
164+
bool isFeatureDeleted( QgsFeatureId id ) const { return mDeletedFeatureIds.contains( id ); }
165+
138166
//QString dumpEditBuffer();
139167

140168
protected slots:

‎src/gui/attributetable/qgsattributetablefiltermodel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,13 @@ bool QgsAttributeTableFilterModel::filterAcceptsRow( int sourceRow, const QModel
326326
{
327327
QgsFeatureId fid = masterModel()->rowToId( sourceRow );
328328

329-
if ( editBuffer->featureIsAdded( fid ) )
329+
if ( editBuffer->isFeatureAdded( fid ) )
330330
return true;
331331

332-
if ( editBuffer->featureHasAttributeChanges( fid ) )
332+
if ( editBuffer->isFeatureAttributesChanged( fid ) )
333333
return true;
334334

335-
if ( editBuffer->featureHasGeometryChange( fid ) )
335+
if ( editBuffer->isFeatureGeometryChanged( fid ) )
336336
return true;
337337

338338
return false;

‎src/gui/attributetable/qgsfeaturelistmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ QVariant QgsFeatureListModel::data( const QModelIndex &index, int role ) const
111111

112112
if ( editBuffer )
113113
{
114-
if ( editBuffer->featureIsAdded( feat.id() ) )
114+
if ( editBuffer->isFeatureAdded( feat.id() ) )
115115
{
116116
featInfo.isNew = true;
117117
}
118-
if ( editBuffer->featureHasAttributeChanges( feat.id() ) )
118+
if ( editBuffer->isFeatureAttributesChanged( feat.id() ) )
119119
{
120120
featInfo.isEdited = true;
121121
}

‎src/providers/grass/qgsgrassprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ void QgsGrassProvider::onFeatureAdded( QgsFeatureId fid )
12191219
}
12201220
// geometry
12211221
const QgsAbstractGeometryV2 *geometry = 0;
1222-
if ( !mEditBuffer->featureIsAdded( fid ) )
1222+
if ( !mEditBuffer->isFeatureAdded( fid ) )
12231223
{
12241224
#ifdef QGISDEBUG
12251225
QgsDebugMsg( "the feature is missing in buffer addedFeatures :" );

‎tests/src/python/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ ADD_PYTHON_TEST(PyQgsUnitTypes test_qgsunittypes.py)
9494
ADD_PYTHON_TEST(PyQgsVectorColorRamp test_qgsvectorcolorramp.py)
9595
ADD_PYTHON_TEST(PyQgsVectorFileWriter test_qgsvectorfilewriter.py)
9696
ADD_PYTHON_TEST(PyQgsVectorLayer test_qgsvectorlayer.py)
97+
ADD_PYTHON_TEST(PyQgsVectorLayerEditBuffer test_qgsvectorlayereditbuffer.py)
9798
ADD_PYTHON_TEST(PyQgsZonalStatistics test_qgszonalstatistics.py)
9899
ADD_PYTHON_TEST(PyQgsMapLayerRegistry test_qgsmaplayerregistry.py)
99100
ADD_PYTHON_TEST(PyQgsVirtualLayerProvider test_provider_virtual.py)

0 commit comments

Comments
 (0)
Please sign in to comment.