Skip to content

Commit

Permalink
Correctly handle opening gdb directories as a database in browser
Browse files Browse the repository at this point in the history
Allows ESRI gdb directories to be accessed and the contained
layers to be visible and added to projects.
  • Loading branch information
nyalldawson authored and elpaso committed Sep 19, 2017
1 parent ca0fea7 commit ac6eaa8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/providers/gdal/qgsgdaldataitems.cpp
Expand Up @@ -251,9 +251,9 @@ QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )
// class
// TODO: add more OGR supported multiple layers formats here!
QStringList ogrSupportedDbLayersExtensions;
ogrSupportedDbLayersExtensions << QLatin1String( "gpkg" ) << QLatin1String( "sqlite" ) << QLatin1String( "db" );
ogrSupportedDbLayersExtensions << QLatin1String( "gpkg" ) << QLatin1String( "sqlite" ) << QLatin1String( "db" ) << QLatin1String( "gdb" );
QStringList ogrSupportedDbDriverNames;
ogrSupportedDbDriverNames << QLatin1String( "GPKG" ) << QLatin1String( "db" );
ogrSupportedDbDriverNames << QLatin1String( "GPKG" ) << QLatin1String( "db" ) << QLatin1String( "gdb" );

// return item without testing if:
// scanExtSetting
Expand Down
17 changes: 10 additions & 7 deletions src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -38,6 +38,7 @@

// these are defined in qgsogrprovider.cpp
QGISEXTERN QStringList fileExtensions();
QGISEXTERN QStringList directoryExtensions();
QGISEXTERN QStringList wildcards();

QGISEXTERN bool deleteLayer( const QString &uri, const QString &errCause );
Expand Down Expand Up @@ -506,11 +507,13 @@ QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )
QgsDebugMsgLevel( "thePath= " + path + " tmpPath= " + tmpPath + " name= " + name
+ " suffix= " + suffix + " vsiPrefix= " + vsiPrefix, 3 );

// allow only normal files or VSIFILE items to continue
if ( !info.isFile() && vsiPrefix == QLatin1String( "" ) )
return nullptr;

QStringList myExtensions = fileExtensions();
QStringList dirExtensions = directoryExtensions();

// allow only normal files, supported directories, or VSIFILE items to continue
bool isOgrSupportedDirectory = info.isDir() && dirExtensions.contains( suffix );
if ( !isOgrSupportedDirectory && !info.isFile() && vsiPrefix == QLatin1String( "" ) )
return nullptr;

// skip *.aux.xml files (GDAL auxiliary metadata files),
// *.shp.xml files (ESRI metadata) and *.tif.xml files (TIFF metadata)
Expand All @@ -527,7 +530,7 @@ QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )

// We have to filter by extensions, otherwise e.g. all Shapefile files are displayed
// because OGR drive can open also .dbf, .shx.
if ( myExtensions.indexOf( suffix ) < 0 )
if ( myExtensions.indexOf( suffix ) < 0 && !dirExtensions.contains( suffix ) )
{
bool matches = false;
Q_FOREACH ( const QString &wildcard, wildcards() )
Expand Down Expand Up @@ -577,9 +580,9 @@ QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )
// class
// TODO: add more OGR supported multiple layers formats here!
QStringList ogrSupportedDbLayersExtensions;
ogrSupportedDbLayersExtensions << QLatin1String( "gpkg" ) << QLatin1String( "sqlite" ) << QLatin1String( "db" );
ogrSupportedDbLayersExtensions << QLatin1String( "gpkg" ) << QLatin1String( "sqlite" ) << QLatin1String( "db" ) << QStringLiteral( "gdb" );
QStringList ogrSupportedDbDriverNames;
ogrSupportedDbDriverNames << QLatin1String( "GPKG" ) << QLatin1String( "db" );
ogrSupportedDbDriverNames << QLatin1String( "GPKG" ) << QLatin1String( "db" ) << QStringLiteral( "gdb" );

// Fast track: return item without testing if:
// scanExtSetting or zipfile and scan zip == "Basic scan"
Expand Down

0 comments on commit ac6eaa8

Please sign in to comment.