Skip to content
Permalink
Browse files

Default point cloud file picker from data source manager to filtering

for ALL supported point cloud files, regardless of provider
  • Loading branch information
nyalldawson committed Nov 5, 2020
1 parent d51e752 commit caed02ac095f8a35af447586276bda4ad8982b30
Showing with 29 additions and 4 deletions.
  1. +19 −4 src/core/qgsproviderregistry.cpp
  2. +10 −0 tests/src/python/test_qgsproviderregistry.py
@@ -38,6 +38,7 @@
#include "providers/meshmemory/qgsmeshmemorydataprovider.h"
#include "providers/ept/qgseptprovider.h"
#include "qgsruntimeprofiler.h"
#include "qgsfileutils.h"

#ifdef HAVE_STATIC_PROVIDERS
#include "qgswmsprovider.h"
@@ -250,6 +251,9 @@ void QgsProviderRegistry::init()
#endif
QgsDebugMsg( QStringLiteral( "Loaded %1 providers (%2) " ).arg( mProviders.size() ).arg( providerList().join( ';' ) ) );

QStringList pointCloudWildcards;
QStringList pointCloudFilters;

// now initialize all providers
for ( Providers::const_iterator it = mProviders.begin(); it != mProviders.end(); ++it )
{
@@ -297,16 +301,27 @@ void QgsProviderRegistry::init()
if ( !filePointCloudFilters.isEmpty() )
{
QgsDebugMsgLevel( "point cloud filters: " + filePointCloudFilters, 2 );
if ( !mPointCloudFileFilters.isEmpty() && !mPointCloudFileFilters.endsWith( QLatin1String( ";;" ) ) )
mPointCloudFileFilters += QStringLiteral( ";;" );
mPointCloudFileFilters += filePointCloudFilters;
QgsDebugMsgLevel( QStringLiteral( "Checking %1: ...loaded OK (%2 file filters)" ).arg( key ).arg( filePointCloudFilters.split( ";;" ).count() ), 2 );

#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList filters = filePointCloudFilters.split( QStringLiteral( ";;" ), QString::SkipEmptyParts );
#else
const QStringList filters = filePointCloudFilters.split( QStringLiteral( ";;" ), Qt::SkipEmptyParts );
#endif
for ( const QString &filter : filters )
{
pointCloudFilters.append( filter );
pointCloudWildcards.append( QgsFileUtils::wildcardsFromFilter( filter ).split( ' ' ) );
}
}

// call initProvider() - allows provider to register its services to QGIS
meta->initProvider();
}

pointCloudFilters.insert( 0, QObject::tr( "All Supported Files" ) + QStringLiteral( " (%1)" ).arg( pointCloudWildcards.join( ' ' ) ) );
pointCloudFilters.insert( 1, QObject::tr( "All Files" ) + QStringLiteral( " (*.*)" ) );
mPointCloudFileFilters = pointCloudFilters.join( QStringLiteral( ";;" ) );

// load database drivers (only OGR)
mDatabaseDrivers = QgsOgrProviderUtils::databaseDrivers();

@@ -79,6 +79,16 @@ def testUriIsBlocklisted(self):
self.assertTrue(QgsProviderRegistry.instance().uriIsBlocklisted('/home/nyall/me.png.aux.xml'))
self.assertTrue(QgsProviderRegistry.instance().uriIsBlocklisted('/home/nyall/me.tif.xml'))

def testFilePointCloudFilters(self):
parts = QgsProviderRegistry.instance().filePointCloudFilters().split(';;')
self.assertTrue(parts[0].startswith('All Supported Files ('))
all_filter = parts[0][21:-1]
self.assertIn('ept.json', all_filter.split(' '))
self.assertIn('EPT.JSON', all_filter.split(' '))

self.assertEqual(parts[1], 'All Files (*.*)')
self.assertIn('Entwine Point Clouds (ept.json EPT.JSON)', parts)


if __name__ == '__main__':
unittest.main()

0 comments on commit caed02a

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