add QgsFeatureRequest::setNoAttributes (#8326)

since it's more convenient than setSubsetOfAttributes( QgsAttributesList() )
This commit is contained in:
Denis Rouzaud 2018-10-25 07:35:05 -08:00 committed by GitHub
parent 653a668531
commit 699d8487dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -513,6 +513,15 @@ Set a subset of attributes that will be fetched.
An empty attributes list indicates that no attributes will be fetched.
To revert a call to setSubsetOfAttributes and fetch all available attributes,
the SubsetOfAttributes flag should be removed from the request.
%End
QgsFeatureRequest &setNoAttributes();
%Docstring
Set that no attributes will be fetched.
To revert a call to setNoAttributes and fetch all or some available attributes,
the SubsetOfAttributes flag should be removed from the request.
.. versionadded:: 3.4
%End
QgsAttributeList subsetOfAttributes() const;

View File

@ -190,6 +190,11 @@ QgsFeatureRequest &QgsFeatureRequest::setSubsetOfAttributes( const QgsAttributeL
return *this;
}
QgsFeatureRequest &QgsFeatureRequest::setNoAttributes()
{
return setSubsetOfAttributes( QgsAttributeList() );
}
QgsFeatureRequest &QgsFeatureRequest::setSubsetOfAttributes( const QStringList &attrNames, const QgsFields &fields )
{
if ( attrNames.contains( QgsFeatureRequest::ALL_ATTRIBUTES ) )

View File

@ -501,6 +501,14 @@ class CORE_EXPORT QgsFeatureRequest
*/
QgsFeatureRequest &setSubsetOfAttributes( const QgsAttributeList &attrs );
/**
* Set that no attributes will be fetched.
* To revert a call to setNoAttributes and fetch all or some available attributes,
* the SubsetOfAttributes flag should be removed from the request.
* \since QGIS 3.4
*/
QgsFeatureRequest &setNoAttributes();
/**
* Returns the subset of attributes which at least need to be fetched
* \returns A list of attributes to be fetched