Skip to content
Permalink
Browse files

QgsVectorLayer, countSymbolFeatures return QgsVectorLayerFeatureCounter

  • Loading branch information
rldhont committed Sep 14, 2017
1 parent 08cacd4 commit f88af6d55f230813dfffa51be6d1d660d15354c4
Showing with 22 additions and 20 deletions.
  1. +8 −7 python/core/qgsvectorlayer.sip
  2. +7 −7 src/core/qgsvectorlayer.cpp
  3. +7 −6 src/core/qgsvectorlayer.h
@@ -854,20 +854,21 @@ Return the provider type for this layer
.. versionadded:: 2.10
%End

bool countSymbolFeatures();
QgsVectorLayerFeatureCounter *countSymbolFeatures();
%Docstring
Count features for symbols.
The method will return immediately. You will need to connect to the
symbolFeatureCountMapChanged() signal to be notified when the freshly updated
feature counts are ready.
The method will return the feature counter task. You will need to
connect to the symbolFeatureCountMapChanged() signal to be
notified when the freshly updated feature counts are ready.

.. note::

If you need to wait for the results, create and start your own QgsVectorLayerFeatureCounter
task and call waitForFinished().
If the count features for symbols has been already done a
None is returned. If you need to wait for the results,
you can call waitForFinished() on the feature counter.

.. versionadded:: 3.0
:rtype: bool
:rtype: QgsVectorLayerFeatureCounter
%End

virtual bool setSubsetString( const QString &subset );
@@ -726,27 +726,27 @@ class QgsVectorLayerInterruptionCheckerDuringCountSymbolFeatures: public QgsInte
QProgressDialog *mDialog = nullptr;
};

bool QgsVectorLayer::countSymbolFeatures()
QgsVectorLayerFeatureCounter *QgsVectorLayer::countSymbolFeatures()
{
if ( mSymbolFeatureCounted )
return true;
if ( mSymbolFeatureCounted || mFeatureCounter )
return mFeatureCounter;

mSymbolFeatureCountMap.clear();

if ( !mValid )
{
QgsDebugMsg( "invoked with invalid layer" );
return false;
return mFeatureCounter;
}
if ( !mDataProvider )
{
QgsDebugMsg( "invoked with null mDataProvider" );
return false;
return mFeatureCounter;
}
if ( !mRenderer )
{
QgsDebugMsg( "invoked with null mRenderer" );
return false;
return mFeatureCounter;
}

if ( !mFeatureCounter )
@@ -758,7 +758,7 @@ bool QgsVectorLayer::countSymbolFeatures()
QgsApplication::taskManager()->addTask( mFeatureCounter );
}

return true;
return mFeatureCounter;
}

void QgsVectorLayer::updateExtents( bool force )
@@ -836,16 +836,17 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte

/**
* Count features for symbols.
* The method will return immediately. You will need to connect to the
* symbolFeatureCountMapChanged() signal to be notified when the freshly updated
* feature counts are ready.
* The method will return the feature counter task. You will need to
* connect to the symbolFeatureCountMapChanged() signal to be
* notified when the freshly updated feature counts are ready.
*
* \note If you need to wait for the results, create and start your own QgsVectorLayerFeatureCounter
* task and call waitForFinished().
* \note If the count features for symbols has been already done a
* nullptr is returned. If you need to wait for the results,
* you can call waitForFinished() on the feature counter.
*
* \since This is asynchronous since QGIS 3.0
*/
bool countSymbolFeatures();
QgsVectorLayerFeatureCounter *countSymbolFeatures();

/**
* Set the string (typically sql) used to define a subset of the layer

0 comments on commit f88af6d

Please sign in to comment.
You can’t perform that action at this time.