Rename QgsVectorLayer::pkAttributeList to primaryKeyAttributes() for consistency

This commit is contained in:
Nyall Dawson 2018-01-15 09:05:32 +10:00
parent 21c8956b18
commit ded9b0978d
6 changed files with 7 additions and 9 deletions

View File

@ -2433,7 +2433,7 @@ 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.
- pendingPkAttributesList() and pkAttributeList() were dropped. Use primaryKeyAttributes() instead.
- pendingFeatureCount() was dropped. Use featureCount() instead.

View File

@ -1397,10 +1397,9 @@ This also includes fields which have not yet been saved to the provider.
QgsAttributeList attributeList() const;
%Docstring
Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
Alias for attributeList()
%End
QgsAttributeList pkAttributeList() const;
QgsAttributeList primaryKeyAttributes() const;
%Docstring
Returns the list of attributes which make up the layer's primary keys.
%End

View File

@ -2554,7 +2554,7 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids )
return res;
}
QgsAttributeList QgsVectorLayer::pkAttributeList() const
QgsAttributeList QgsVectorLayer::primaryKeyAttributes() const
{
QgsAttributeList pkAttributesList;
@ -4082,7 +4082,7 @@ QString QgsVectorLayer::htmlMetadata() const
myMetadata += QStringLiteral( "<h1>" ) + tr( "Fields" ) + QStringLiteral( "</h1>\n<hr>\n<table class=\"list-view\">\n" );
// primary key
QgsAttributeList pkAttrList = pkAttributeList();
QgsAttributeList pkAttrList = primaryKeyAttributes();
if ( !pkAttrList.isEmpty() )
{
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Primary key attributes" ) + QStringLiteral( "</td><td>" );

View File

@ -1304,14 +1304,13 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
/**
* Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
* Alias for attributeList()
*/
inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }
/**
* Returns the list of attributes which make up the layer's primary keys.
*/
QgsAttributeList pkAttributeList() const;
QgsAttributeList primaryKeyAttributes() const;
/**
* Returns feature count including changes which have not yet been committed

View File

@ -34,7 +34,7 @@ bool QgsVectorLayerTools::copyMoveFeatures( QgsVectorLayer *layer, QgsFeatureReq
QgsFeatureIterator fi = layer->getFeatures( request );
QgsFeature f;
QgsAttributeList pkAttrList = layer->pkAttributeList();
QgsAttributeList pkAttrList = layer->primaryKeyAttributes();
int browsedFeatureCount = 0;
int couldNotWriteCount = 0;

View File

@ -758,7 +758,7 @@ class TestPyQgsPostgresProvider(unittest.TestCase, ProviderTestCase):
self.assertEqual(oflds.size(), flds.size())
for i in range(oflds.size()):
self.assertEqual(oflds[i].name(), flds[i].name())
pks = olyr.pkAttributeList()
pks = olyr.primaryKeyAttributes()
self.assertEqual(len(pks), len(kfnames))
for i in range(0, len(kfnames)):
self.assertEqual(oflds[pks[i]].name(), kfnames[i])