@@ -4667,13 +4667,25 @@ bool QgisApp::addVectorLayers( const QStringList &layerQStringList, const QStrin
4667
4667
4668
4668
QgsDebugMsgLevel( "completeBaseName: " + baseName, 2 );
4669
4669
4670
- // create the layer
4670
+ const bool isVsiCurl { src.startsWith( QLatin1String( "/vsicurl", Qt::CaseInsensitive ) ) };
4671
+ const auto scheme { QUrl( src ).scheme() };
4672
+ const bool isRemoteUrl { scheme.startsWith( QStringLiteral( "http" ) ) || scheme == QStringLiteral( "ftp" ) };
4671
4673
4674
+ // create the layer
4672
4675
QgsVectorLayer::LayerOptions options;
4673
4676
options.loadDefaultStyle = false;
4677
+ if ( isVsiCurl || isRemoteUrl )
4678
+ {
4679
+ visibleMessageBar()->pushInfo( tr( "Remote layer" ), tr( "loading %1, please wait …" ).arg( src ) );
4680
+ QApplication::setOverrideCursor( Qt::WaitCursor );
4681
+ qApp->processEvents();
4682
+ }
4674
4683
QgsVectorLayer *layer = new QgsVectorLayer( src, baseName, QStringLiteral( "ogr" ), options );
4675
4684
Q_CHECK_PTR( layer );
4676
-
4685
+ if ( isVsiCurl || isRemoteUrl )
4686
+ {
4687
+ QApplication::restoreOverrideCursor( );
4688
+ }
4677
4689
if ( ! layer )
4678
4690
{
4679
4691
freezeCanvases( false );
@@ -4723,9 +4735,9 @@ bool QgisApp::addVectorLayers( const QStringList &layerQStringList, const QStrin
4723
4735
delete layer;
4724
4736
QString msg = tr( "%1 is not a valid or recognized data source." ).arg( src );
4725
4737
// If the failed layer was a vsicurl type, give the user a chance to try the normal download.
4726
- if ( src.startsWith( QLatin1String( "/vsicurl" ), Qt::CaseInsensitive ) &&
4738
+ if ( isVsiCurl &&
4727
4739
QMessageBox::question( this, tr( "Invalid Data Source" ),
4728
- tr( "The \"protocol \" source type failed, do you want to try the \"file\" type?" ) ) == QMessageBox::Yes )
4740
+ tr( "Download with \"Protocol \" source type has failed, do you want to try the \"File\" source type?" ) ) == QMessageBox::Yes )
4729
4741
{
4730
4742
return addVectorLayers( QStringList() << src.replace( QLatin1String( "/vsicurl/" ), " " ), enc, dataSourceType );
4731
4743
}
0 commit comments