mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[Geometry snapper] Fix progress bar not working
This commit is contained in:
parent
7afdecd0b6
commit
b00950b9d6
@ -49,11 +49,13 @@ QgsGeometrySnapper::QgsGeometrySnapper( QgsVectorLayer *adjustLayer, QgsVectorLa
|
||||
|
||||
QFuture<void> QgsGeometrySnapper::processFeatures()
|
||||
{
|
||||
emit progressRangeChanged( 0, mFeatures.size() );
|
||||
return QtConcurrent::map( mFeatures, ProcessFeatureWrapper( this ) );
|
||||
}
|
||||
|
||||
void QgsGeometrySnapper::processFeature( QgsFeatureId id )
|
||||
{
|
||||
emit progressStep();
|
||||
// Get current feature
|
||||
QgsFeature feature;
|
||||
if ( !getFeature( mAdjustLayer, mAdjustLayerMutex, id, feature ) )
|
||||
|
@ -35,6 +35,10 @@ class QgsGeometrySnapper : public QObject
|
||||
QFuture<void> processFeatures();
|
||||
const QStringList& getErrors() const { return mErrors; }
|
||||
|
||||
signals:
|
||||
void progressRangeChanged( int min, int max );
|
||||
void progressStep();
|
||||
|
||||
private:
|
||||
struct ProcessFeatureWrapper
|
||||
{
|
||||
|
@ -280,8 +280,6 @@ void QgsGeometrySnapperDialog::run()
|
||||
/** Run **/
|
||||
QEventLoop evLoop;
|
||||
QFutureWatcher<void> futureWatcher;
|
||||
connect( &futureWatcher, SIGNAL( progressRangeChanged( int, int ) ), progressBar, SLOT( setRange( int, int ) ) );
|
||||
connect( &futureWatcher, SIGNAL( progressValueChanged( int ) ), progressBar, SLOT( setValue( int ) ) );
|
||||
connect( &futureWatcher, SIGNAL( finished() ), &evLoop, SLOT( quit() ) );
|
||||
connect( buttonBox->button( QDialogButtonBox::Abort ), SIGNAL( clicked() ), &futureWatcher, SLOT( cancel() ) );
|
||||
|
||||
@ -294,6 +292,8 @@ void QgsGeometrySnapperDialog::run()
|
||||
widgetInputs->setEnabled( false );
|
||||
|
||||
QgsGeometrySnapper snapper( layer, referenceLayer, selectedOnly, doubleSpinBoxMaxDistance->value(), &mIface->mapCanvas()->mapSettings() );
|
||||
connect( &snapper, SIGNAL( progressRangeChanged( int, int ) ), progressBar, SLOT( setRange( int, int ) ) );
|
||||
connect( &snapper, SIGNAL( progressStep() ), this, SLOT( progressStep() ) );
|
||||
futureWatcher.setFuture( snapper.processFeatures() );
|
||||
evLoop.exec();
|
||||
|
||||
@ -317,3 +317,8 @@ void QgsGeometrySnapperDialog::run()
|
||||
hide() ;
|
||||
}
|
||||
|
||||
void QgsGeometrySnapperDialog::progressStep()
|
||||
{
|
||||
progressBar->setValue( progressBar->value() + 1 );
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ class QgsGeometrySnapperDialog: public QDialog, private Ui::QgsGeometrySnapperDi
|
||||
void updateLayers();
|
||||
void validateInput();
|
||||
void selectOutputFile();
|
||||
void progressStep();
|
||||
};
|
||||
|
||||
#endif // QGS_GEOMETRY_SNAPPER_DIALOG_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user