File tree 3 files changed +43
-0
lines changed
3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,18 @@ Filter string for file picker dialogs
194
194
:rtype: list of QgsRasterFileWriter.FilterFormatDetails
195
195
%End
196
196
197
+ static QStringList supportedFormatExtensions( RasterFormatOptions options = SortRecommended );
198
+ %Docstring
199
+ Returns a list of file extensions for supported formats.
200
+
201
+ The ``options`` argument can be used to control the sorting and filtering of
202
+ returned formats.
203
+
204
+ .. versionadded:: 3.0
205
+ .. seealso:: :py:func:`supportedFiltersAndFormats()`
206
+ :rtype: list of str
207
+ %End
208
+
197
209
static QString driverForExtension( const QString &extension );
198
210
%Docstring
199
211
Returns the GDAL driver name for a specified file ``extension``. E.g. the
Original file line number Diff line number Diff line change @@ -1103,3 +1103,23 @@ QList< QgsRasterFileWriter::FilterFormatDetails > QgsRasterFileWriter::supported
1103
1103
1104
1104
return results;
1105
1105
}
1106
+
1107
+ QStringList QgsRasterFileWriter::supportedFormatExtensions ( const RasterFormatOptions options )
1108
+ {
1109
+ const auto formats = supportedFiltersAndFormats ( options );
1110
+ QStringList extensions;
1111
+
1112
+ QRegularExpression rx ( QStringLiteral ( " \\ *\\ .([a-zA-Z0-9]*)" ) );
1113
+
1114
+ for ( const FilterFormatDetails &format : formats )
1115
+ {
1116
+ QString ext = format.filterString ;
1117
+ QRegularExpressionMatch match = rx.match ( ext );
1118
+ if ( !match.hasMatch () )
1119
+ continue ;
1120
+
1121
+ QString matched = match.captured ( 1 );
1122
+ extensions << matched;
1123
+ }
1124
+ return extensions;
1125
+ }
Original file line number Diff line number Diff line change @@ -171,6 +171,17 @@ class CORE_EXPORT QgsRasterFileWriter
171
171
*/
172
172
static QList< QgsRasterFileWriter::FilterFormatDetails > supportedFiltersAndFormats ( RasterFormatOptions options = SortRecommended );
173
173
174
+ /* *
175
+ * Returns a list of file extensions for supported formats.
176
+ *
177
+ * The \a options argument can be used to control the sorting and filtering of
178
+ * returned formats.
179
+ *
180
+ * \since QGIS 3.0
181
+ * \see supportedFiltersAndFormats()
182
+ */
183
+ static QStringList supportedFormatExtensions ( RasterFormatOptions options = SortRecommended );
184
+
174
185
/* *
175
186
* Returns the GDAL driver name for a specified file \a extension. E.g. the
176
187
* driver name for the ".tif" extension is "GTiff".
You can’t perform that action at this time.
0 commit comments