Skip to content
Permalink
Browse files

[Geometry snapper] Fix progress bar not working

  • Loading branch information
manisandro committed Jan 21, 2016
1 parent 7afdecd commit b00950b9d63c79c00635461271a5509601c5fb45
@@ -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

0 comments on commit b00950b

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