mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
add supportedFormatExtensions() method to QgsRasterFileWriter
This commit is contained in:
parent
52b5864335
commit
48661addc6
@ -194,6 +194,18 @@ Filter string for file picker dialogs
|
||||
:rtype: list of QgsRasterFileWriter.FilterFormatDetails
|
||||
%End
|
||||
|
||||
static QStringList supportedFormatExtensions( RasterFormatOptions options = SortRecommended );
|
||||
%Docstring
|
||||
Returns a list of file extensions for supported formats.
|
||||
|
||||
The ``options`` argument can be used to control the sorting and filtering of
|
||||
returned formats.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
.. seealso:: :py:func:`supportedFiltersAndFormats()`
|
||||
:rtype: list of str
|
||||
%End
|
||||
|
||||
static QString driverForExtension( const QString &extension );
|
||||
%Docstring
|
||||
Returns the GDAL driver name for a specified file ``extension``. E.g. the
|
||||
|
@ -1103,3 +1103,23 @@ QList< QgsRasterFileWriter::FilterFormatDetails > QgsRasterFileWriter::supported
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
QStringList QgsRasterFileWriter::supportedFormatExtensions( const RasterFormatOptions options )
|
||||
{
|
||||
const auto formats = supportedFiltersAndFormats( options );
|
||||
QStringList extensions;
|
||||
|
||||
QRegularExpression rx( QStringLiteral( "\\*\\.([a-zA-Z0-9]*)" ) );
|
||||
|
||||
for ( const FilterFormatDetails &format : formats )
|
||||
{
|
||||
QString ext = format.filterString;
|
||||
QRegularExpressionMatch match = rx.match( ext );
|
||||
if ( !match.hasMatch() )
|
||||
continue;
|
||||
|
||||
QString matched = match.captured( 1 );
|
||||
extensions << matched;
|
||||
}
|
||||
return extensions;
|
||||
}
|
||||
|
@ -171,6 +171,17 @@ class CORE_EXPORT QgsRasterFileWriter
|
||||
*/
|
||||
static QList< QgsRasterFileWriter::FilterFormatDetails > supportedFiltersAndFormats( RasterFormatOptions options = SortRecommended );
|
||||
|
||||
/**
|
||||
* Returns a list of file extensions for supported formats.
|
||||
*
|
||||
* The \a options argument can be used to control the sorting and filtering of
|
||||
* returned formats.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
* \see supportedFiltersAndFormats()
|
||||
*/
|
||||
static QStringList supportedFormatExtensions( RasterFormatOptions options = SortRecommended );
|
||||
|
||||
/**
|
||||
* Returns the GDAL driver name for a specified file \a extension. E.g. the
|
||||
* driver name for the ".tif" extension is "GTiff".
|
||||
|
Loading…
x
Reference in New Issue
Block a user