QGIS API Documentation 3.99.0-Master (a26b91b364d)
qgsfeaturefilterprovidergroup.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsfeaturefilterprovidergroup.cpp
3 --------------------------------
4 begin : 26-10-2017
5 copyright : (C) 2017 by Patrick Valsecchi
6 email : patrick dot valsecchi at camptocamp dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19#include "qgsfeaturerequest.h"
20
22{
23 for ( const QgsFeatureFilterProvider *provider : mProviders )
24 {
27 provider->filterFeatures( layer, temp );
29 if ( auto *lFilterExpression = temp.filterExpression() )
30 {
31 filterFeatures.combineFilterExpression( lFilterExpression->dump() );
32 }
33 }
34}
35
36QStringList QgsFeatureFilterProviderGroup::layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const
37{
38 QStringList allowedAttributes { attributes };
39 for ( const QgsFeatureFilterProvider *provider : mProviders )
40 {
41 const QgsFeatureRequest temp;
42 allowedAttributes = provider->layerAttributes( layer, allowedAttributes );
43 }
44 return allowedAttributes;
45}
46
48{
49 auto result = new QgsFeatureFilterProviderGroup();
50 result->mProviders = mProviders;
51 return result;
52}
53
55{
56 if ( provider )
57 {
58 mProviders.append( provider );
59 }
60 return *this;
61}
A filter filter provider grouping several filter providers.
void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures) const override
Add additional filters to the feature request to further restrict the features returned by the reques...
QgsFeatureFilterProviderGroup & addProvider(const QgsFeatureFilterProvider *provider)
Add another filter provider to the group.
QgsFeatureFilterProviderGroup * clone() const override
Create a clone of the feature filter provider.
QStringList layerAttributes(const QgsVectorLayer *layer, const QStringList &attributes) const override
Returns the list of visible attribute names from a list of attributes names for the given layer.
QgsFeatureFilterProviderGroup()=default
Constructor.
Abstract interface for use by classes that filter the features or attributes of a layer.
Wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
QgsExpression * filterExpression() const
Returns the filter expression (if set).
Represents a vector layer which manages a vector based dataset.
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:6945
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:6944