QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsgroupedfeaturefilterprovider.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsgroupedfeaturefilterprovider.cpp
3 --------------------------------
4 begin : 2025-07-26
5 copyright : (C) 2025 by Mathieu Pellerin
6 email : mathieu at opengis dot ch
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
20#include "qgsfeaturerequest.h"
21#include "qgsvectorlayer.h"
22
24{
25 for ( const QgsFeatureFilterProvider *provider : mProviders )
26 {
28 if ( !provider->isFilterThreadSafe() )
29 {
30 return false;
31 }
33 }
34 return true;
35}
36
38{
39 for ( const QgsFeatureFilterProvider *provider : mProviders )
40 {
43 if ( provider->isFilterThreadSafe() )
44 {
45 provider->filterFeatures( layer->id(), temp );
46 }
47 else
48 {
49 provider->filterFeatures( layer, temp );
50 }
52 if ( auto *lFilterExpression = temp.filterExpression() )
53 {
54 filterFeatures.combineFilterExpression( lFilterExpression->dump() );
55 }
56 }
57}
58
60{
61 for ( const QgsFeatureFilterProvider *provider : mProviders )
62 {
64 provider->filterFeatures( layerId, temp );
65 if ( auto *lFilterExpression = temp.filterExpression() )
66 {
67 filterFeatures.combineFilterExpression( lFilterExpression->dump() );
68 }
69 }
70}
71
72QStringList QgsGroupedFeatureFilterProvider::layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const
73{
74 QStringList allowedAttributes { attributes };
75 for ( const QgsFeatureFilterProvider *provider : mProviders )
76 {
77 const QgsFeatureRequest temp;
78 allowedAttributes = provider->layerAttributes( layer, allowedAttributes );
79 }
80 return allowedAttributes;
81}
82
84{
86 filter->mProviders = mProviders;
87 return filter;
88}
89
91{
92 if ( provider )
93 {
94 mProviders.append( provider );
95 }
96 return *this;
97}
QgsFeatureFilterProvider()=default
Wraps a request for features to a vector layer (or directly its vector data provider).
QgsExpression * filterExpression() const
Returns the filter expression (if set).
Q_DECL_DEPRECATED bool isFilterThreadSafe() const override
Returns true if the filterFeature function is thread safe, which will lead to reliance on layer ID in...
QgsGroupedFeatureFilterProvider()=default
Constructor.
QgsGroupedFeatureFilterProvider * clone() const override
Create a clone of the feature filter provider.
Q_DECL_DEPRECATED 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...
QgsGroupedFeatureFilterProvider & 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.
QString id
Definition qgsmaplayer.h:83
Represents a vector layer which manages a vector based dataset.
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:7170
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:7169