QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgsvectorlayerfeaturecounter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorlayerfeaturecounter.h
3 ---------------------
4 begin : May 2017
5 copyright : (C) 2017 by Matthias Kuhn
6 email : matthias at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSVECTORLAYERFEATURECOUNTER_H
16#define QGSVECTORLAYERFEATURECOUNTER_H
17
18#include "qgsfeatureid.h"
19#include "qgsrenderer.h"
20#include "qgstaskmanager.h"
22
33class CORE_EXPORT QgsVectorLayerFeatureCounter : public QgsTask
34{
35 Q_OBJECT
36
37 public:
38
45 QgsVectorLayerFeatureCounter( QgsVectorLayer *layer, const QgsExpressionContext &context = QgsExpressionContext(), bool storeSymbolFids = false );
47
51 bool run() override;
52
53 void cancel() override;
54
61 QHash<QString, long long> symbolFeatureCountMap() const SIP_SKIP;
62
67 long long featureCount( const QString &legendKey ) const;
68
77 QHash<QString, QgsFeatureIds> symbolFeatureIdMap() const SIP_SKIP;
78
85 QgsFeatureIds featureIds( const QString &symbolkey ) const;
86
87 signals:
88
93
94 private:
95 std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
96 std::unique_ptr<QgsFeatureRenderer> mRenderer;
97 QgsExpressionContext mExpressionContext;
98 QHash<QString, long long> mSymbolFeatureCountMap;
99 QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;
100 std::unique_ptr< QgsFeedback > mFeedback;
101 bool mWithFids = false;
102 long mFeatureCount = 0;
103
104};
105
106#endif // QGSVECTORLAYERFEATURECOUNTER_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Abstract base class for all 2D vector feature renderers.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
virtual bool run()=0
Performs the task's operation.
virtual void cancel()
Notifies the task that it should terminate.
QgsTask(const QString &description=QString(), QgsTask::Flags flags=AllFlags)
Constructor for QgsTask.
void symbolsCounted()
Emitted when the symbols have been counted.
~QgsVectorLayerFeatureCounter() override
QgsVectorLayerFeatureCounter(QgsVectorLayer *layer, const QgsExpressionContext &context=QgsExpressionContext(), bool storeSymbolFids=false)
Create a new feature counter for layer.
QHash< QString, long long > symbolFeatureCountMap() const
Returns the count for each symbol.
long long featureCount(const QString &legendKey) const
Returns the feature count for a particular legendKey.
QgsFeatureIds featureIds(const QString &symbolkey) const
Returns the feature Ids for a particular legendKey.
QHash< QString, QgsFeatureIds > symbolFeatureIdMap() const
Returns the QgsFeatureIds for each symbol.
Partial snapshot of vector layer's state (only the members necessary for access to features).
Represents a vector layer which manages a vector based dataset.
#define SIP_SKIP
Definition qgis_sip.h:134
QSet< QgsFeatureId > QgsFeatureIds