Skip to content

Commit

Permalink
[browser] Always open xlsx/csv/ods files as layers, instead of just
Browse files Browse the repository at this point in the history
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 f0094ea
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -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" ) )
Expand Down

0 comments on commit f0094ea

Please sign in to comment.