Skip to content
Permalink
Browse files
[ui] Adopt ogr remote layer addition's loading message bar in gdal to…
…o instead of merely freezing the interface for 15sec
  • Loading branch information
nirvn authored and nyalldawson committed Nov 10, 2021
1 parent dc6d932 commit 4316d96f392bd0a5a192d1ad7a8110b29f847e08
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/app/qgisapp.cpp
@@ -16060,6 +16060,18 @@ bool QgisApp::addRasterLayers( QStringList const &files, bool guiWarning )
continue;
}

const bool isVsiCurl { src.startsWith( QLatin1String( "/vsicurl" ), Qt::CaseInsensitive ) };
const auto scheme { QUrl( src ).scheme() };
const bool isRemoteUrl { src.startsWith( QLatin1String( "http" ) ) || src == QLatin1String( "ftp" ) };

std::unique_ptr< QgsTemporaryCursorOverride > cursorOverride;
if ( isVsiCurl || isRemoteUrl )
{
cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
visibleMessageBar()->pushInfo( tr( "Remote layer" ), tr( "loading %1, please wait …" ).arg( src ) );
qApp->processEvents();
}

if ( QgsRasterLayer::isValidRasterFileName( src, errMsg ) )
{
QFileInfo myFileInfo( src );
@@ -16077,6 +16089,7 @@ bool QgisApp::addRasterLayers( QStringList const &files, bool guiWarning )
}

// try to create the layer
cursorOverride.reset();
QgsRasterLayer *layer = addLayerPrivate< QgsRasterLayer >( QgsMapLayerType::RasterLayer, src, layerName, QStringLiteral( "gdal" ), guiWarning );

if ( layer && layer->isValid() )

0 comments on commit 4316d96

Please sign in to comment.