From 1b41377693c170abc4135980fcb21fcada3549e2 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Thu, 7 May 2020 11:52:49 +0300 Subject: [PATCH] add "All supported" file filter for OGR and GDAL providers allowing to view all supported file types at once (fix #13239) --- src/core/providers/gdal/qgsgdalprovider.cpp | 6 ++++++ src/core/providers/ogr/qgsogrprovider.cpp | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/providers/gdal/qgsgdalprovider.cpp b/src/core/providers/gdal/qgsgdalprovider.cpp index 4ecdf33777a0..aa00c9115ec3 100644 --- a/src/core/providers/gdal/qgsgdalprovider.cpp +++ b/src/core/providers/gdal/qgsgdalprovider.cpp @@ -2286,6 +2286,12 @@ void buildSupportedRasterFileFilterAndExtensions( QString &fileFiltersString, QS extensions << QStringLiteral( "zip" ) << QStringLiteral( "gz" ) << QStringLiteral( "tar" ) << QStringLiteral( "tar.gz" ) << QStringLiteral( "tgz" ); } + // can't forget the all supported case + QStringList exts; + for ( const QString &ext : qgis::as_const( extensions ) ) + exts << QStringLiteral( "*.%1 *.%2" ).arg( ext, ext.toUpper() ); + fileFiltersString.prepend( QObject::tr( "All supported files" ) + QStringLiteral( " (%1);;" ).arg( exts.join( QStringLiteral( " " ) ) ) ); + // can't forget the default case - first fileFiltersString.prepend( QObject::tr( "All files" ) + " (*);;" ); diff --git a/src/core/providers/ogr/qgsogrprovider.cpp b/src/core/providers/ogr/qgsogrprovider.cpp index 9e0756635e1a..9362dc3df9d7 100644 --- a/src/core/providers/ogr/qgsogrprovider.cpp +++ b/src/core/providers/ogr/qgsogrprovider.cpp @@ -3306,12 +3306,18 @@ QString createFilters( const QString &type ) { sFileFilters.prepend( createFileFilter_( QObject::tr( "GDAL/OGR VSIFileHandler" ), QStringLiteral( "*.zip *.gz *.tar *.tar.gz *.tgz" ) ) ); sExtensions << QStringLiteral( "zip" ) << QStringLiteral( "gz" ) << QStringLiteral( "tar" ) << QStringLiteral( "tar.gz" ) << QStringLiteral( "tgz" ); - } + // can't forget the all supported case + QStringList exts; + for ( const QString &ext : qgis::as_const( sExtensions ) ) + exts << QStringLiteral( "*.%1 *.%2" ).arg( ext, ext.toUpper() ); + sFileFilters.prepend( QObject::tr( "All supported files" ) + QStringLiteral( " (%1);;" ).arg( exts.join( QStringLiteral( " " ) ) ) ); + // can't forget the default case - first sFileFilters.prepend( QObject::tr( "All files" ) + " (*);;" ); + // cleanup if ( sFileFilters.endsWith( QLatin1String( ";;" ) ) ) sFileFilters.chop( 2 );