Skip to content

Commit 8105905

Browse files
committed
[browser] Always open xlsx/csv/ods files as layers, instead of just
checking the file extension (by default) These formats are inexpensive to open, and doing so allows browser to display all sheets from the files in the tree (and gives correct 'no geometry' icon for the file)
1 parent 0a1d644 commit 8105905

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/providers/ogr/qgsogrdataitems.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -672,12 +672,20 @@ QgsDataItem *QgsOgrDataItemProvider::createDataItem( const QString &pathIn, QgsD
672672
QStringLiteral( "db" ),
673673
QStringLiteral( "gdb" ) };
674674

675+
// these extensions are trivial to read, so there's no need to rely on
676+
// the extension only scan here -- avoiding it always gives us the correct data type
677+
// and sublayer visiblity
678+
static QStringList sSkipFastTrackExtensions { QStringLiteral( "xlsx" ),
679+
QStringLiteral( "ods" ),
680+
QStringLiteral( "csv" ),
681+
QStringLiteral( "nc" ) };
682+
675683
// Fast track: return item without testing if:
676684
// scanExtSetting or zipfile and scan zip == "Basic scan"
677685
// netCDF files can be both raster or vector, so fallback to opening
678686
if ( ( scanExtSetting ||
679687
( ( is_vsizip || is_vsitar ) && scanZipSetting == QLatin1String( "basic" ) ) ) &&
680-
suffix != QLatin1String( "nc" ) )
688+
!sSkipFastTrackExtensions.contains( suffix ) )
681689
{
682690
// if this is a VRT file make sure it is vector VRT to avoid duplicates
683691
if ( suffix == QLatin1String( "vrt" ) )

0 commit comments

Comments
 (0)