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)

(cherry picked from commit 8105905)
  • Loading branch information
nyalldawson committed Mar 7, 2019
1 parent bb7762c commit f0094ea4d282899d9b13f004031c0f381b2f3390
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/providers/ogr/qgsogrdataitems.cpp
@@ -714,12 +714,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 f0094ea

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