Skip to content
Permalink
Browse files

Drop QgsVectorLayer::pendingFeatureCount()

Use QgsVectorLayer::featureCount() instead.
  • Loading branch information
nyalldawson committed Jan 12, 2018
1 parent 1da1790 commit 21c8956b182922fbde53de9046f462b9bf4a4622
@@ -2433,6 +2433,8 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.
- splitFeatured() now returns QgsGeometry::OperationResult enum, integer representation of returned values may have changed
- pendingFields() was dropped. Use fields() instead.
- pendingAllAttributesList() was dropped. Use allAttributes() instead.
- pendingPkAttributesList() was dropped. Use pkAttributeList() instead.
- pendingFeatureCount() was dropped. Use featureCount() instead.


QgsVectorLayerEditBuffer {#qgis_api_break_3_0_QgsVectorLayerEditBuffer}
@@ -1398,23 +1398,11 @@ This also includes fields which have not yet been saved to the provider.
%Docstring
Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
Alias for attributeList()
%End

QgsAttributeList pendingPkAttributesList() const;
%Docstring
Returns list of attributes making up the primary key
Alias for pkAttributeList()
%End

QgsAttributeList pkAttributeList() const;
%Docstring
Returns list of attributes making up the primary key
%End

long pendingFeatureCount() const;
%Docstring
Returns feature count including changes which have not yet been committed
Alias for featureCount()
Returns the list of attributes which make up the layer's primary keys.
%End

virtual long featureCount() const;
@@ -364,7 +364,7 @@ void QgsSnappingUtils::prepareIndex( const QList<LayerAndAreaOfInterest> &layers
// first time the layer is used? - let's set an initial guess about indexing
if ( !mHybridMaxAreaPerLayer.contains( vl->id() ) )
{
int totalFeatureCount = vl->pendingFeatureCount();
int totalFeatureCount = vl->featureCount();
if ( totalFeatureCount < mHybridPerLayerFeatureLimit )
{
// index the whole layer
@@ -1309,20 +1309,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }

/**
* Returns list of attributes making up the primary key
* Alias for pkAttributeList()
* Returns the list of attributes which make up the layer's primary keys.
*/
inline QgsAttributeList pendingPkAttributesList() const { return pkAttributeList(); }

//! Returns list of attributes making up the primary key
QgsAttributeList pkAttributeList() const;

/**
* Returns feature count including changes which have not yet been committed
* Alias for featureCount()
*/
inline long pendingFeatureCount() const { return featureCount(); }

/**
* Returns feature count including changes which have not yet been committed
* If you need only the count of committed features call this method on this layer's provider.
@@ -209,7 +209,7 @@ def testRepack(self):
ids = [f.id() for f in vl.getFeatures(QgsFeatureRequest().setFilterExpression('pk=1'))]
vl.selectByIds(ids)
self.assertEqual(vl.selectedFeatureIds(), ids)
self.assertEqual(vl.pendingFeatureCount(), 5)
self.assertEqual(vl.featureCount(), 5)
self.assertTrue(vl.startEditing())
self.assertTrue(vl.deleteFeature(3))
self.assertTrue(vl.commitChanges())
@@ -38,7 +38,7 @@ def createLayerWithOnePoint(self):
f.setAttributes(["test", 123])
f.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(100, 200)))
self.assertTrue(pr.addFeatures([f]))
self.assertEqual(self.layer.pendingFeatureCount(), 1)
self.assertEqual(self.layer.featureCount(), 1)
return self.layer

def doAttributeTest(self, idx, expected):
@@ -57,7 +57,7 @@ def testNoSliverPolygons(self):
features.append(f)

l.dataProvider().addFeatures(features)
assert l.pendingFeatureCount() == 7
assert l.featureCount() == 7

# create a geometry and remove its intersections with other geometries

@@ -71,7 +71,7 @@ def createLayerWithOnePoint():
f.setAttributes(["test", 123])
f.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(100, 200)))
assert pr.addFeatures([f])
assert layer.pendingFeatureCount() == 1
assert layer.featureCount() == 1
return layer


@@ -69,13 +69,13 @@

def createEmptyLayer():
layer = QgsVectorLayer("Point", "addfeat", "memory")
assert layer.pendingFeatureCount() == 0
assert layer.featureCount() == 0
return layer


def createEmptyLayerWithFields():
layer = QgsVectorLayer("Point?field=fldtxt:string&field=fldint:integer", "addfeat", "memory")
assert layer.pendingFeatureCount() == 0
assert layer.featureCount() == 0
return layer


@@ -87,7 +87,7 @@ def createLayerWithOnePoint():
f.setAttributes(["test", 123])
f.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(100, 200)))
assert pr.addFeatures([f])
assert layer.pendingFeatureCount() == 1
assert layer.featureCount() == 1
return layer


@@ -102,7 +102,7 @@ def createLayerWithTwoPoints():
f2.setAttributes(["test2", 457])
f2.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(100, 200)))
assert pr.addFeatures([f, f2])
assert layer.pendingFeatureCount() == 2
assert layer.featureCount() == 2
return layer


@@ -148,7 +148,7 @@ def createJoinLayer():
f4.setAttributes(["a", 458, 19])
f4.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(2, 2)))
assert pr.addFeatures([f1, f2, f3, f4])
assert joinLayer.pendingFeatureCount() == 4
assert joinLayer.featureCount() == 4
return joinLayer


@@ -246,7 +246,7 @@ def test_AddFeature(self):
feat.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(1, 2)))

def checkAfter():
self.assertEqual(layer.pendingFeatureCount(), 1)
self.assertEqual(layer.featureCount(), 1)

# check select+nextFeature
f = next(layer.getFeatures())
@@ -257,7 +257,7 @@ def checkAfter():
self.assertEqual(f2.geometry().asPoint(), QgsPointXY(1, 2))

def checkBefore():
self.assertEqual(layer.pendingFeatureCount(), 0)
self.assertEqual(layer.featureCount(), 0)

# check select+nextFeature
with self.assertRaises(StopIteration):
@@ -302,7 +302,7 @@ def test_AddFeatures(self):
feat2.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(11, 12)))

def checkAfter():
self.assertEqual(layer.pendingFeatureCount(), 2)
self.assertEqual(layer.featureCount(), 2)

# check select+nextFeature
it = layer.getFeatures()
@@ -318,7 +318,7 @@ def checkAfter():
self.assertEqual(f2_1.geometry().asPoint(), QgsPointXY(11, 12))

def checkBefore():
self.assertEqual(layer.pendingFeatureCount(), 0)
self.assertEqual(layer.featureCount(), 0)

# check select+nextFeature
with self.assertRaises(StopIteration):
@@ -362,7 +362,7 @@ def test_DeleteFeature(self):
fid = 1

def checkAfter():
self.assertEqual(layer.pendingFeatureCount(), 0)
self.assertEqual(layer.featureCount(), 0)

# check select+nextFeature
with self.assertRaises(StopIteration):
@@ -373,7 +373,7 @@ def checkAfter():
next(layer.getFeatures(QgsFeatureRequest(fid)))

def checkBefore():
self.assertEqual(layer.pendingFeatureCount(), 1)
self.assertEqual(layer.featureCount(), 1)

# check select+nextFeature
fi = layer.getFeatures()
@@ -420,14 +420,14 @@ def test_DeleteFeatureAfterAddFeature(self):
feat.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(1, 2)))

def checkBefore():
self.assertEqual(layer.pendingFeatureCount(), 0)
self.assertEqual(layer.featureCount(), 0)

# check select+nextFeature
with self.assertRaises(StopIteration):
next(layer.getFeatures())

def checkAfter1():
self.assertEqual(layer.pendingFeatureCount(), 1)
self.assertEqual(layer.featureCount(), 1)

def checkAfter2():
checkBefore() # should be the same state: no features
@@ -40,7 +40,7 @@ def createLayerWithOnePoint():
f.setAttributes(["test", 123])
f.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(100, 200)))
assert pr.addFeatures([f])
assert layer.pendingFeatureCount() == 1
assert layer.featureCount() == 1
return layer


@@ -39,7 +39,7 @@ def createLayerWithOnePoint():
f = QgsFeature()
f.setAttributes(["test", 123])
assert pr.addFeatures([f])
assert layer.pendingFeatureCount() == 1
assert layer.featureCount() == 1
return layer


0 comments on commit 21c8956

Please sign in to comment.
You can’t perform that action at this time.