Skip to content

Commit

Permalink
Restrict available formats when running algorithms to those supported
Browse files Browse the repository at this point in the history
by the provider
  • Loading branch information
nyalldawson committed Nov 6, 2017
1 parent 4ae9241 commit 4e3b082
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
12 changes: 5 additions & 7 deletions python/plugins/processing/gui/ParameterGuiUtils.py
Expand Up @@ -63,13 +63,11 @@ def getFileFilter(param):
for i in range(len(exts)):
exts[i] = tr('{0} files (*.{1})', 'QgsProcessingParameterRasterDestination').format(exts[i].upper(), exts[i].lower())
return ';;'.join(exts) + ';;' + tr('All files (*.*)')
elif param.type() == 'table':
exts = ['csv', 'dbf']
for i in range(len(exts)):
exts[i] = tr('{0} files (*.{1})', 'ParameterTable').format(exts[i].upper(), exts[i].lower())
return tr('All files (*.*)') + ';;' + ';;'.join(exts)
elif param.type() == 'sink':
exts = QgsVectorFileWriter.supportedFormatExtensions()
elif param.type() in ('sink', 'vectorDestination'):
if param.provider() is not None:
exts = param.provider().supportedOutputVectorLayerExtensions()
else:
exts = QgsVectorFileWriter.supportedFormatExtensions()
for i in range(len(exts)):
exts[i] = tr('{0} files (*.{1})', 'ParameterVector').format(exts[i].upper(), exts[i].lower())
return ';;'.join(exts) + ';;' + tr('All files (*.*)')
Expand Down
5 changes: 5 additions & 0 deletions src/core/processing/qgsprocessingprovider.cpp
Expand Up @@ -45,6 +45,11 @@ QString QgsProcessingProvider::longName() const
return name();
}

QStringList QgsProcessingProvider::supportedOutputRasterLayerExtensions() const
{
return QStringList() << QStringLiteral( "tif" );
}

void QgsProcessingProvider::refreshAlgorithms()
{
qDeleteAll( mAlgorithms );
Expand Down
2 changes: 1 addition & 1 deletion src/core/processing/qgsprocessingprovider.h
Expand Up @@ -106,7 +106,7 @@ class CORE_EXPORT QgsProcessingProvider : public QObject
* \see supportedOutputVectorLayerExtensions()
* \see supportedOutputTableExtensions()
*/
virtual QStringList supportedOutputRasterLayerExtensions() const { return QStringList() << QStringLiteral( "tif" ); }
virtual QStringList supportedOutputRasterLayerExtensions() const;

/**
* Returns a list of the vector format file extensions supported by this provider.
Expand Down

0 comments on commit 4e3b082

Please sign in to comment.