Skip to content
Permalink
Browse files

[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)
  • Loading branch information
nyalldawson committed Feb 26, 2019
1 parent 0a1d644 commit 8105905189e34f862a9cdb0d3c5f32b4ad1d4c49
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/providers/ogr/qgsogrdataitems.cpp
@@ -672,12 +672,20 @@ QgsDataItem *QgsOgrDataItemProvider::createDataItem( const QString &pathIn, QgsD
QStringLiteral( "db" ),
QStringLiteral( "gdb" ) };

// these extensions are trivial to read, so there's no need to rely on
// the extension only scan here -- avoiding it always gives us the correct data type
// and sublayer visiblity
static QStringList sSkipFastTrackExtensions { QStringLiteral( "xlsx" ),
QStringLiteral( "ods" ),
QStringLiteral( "csv" ),
QStringLiteral( "nc" ) };

// Fast track: return item without testing if:
// scanExtSetting or zipfile and scan zip == "Basic scan"
// netCDF files can be both raster or vector, so fallback to opening
if ( ( scanExtSetting ||
( ( is_vsizip || is_vsitar ) && scanZipSetting == QLatin1String( "basic" ) ) ) &&
suffix != QLatin1String( "nc" ) )
!sSkipFastTrackExtensions.contains( suffix ) )
{
// if this is a VRT file make sure it is vector VRT to avoid duplicates
if ( suffix == QLatin1String( "vrt" ) )

0 comments on commit 8105905

Please sign in to comment.
You can’t perform that action at this time.