Skip to content
Permalink
Browse files

Use provider metadata to filter data items for ept provider

  • Loading branch information
nyalldawson committed Nov 4, 2020
1 parent 74722b3 commit b4d381de7a1f7abaa8749339c7088a60061af38e
Showing with 18 additions and 4 deletions.
  1. +11 −4 src/core/providers/ept/qgseptdataitems.cpp
  2. +7 −0 src/core/providers/ept/qgseptdataitems.h
@@ -18,6 +18,9 @@
#include "qgseptdataitems.h"
#include "qgslogger.h"
#include "qgssettings.h"
#include "qgsproviderregistry.h"
#include "qgsprovidermetadata.h"
#include "qgsfileutils.h"

#include <QFileInfo>
#include <mutex>
@@ -39,6 +42,12 @@ QString QgsEptLayerItem::layerName() const
}

// ---------------------------------------------------------------------------
QgsEptDataItemProvider::QgsEptDataItemProvider()
{
QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ept" ) );
mFileFilter = metadata->filters( QgsProviderMetadata::FilterType::FilterPointCloud );
}

QString QgsEptDataItemProvider::name()
{
return QStringLiteral( "ept" );
@@ -56,16 +65,14 @@ QgsDataItem *QgsEptDataItemProvider::createDataItem( const QString &path, QgsDat

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

// get suffix, removing .gz if present
QFileInfo info( path );
info.setFile( path );
const QFileInfo info( path );

// allow only normal files
if ( !info.isFile() )
return nullptr;

// Filter files by extension
if ( !path.endsWith( QStringLiteral( "ept.json" ) ) )
if ( !QgsFileUtils::fileMatchesFilter( path, mFileFilter ) )
return nullptr;

QString name = info.dir().dirName();
@@ -38,11 +38,18 @@ class CORE_EXPORT QgsEptLayerItem : public QgsLayerItem
class QgsEptDataItemProvider : public QgsDataItemProvider
{
public:

QgsEptDataItemProvider();

QString name() override;

int capabilities() const override;

QgsDataItem *createDataItem( const QString &pathIn, QgsDataItem *parentItem ) override;

private:

QString mFileFilter;
};

///@endcond

0 comments on commit b4d381d

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