Skip to content
Permalink
Browse files

Use a proxy task to show progress when dropping multiple layers to QGIS

  • Loading branch information
nyalldawson committed Aug 17, 2018
1 parent 0d20062 commit 54f4eefc45f01db4e60de9c9ac0c584727768b17
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/app/qgisapp.cpp
@@ -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 );

@@ -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() );
}

0 comments on commit 54f4eef

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