Skip to content

Commit

Permalink
Don't show OGR or GDAL entries for files in browser wherever another
Browse files Browse the repository at this point in the history
provider is the preferred provider for a particular file

In particular, this allows us to hide the OGR entry for ept.json
files in the browser, so that instead we ONLY see an entry for the
EPT point cloud provider for these files. (Besides being clutter,
the OGR item for the ept.json file cannot be opened as a vector
layer so is just noise!)

(In the rare chance that a user DOES need to open a geojson file called
"ept.json" they can still do this easily via the Data Source Manager)
  • Loading branch information
nyalldawson committed Nov 5, 2020
1 parent 8abe4a1 commit cad2884
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/providers/gdal/qgsgdaldataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "qgsproject.h"
#include "qgsgdalutils.h"
#include "qgsvectortiledataitems.h"
#include "qgsproviderregistry.h"
#include "symbology/qgsstyle.h"

#include <QFileInfo>
Expand Down Expand Up @@ -144,6 +145,15 @@ QgsDataItem *QgsGdalDataItemProvider::createDataItem( const QString &pathIn, Qgs
if ( path.isEmpty() )
return nullptr;

// if another provider has preference for this path, let it win. This allows us to hide known files
// more strongly associated with another provider from showing duplicate entries for the ogr provider.
// e.g. in particular this hides "ept.json" files from showing as a non-functional ogr data item, and
// instead ONLY shows them as the functional EPT point cloud provider items
if ( QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( path, QStringLiteral( "gdal" ) ) )
{
return nullptr;
}

QgsDebugMsgLevel( "thePath = " + path, 2 );

// zip settings + info
Expand Down
9 changes: 9 additions & 0 deletions src/core/providers/ogr/qgsogrdataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,15 @@ QgsDataItem *QgsOgrDataItemProvider::createDataItem( const QString &pathIn, QgsD
if ( path.isEmpty() )
return nullptr;

// if another provider has preference for this path, let it win. This allows us to hide known files
// more strongly associated with another provider from showing duplicate entries for the ogr provider.
// e.g. in particular this hides "ept.json" files from showing as a non-functional ogr data item, and
// instead ONLY shows them as the functional EPT point cloud provider items
if ( QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( path, QStringLiteral( "ogr" ) ) )
{
return nullptr;
}

QgsDebugMsgLevel( "thePath: " + path, 2 );

// zip settings + info
Expand Down

0 comments on commit cad2884

Please sign in to comment.