QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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 {
26 provider->filterFeatures( layer, temp );
27 if ( auto *lFilterExpression = temp.filterExpression() )
28 {
29 filterFeatures.combineFilterExpression( lFilterExpression->dump() );
30 }
31 }
32}
33
34QStringList QgsFeatureFilterProviderGroup::layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const
35{
36 QStringList allowedAttributes { attributes };
37 for ( const QgsFeatureFilterProvider *provider : mProviders )
38 {
39 const QgsFeatureRequest temp;
40 allowedAttributes = provider->layerAttributes( layer, allowedAttributes );
41 }
42 return allowedAttributes;
43}
44
46{
47 auto result = new QgsFeatureFilterProviderGroup();
48 result->mProviders = mProviders;
49 return result;
50}
51
53{
54 if ( provider )
55 {
56 mProviders.append( provider );
57 }
58 return *this;
59}
A filter filter provider grouping several filter providers.
void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures) const override
Filter the features of the layer.
QgsFeatureFilterProviderGroup & addProvider(const QgsFeatureFilterProvider *provider)
Add another filter provider to the group.
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.
QgsFeatureFilterProvider * clone() const override
Returns a clone of the object.
Abstract interface for use by classes that filter the features or attributes of a layer.
This class 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 data sets.