Navigation Menu

Skip to content

Commit

Permalink
add "All supported" file filter for OGR and GDAL providers allowing to
Browse files Browse the repository at this point in the history
view all supported file types at once (fix #13239)
  • Loading branch information
alexbruy authored and nyalldawson committed May 7, 2020
1 parent 154c892 commit 1b41377
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/core/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -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" ) + " (*);;" );

Expand Down
8 changes: 7 additions & 1 deletion src/core/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -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 );

Expand Down

0 comments on commit 1b41377

Please sign in to comment.