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

This commit is contained in:
Nyall Dawson 2018-08-17 12:30:31 +10:00
parent 0d200623b1
commit 54f4eefc45

View File

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