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)
  • Loading branch information
nyalldawson committed Feb 26, 2019
1 parent 0a1d644 commit 8105905
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -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" ) )
Expand Down

0 comments on commit 8105905

Please sign in to comment.