Skip to content

Commit

Permalink
Use a proxy task to show progress when dropping multiple layers to QGIS
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 17, 2018
1 parent 0d20062 commit 54f4eef
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -1712,8 +1712,12 @@ void QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst )
// added all layers, and only emit the signal once for the final layer added
mBlockActiveLayerChanged = true;

QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Loading layers" ) );
QgsApplication::taskManager()->addTask( proxyTask );

// insert items in reverse order as each one is inserted on top of previous one
for ( int i = lst.size() - 1 ; i >= 0 ; i-- )
int count = 0;
for ( int i = lst.size() - 1 ; i >= 0 ; i--, count++ )
{
const QgsMimeDataUtils::Uri &u = lst.at( i );

Expand Down Expand Up @@ -1751,8 +1755,12 @@ void QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst )
{
openFile( u.uri, QStringLiteral( "project" ) );
}

proxyTask->setProxyProgress( 100.0 * static_cast< double >( count ) / lst.size() );
}

proxyTask->finalize( true );

mBlockActiveLayerChanged = false;
emit activeLayerChanged( activeLayer() );
}
Expand Down

0 comments on commit 54f4eef

Please sign in to comment.