Skip to content

Commit

Permalink
Rename QgsVectorLayer::pkAttributeList to primaryKeyAttributes() for …
Browse files Browse the repository at this point in the history
…consistency
  • Loading branch information
nyalldawson committed Jan 15, 2018
1 parent 21c8956 commit ded9b09
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doc/api_break.dox
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
3 changes: 1 addition & 2 deletions python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2554,7 +2554,7 @@ bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids )
return res;
}

QgsAttributeList QgsVectorLayer::pkAttributeList() const
QgsAttributeList QgsVectorLayer::primaryKeyAttributes() const
{
QgsAttributeList pkAttributesList;

Expand Down Expand Up @@ -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>" );
Expand Down
3 changes: 1 addition & 2 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayertools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_provider_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def testKey(lyr, key, kfnames):
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])
Expand Down

0 comments on commit ded9b09

Please sign in to comment.