Restrict available formats when running algorithms to those supported

by the provider
This commit is contained in:
Nyall Dawson 2017-11-06 12:58:30 +10:00
parent 4ae9241e71
commit 4e3b082594
3 changed files with 11 additions and 8 deletions

View File

@ -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 (*.*)')

View File

@ -45,6 +45,11 @@ QString QgsProcessingProvider::longName() const
return name();
}
QStringList QgsProcessingProvider::supportedOutputRasterLayerExtensions() const
{
return QStringList() << QStringLiteral( "tif" );
}
void QgsProcessingProvider::refreshAlgorithms()
{
qDeleteAll( mAlgorithms );

View File

@ -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.