mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Fix compatibility with older sip versions
This commit is contained in:
parent
964d9ac70a
commit
05a713f444
@ -31,8 +31,13 @@ class QgsVectorLayerFeatureCounter : QgsTask
|
||||
|
||||
virtual bool run();
|
||||
|
||||
|
||||
signals:
|
||||
void symbolsCounted( const QHash<QString, long> &symbolFeatureCountMap );
|
||||
|
||||
void symbolsCounted();
|
||||
%Docstring
|
||||
Emitted when the symbols have been counted.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
@ -135,6 +135,7 @@ QgsSymbolLegendNode::QgsSymbolLegendNode( QgsLayerTreeLayer *nodeLayer, const Qg
|
||||
, mIconSize( 16, 16 )
|
||||
{
|
||||
updateLabel();
|
||||
connect( qobject_cast<QgsVectorLayer*>( nodeLayer->layer() ), &QgsVectorLayer::symbolFeatureCountMapChanged, this, &QgsSymbolLegendNode::updateLabel );
|
||||
|
||||
if ( mItem.symbol() )
|
||||
mSymbolUsesMapUnits = ( mItem.symbol()->outputUnit() != QgsUnitTypes::RenderMillimeters );
|
||||
|
@ -702,12 +702,12 @@ bool QgsVectorLayer::countSymbolFeatures()
|
||||
|
||||
if ( !mFeatureCounter )
|
||||
{
|
||||
mFeatureCounter.reset( new QgsVectorLayerFeatureCounter( this ) );
|
||||
connect( mFeatureCounter.get(), &QgsVectorLayerFeatureCounter::symbolsCounted, this, &QgsVectorLayer::onSymbolsCounted );
|
||||
connect( mFeatureCounter.get(), &QgsTask::taskCompleted, [ = ]() { mFeatureCounter.reset(); } );
|
||||
connect( mFeatureCounter.get(), &QgsTask::taskTerminated, [ = ]() { mFeatureCounter.reset(); } );
|
||||
mFeatureCounter = new QgsVectorLayerFeatureCounter( this );
|
||||
connect( mFeatureCounter, &QgsVectorLayerFeatureCounter::symbolsCounted, this, &QgsVectorLayer::onSymbolsCounted );
|
||||
connect( mFeatureCounter, &QgsTask::taskCompleted, [ = ]() { mFeatureCounter = nullptr; } );
|
||||
connect( mFeatureCounter, &QgsTask::taskTerminated, [ = ]() { mFeatureCounter = nullptr; } );
|
||||
|
||||
QgsApplication::taskManager()->addTask( mFeatureCounter.get() );
|
||||
QgsApplication::taskManager()->addTask( mFeatureCounter );
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -3899,11 +3899,14 @@ void QgsVectorLayer::onRelationsLoaded()
|
||||
mEditFormConfig.onRelationsLoaded();
|
||||
}
|
||||
|
||||
void QgsVectorLayer::onSymbolsCounted( const QHash<QString, long> &symbolFeatureCountMap )
|
||||
void QgsVectorLayer::onSymbolsCounted()
|
||||
{
|
||||
mSymbolFeatureCountMap = symbolFeatureCountMap;
|
||||
mSymbolFeatureCounted = true;
|
||||
emit symbolFeatureCountMapChanged();
|
||||
if ( mFeatureCounter )
|
||||
{
|
||||
mSymbolFeatureCountMap = mFeatureCounter->symbolFeatureCountMap();
|
||||
mSymbolFeatureCounted = true;
|
||||
emit symbolFeatureCountMapChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QList<QgsRelation> QgsVectorLayer::referencingRelations( int idx ) const
|
||||
|
@ -1858,7 +1858,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
void onJoinedFieldsChanged();
|
||||
void onFeatureDeleted( QgsFeatureId fid );
|
||||
void onRelationsLoaded();
|
||||
void onSymbolsCounted( const QHash<QString, long> &symbolFeatureCountMap );
|
||||
void onSymbolsCounted();
|
||||
|
||||
protected:
|
||||
//! Set the extent
|
||||
@ -2008,7 +2008,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
|
||||
mutable QMutex mFeatureSourceConstructorMutex;
|
||||
|
||||
std::unique_ptr<QgsVectorLayerFeatureCounter> mFeatureCounter;
|
||||
QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
|
||||
|
||||
friend class QgsVectorLayerFeatureSource;
|
||||
};
|
||||
|
@ -64,6 +64,11 @@ bool QgsVectorLayerFeatureCounter::run()
|
||||
mRenderer->stopRender( renderContext );
|
||||
setProgress( 100 );
|
||||
|
||||
emit symbolsCounted( mSymbolFeatureCountMap );
|
||||
emit symbolsCounted();
|
||||
return true;
|
||||
}
|
||||
|
||||
QHash<QString, long> QgsVectorLayerFeatureCounter::symbolFeatureCountMap() const
|
||||
{
|
||||
return mSymbolFeatureCountMap;
|
||||
}
|
||||
|
@ -28,8 +28,20 @@ class CORE_EXPORT QgsVectorLayerFeatureCounter : public QgsTask
|
||||
|
||||
virtual bool run() override;
|
||||
|
||||
/**
|
||||
* Get the count for each symbol. Only valid after the symbolsCounted()
|
||||
* signal has been emitted.
|
||||
*
|
||||
* \note Not available in Python bindings.
|
||||
*/
|
||||
QHash<QString, long> symbolFeatureCountMap() const SIP_SKIP;
|
||||
|
||||
signals:
|
||||
void symbolsCounted( const QHash<QString, long> &symbolFeatureCountMap );
|
||||
|
||||
/**
|
||||
* Emitted when the symbols have been counted.
|
||||
*/
|
||||
void symbolsCounted();
|
||||
|
||||
private:
|
||||
std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
|
||||
|
Loading…
x
Reference in New Issue
Block a user