QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsdimensionfilter.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdimensionfilter.cpp
3  -------------------
4  begin : September 2021
5  copyright : (C) 2021 Matthias Kuhn
6  email : [email protected]
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 
18 #include "qgsdimensionfilter.h"
19 
20 QgsDimensionFilter::QgsDimensionFilter( const QHash<const QgsVectorLayer *, QStringList> dimensionFilter )
21  : mDimensionFilter( dimensionFilter )
22 {
23 
24 }
25 
26 void QgsDimensionFilter::filterFeatures( const QgsVectorLayer *layer, QgsFeatureRequest &featureRequest ) const
27 {
28  const QStringList dimFilters = mDimensionFilter.value( layer );
29 
30  for ( const QString &flt : dimFilters )
31  featureRequest.combineFilterExpression( flt );
32 }
33 
34 QStringList QgsDimensionFilter::layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const
35 {
36  Q_UNUSED( layer )
37  return attributes;
38 }
39 
41 {
42  return new QgsDimensionFilter( mDimensionFilter );
43 }
QgsDimensionFilter
A server filter to apply a dimension filter to a request.
Definition: qgsdimensionfilter.h:32
QgsFeatureRequest
This class wraps a request for features to a vector layer (or directly its vector data provider).
Definition: qgsfeaturerequest.h:83
QgsFeatureRequest::combineFilterExpression
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
Definition: qgsfeaturerequest.cpp:174
QgsDimensionFilter::filterFeatures
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...
Definition: qgsdimensionfilter.cpp:26
qgsdimensionfilter.h
QgsDimensionFilter::layerAttributes
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.
Definition: qgsdimensionfilter.cpp:34
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsDimensionFilter::QgsDimensionFilter
QgsDimensionFilter(const QHash< const QgsVectorLayer *, QStringList > dimensionFilter)
Creates a new dimension filter object with a list of filters to be applied to vector layers.
Definition: qgsdimensionfilter.cpp:20
QgsDimensionFilter::clone
QgsDimensionFilter * clone() const override
Create a clone of the feature filter provider.
Definition: qgsdimensionfilter.cpp:40