LCOV - code coverage report
Current view: top level - core/vector - qgsvectorlayerfeaturecounter.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 0 1 0.0 %
Date: 2021-03-26 12:19:53 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       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 "qgsvectorlayerfeatureiterator.h"
      19                 :            : #include "qgsrenderer.h"
      20                 :            : #include "qgstaskmanager.h"
      21                 :            : #include "qgsfeatureid.h"
      22                 :            : 
      23                 :            : /**
      24                 :            :  * \ingroup core
      25                 :            :  *
      26                 :            :  * \brief Counts the features in a QgsVectorLayer in task.
      27                 :            :  * You should most likely not use this directly and instead call
      28                 :            :  * QgsVectorLayer::countSymbolFeatures() and connect to the signal
      29                 :            :  * QgsVectorLayer::symbolFeatureCountMapChanged().
      30                 :            :  *
      31                 :            :  * \since QGIS 3.0
      32                 :            :  */
      33                 :            : class CORE_EXPORT QgsVectorLayerFeatureCounter : public QgsTask
      34                 :            : {
      35                 :          0 :     Q_OBJECT
      36                 :            : 
      37                 :            :   public:
      38                 :            : 
      39                 :            :     /**
      40                 :            :      * Create a new feature counter for \a layer.
      41                 :            :      * \param layer Target QgsVectorLayer to perform counting on.
      42                 :            :      * \param context Specific QgsExpressionContext to use during the rendering step.
      43                 :            :      * \param storeSymbolFids If TRUE will store the feature ids (fids), otherwise will only count the number of features per symbol. Default FALSE.
      44                 :            :      */
      45                 :            :     QgsVectorLayerFeatureCounter( QgsVectorLayer *layer, const QgsExpressionContext &context = QgsExpressionContext(), bool storeSymbolFids = false );
      46                 :            : 
      47                 :            : 
      48                 :            :     /**
      49                 :            :      * Calculates the feature count and Ids per symbol
      50                 :            :      */
      51                 :            :     bool run() override;
      52                 :            : 
      53                 :            :     /**
      54                 :            :      * Returns the count for each symbol. Only valid after the symbolsCounted()
      55                 :            :      * signal has been emitted.
      56                 :            :      *
      57                 :            :      * \note Not available in Python bindings.
      58                 :            :      */
      59                 :            :     QHash<QString, long> symbolFeatureCountMap() const SIP_SKIP;
      60                 :            : 
      61                 :            :     /**
      62                 :            :      * Returns the feature count for a particular \a legendKey.
      63                 :            :      * If the key has not been found, -1 will be returned.
      64                 :            :      */
      65                 :            :     long featureCount( const QString &legendKey ) const;
      66                 :            : 
      67                 :            :     /**
      68                 :            :      * Returns the QgsFeatureIds for each symbol. Only valid after the symbolsCounted()
      69                 :            :      * signal has been emitted.
      70                 :            :      *
      71                 :            :      * \see symbolFeatureCountMap
      72                 :            :      * \note Not available in Python bindings.
      73                 :            :      * \since QGIS 3.10
      74                 :            :      */
      75                 :            :     QHash<QString, QgsFeatureIds> symbolFeatureIdMap() const SIP_SKIP;
      76                 :            : 
      77                 :            :     /**
      78                 :            :      * Returns the feature Ids for a particular \a legendKey.
      79                 :            :      * If the key has not been found an empty QSet will be returned.
      80                 :            :      *
      81                 :            :      * \since QGIS 3.10
      82                 :            :      */
      83                 :            :     QgsFeatureIds featureIds( const QString &symbolkey ) const;
      84                 :            : 
      85                 :            :   signals:
      86                 :            : 
      87                 :            :     /**
      88                 :            :      * Emitted when the symbols have been counted.
      89                 :            :      */
      90                 :            :     void symbolsCounted();
      91                 :            : 
      92                 :            :   private:
      93                 :            :     std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
      94                 :            :     std::unique_ptr<QgsFeatureRenderer> mRenderer;
      95                 :            :     QgsExpressionContext mExpressionContext;
      96                 :            :     QHash<QString, long> mSymbolFeatureCountMap;
      97                 :            :     QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;
      98                 :            :     bool mWithFids = false;
      99                 :            :     int mFeatureCount;
     100                 :            : 
     101                 :            : };
     102                 :            : 
     103                 :            : #endif // QGSVECTORLAYERFEATURECOUNTER_H

Generated by: LCOV version 1.14