Skip to content

Commit

Permalink
add QgsFeatureRequest::setNoAttributes (#8326)
Browse files Browse the repository at this point in the history
since it's more convenient than setSubsetOfAttributes( QgsAttributesList() )
  • Loading branch information
3nids committed Oct 25, 2018
1 parent 653a668 commit 699d848
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/core/auto_generated/qgsfeaturerequest.sip.in
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsfeaturerequest.cpp
Expand Up @@ -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 ) )
Expand Down
8 changes: 8 additions & 0 deletions src/core/qgsfeaturerequest.h
Expand Up @@ -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
Expand Down

0 comments on commit 699d848

Please sign in to comment.