Skip to content

Commit

Permalink
Use progress progress task for identify tool progress
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 20, 2018
1 parent c7845dd commit 485803d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/app/qgsmaptoolidentifyaction.cpp
Expand Up @@ -38,6 +38,7 @@
#include "qgsunittypes.h"
#include "qgsstatusbar.h"
#include "qgsactionscoperegistry.h"
#include "qgsproxyprogresstask.h"

#include "qgssettings.h"
#include <QMouseEvent>
Expand Down Expand Up @@ -111,7 +112,14 @@ void QgsMapToolIdentifyAction::showAttributeTable( QgsMapLayer *layer, const QLi
void QgsMapToolIdentifyAction::identifyFromGeometry()
{
resultsDialog()->clear();
connect( this, &QgsMapToolIdentifyAction::identifyProgress, QgisApp::instance(), &QgisApp::showProgress );

QgsProxyProgressTask *task = new QgsProxyProgressTask( tr( "Identifying features" ) );
QgsApplication::taskManager()->addTask( task );

connect( this, &QgsMapToolIdentifyAction::identifyProgress, task, [ = ]( int i, int n )
{
task->setProxyProgress( static_cast<double>( i ) * 100.0 / n );
} );
connect( this, &QgsMapToolIdentifyAction::identifyMessage, QgisApp::instance(), &QgisApp::showStatusMessage );

QgsGeometry geometry = mSelectionHandler->selectedGeometry();
Expand All @@ -131,7 +139,7 @@ void QgsMapToolIdentifyAction::identifyFromGeometry()

QList<IdentifyResult> results = QgsMapToolIdentify::identify( geometry, mode, AllLayers );

disconnect( this, &QgsMapToolIdentifyAction::identifyProgress, QgisApp::instance(), &QgisApp::showProgress );
task->finalize( true );
disconnect( this, &QgsMapToolIdentifyAction::identifyMessage, QgisApp::instance(), &QgisApp::showStatusMessage );

if ( results.isEmpty() )
Expand Down

0 comments on commit 485803d

Please sign in to comment.