Skip to content

Commit 54f4eef

Browse files
committedAug 17, 2018
Use a proxy task to show progress when dropping multiple layers to QGIS
1 parent 0d20062 commit 54f4eef

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,8 +1712,12 @@ void QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst )
17121712
// added all layers, and only emit the signal once for the final layer added
17131713
mBlockActiveLayerChanged = true;
17141714

1715+
QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Loading layers" ) );
1716+
QgsApplication::taskManager()->addTask( proxyTask );
1717+
17151718
// insert items in reverse order as each one is inserted on top of previous one
1716-
for ( int i = lst.size() - 1 ; i >= 0 ; i-- )
1719+
int count = 0;
1720+
for ( int i = lst.size() - 1 ; i >= 0 ; i--, count++ )
17171721
{
17181722
const QgsMimeDataUtils::Uri &u = lst.at( i );
17191723

@@ -1751,8 +1755,12 @@ void QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst )
17511755
{
17521756
openFile( u.uri, QStringLiteral( "project" ) );
17531757
}
1758+
1759+
proxyTask->setProxyProgress( 100.0 * static_cast< double >( count ) / lst.size() );
17541760
}
17551761

1762+
proxyTask->finalize( true );
1763+
17561764
mBlockActiveLayerChanged = false;
17571765
emit activeLayerChanged( activeLayer() );
17581766
}

0 commit comments

Comments
 (0)
Please sign in to comment.