Skip to content

Commit f404751

Browse files
committedOct 8, 2018
move definition to source
1 parent 775d603 commit f404751

File tree

2 files changed

+51
-47
lines changed

2 files changed

+51
-47
lines changed
 

‎src/app/qgsstatisticalsummarydockwidget.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "qgsstatisticalsummarydockwidget.h"
2222
#include "qgsstatisticalsummary.h"
2323
#include "qgsvectorlayer.h"
24+
#include "qgsfeedback.h"
25+
#include "qgsvectorlayerutils.h"
2426

2527
#include <QTableWidget>
2628
#include <QAction>
@@ -578,3 +580,49 @@ QgsStatisticalSummaryDockWidget::DataType QgsStatisticalSummaryDockWidget::field
578580

579581
return DataType::Numeric;
580582
}
583+
584+
QgsStatisticsValueGatherer::QgsStatisticsValueGatherer( QgsVectorLayer *layer, const QgsFeatureIterator &fit, long featureCount, const QString &sourceFieldExp )
585+
: QgsTask( tr( "Fetching statistic values" ) )
586+
, mFeatureIterator( fit )
587+
, mFeatureCount( featureCount )
588+
, mFieldExpression( sourceFieldExp )
589+
{
590+
mFieldIndex = layer->fields().lookupField( mFieldExpression );
591+
if ( mFieldIndex == -1 )
592+
{
593+
// use expression, already validated
594+
mExpression.reset( new QgsExpression( mFieldExpression ) );
595+
mContext.appendScopes( QgsExpressionContextUtils::globalProjectLayerScopes( layer ) );
596+
}
597+
}
598+
599+
bool QgsStatisticsValueGatherer::run()
600+
{
601+
QgsFeature f;
602+
int current = 0;
603+
while ( mFeatureIterator.nextFeature( f ) )
604+
{
605+
if ( mExpression )
606+
{
607+
mContext.setFeature( f );
608+
QVariant v = mExpression->evaluate( &mContext );
609+
mValues << v;
610+
}
611+
else
612+
{
613+
mValues << f.attribute( mFieldIndex );
614+
}
615+
616+
if ( isCanceled() )
617+
{
618+
return false;
619+
}
620+
621+
current++;
622+
if ( mFeatureCount > 0 )
623+
{
624+
setProgress( 100.0 * static_cast< double >( current ) / mFeatureCount );
625+
}
626+
}
627+
return true;
628+
}

‎src/app/qgsstatisticalsummarydockwidget.h

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#include "qgsdatetimestatisticalsummary.h"
2424
#include "qgsdockwidget.h"
2525
#include "qgsfeatureiterator.h"
26-
#include "qgsfeedback.h"
27-
#include "qgsvectorlayerutils.h"
2826
#include "qgstaskmanager.h"
2927

3028
#include "qgis_app.h"
@@ -47,51 +45,9 @@ class QgsStatisticsValueGatherer : public QgsTask
4745
Q_OBJECT
4846

4947
public:
50-
QgsStatisticsValueGatherer( QgsVectorLayer *layer, const QgsFeatureIterator &fit, long featureCount, const QString &sourceFieldExp )
51-
: QgsTask( tr( "Fetching statistic values" ) )
52-
, mFeatureIterator( fit )
53-
, mFeatureCount( featureCount )
54-
, mFieldExpression( sourceFieldExp )
55-
{
56-
mFieldIndex = layer->fields().lookupField( mFieldExpression );
57-
if ( mFieldIndex == -1 )
58-
{
59-
// use expression, already validated
60-
mExpression.reset( new QgsExpression( mFieldExpression ) );
61-
mContext.appendScopes( QgsExpressionContextUtils::globalProjectLayerScopes( layer ) );
62-
}
63-
}
64-
65-
bool run() override
66-
{
67-
QgsFeature f;
68-
int current = 0;
69-
while ( mFeatureIterator.nextFeature( f ) )
70-
{
71-
if ( mExpression )
72-
{
73-
mContext.setFeature( f );
74-
QVariant v = mExpression->evaluate( &mContext );
75-
mValues << v;
76-
}
77-
else
78-
{
79-
mValues << f.attribute( mFieldIndex );
80-
}
81-
82-
if ( isCanceled() )
83-
{
84-
return false;
85-
}
86-
87-
current++;
88-
if ( mFeatureCount > 0 )
89-
{
90-
setProgress( 100.0 * static_cast< double >( current ) / mFeatureCount );
91-
}
92-
}
93-
return true;
94-
}
48+
QgsStatisticsValueGatherer( QgsVectorLayer *layer, const QgsFeatureIterator &fit, long featureCount, const QString &sourceFieldExp );
49+
50+
bool run() override;
9551

9652
QList<QVariant> values() const { return mValues; }
9753

0 commit comments

Comments
 (0)
Please sign in to comment.