Skip to content
Permalink
Browse files

Don't show OGR or GDAL entries for files in browser wherever another

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 cad2884e32567228091bd61147faaed1c39a4194
Showing with 19 additions and 0 deletions.
  1. +10 −0 src/core/providers/gdal/qgsgdaldataitems.cpp
  2. +9 −0 src/core/providers/ogr/qgsogrdataitems.cpp
@@ -24,6 +24,7 @@
#include "qgsproject.h"
#include "qgsgdalutils.h"
#include "qgsvectortiledataitems.h"
#include "qgsproviderregistry.h"
#include "symbology/qgsstyle.h"

#include <QFileInfo>
@@ -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
@@ -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

0 comments on commit cad2884

Please sign in to comment.
You can’t perform that action at this time.