Navigation Menu

Skip to content

Commit

Permalink
[ui] Adopt ogr remote layer addition's loading message bar in gdal to…
Browse files Browse the repository at this point in the history
…o instead of merely freezing the interface for 15sec
  • Loading branch information
nirvn authored and nyalldawson committed Nov 10, 2021
1 parent dc6d932 commit 4316d96
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -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 );
Expand All @@ -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() )
Expand Down

0 comments on commit 4316d96

Please sign in to comment.