Skip to content

Commit ac6eaa8

Browse files
nyalldawsonelpaso
authored andcommittedSep 19, 2017
Correctly handle opening gdb directories as a database in browser
Allows ESRI gdb directories to be accessed and the contained layers to be visible and added to projects.
1 parent ca0fea7 commit ac6eaa8

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed
 

‎src/providers/gdal/qgsgdaldataitems.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )
251251
// class
252252
// TODO: add more OGR supported multiple layers formats here!
253253
QStringList ogrSupportedDbLayersExtensions;
254-
ogrSupportedDbLayersExtensions << QLatin1String( "gpkg" ) << QLatin1String( "sqlite" ) << QLatin1String( "db" );
254+
ogrSupportedDbLayersExtensions << QLatin1String( "gpkg" ) << QLatin1String( "sqlite" ) << QLatin1String( "db" ) << QLatin1String( "gdb" );
255255
QStringList ogrSupportedDbDriverNames;
256-
ogrSupportedDbDriverNames << QLatin1String( "GPKG" ) << QLatin1String( "db" );
256+
ogrSupportedDbDriverNames << QLatin1String( "GPKG" ) << QLatin1String( "db" ) << QLatin1String( "gdb" );
257257

258258
// return item without testing if:
259259
// scanExtSetting

‎src/providers/ogr/qgsogrdataitems.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
// these are defined in qgsogrprovider.cpp
4040
QGISEXTERN QStringList fileExtensions();
41+
QGISEXTERN QStringList directoryExtensions();
4142
QGISEXTERN QStringList wildcards();
4243

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

509-
// allow only normal files or VSIFILE items to continue
510-
if ( !info.isFile() && vsiPrefix == QLatin1String( "" ) )
511-
return nullptr;
512-
513510
QStringList myExtensions = fileExtensions();
511+
QStringList dirExtensions = directoryExtensions();
512+
513+
// allow only normal files, supported directories, or VSIFILE items to continue
514+
bool isOgrSupportedDirectory = info.isDir() && dirExtensions.contains( suffix );
515+
if ( !isOgrSupportedDirectory && !info.isFile() && vsiPrefix == QLatin1String( "" ) )
516+
return nullptr;
514517

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

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.