mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Use correct file filters for processing vector/raster input selectors
This commit is contained in:
parent
d4ad063f45
commit
470afbebbe
@ -27,7 +27,7 @@ __copyright__ = '(C) 2017, Nyall Dawson'
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
from qgis.core import (QgsProcessing,
|
||||
QgsProcessingParameterDefinition,
|
||||
QgsProviderRegistry,
|
||||
QgsProcessingFeatureSourceDefinition,
|
||||
QgsVectorFileWriter)
|
||||
from qgis.PyQt.QtCore import QCoreApplication
|
||||
@ -55,22 +55,29 @@ def getFileFilter(param):
|
||||
exts = QgsVectorFileWriter.supportedFormatExtensions()
|
||||
for i in range(len(exts)):
|
||||
exts[i] = tr('{0} files (*.{1})', 'QgsProcessingParameterMultipleLayers').format(exts[i].upper(), exts[i].lower())
|
||||
return ';;'.join(exts)
|
||||
elif param.type() in ('raster', 'rasterDestination'):
|
||||
return tr('All files (*.*)') + ';;' + ';;'.join(exts)
|
||||
elif param.type() == 'raster':
|
||||
return QgsProviderRegistry.instance().fileRasterFilters()
|
||||
elif param.type() == 'rasterDestination':
|
||||
exts = dataobjects.getSupportedOutputRasterLayerExtensions()
|
||||
for i in range(len(exts)):
|
||||
exts[i] = tr('{0} files (*.{1})', 'QgsProcessingParameterRasterDestination').format(exts[i].upper(), exts[i].lower())
|
||||
return ';;'.join(exts)
|
||||
return tr('All files (*.*)') + ';;' + ';;'.join(exts)
|
||||
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 ';;'.join(exts)
|
||||
return tr('All files (*.*)') + ';;' + ';;'.join(exts)
|
||||
elif param.type() == 'sink':
|
||||
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)
|
||||
return tr('All files (*.*)') + ';;' + ';;'.join(exts)
|
||||
elif param.type() == 'source':
|
||||
return QgsProviderRegistry.instance().fileVectorFilters()
|
||||
elif param.type() == 'vector':
|
||||
return QgsProviderRegistry.instance().fileVectorFilters()
|
||||
elif param.type() == 'fileOut':
|
||||
return param.fileFilter()
|
||||
return tr('All files (*.*)') + ';;' + param.fileFilter()
|
||||
|
||||
return ''
|
||||
|
@ -218,8 +218,7 @@ class WidgetWrapper(QObject):
|
||||
path = ''
|
||||
|
||||
filename, selected_filter = QFileDialog.getOpenFileName(self.widget, self.tr('Select file'),
|
||||
path, self.tr(
|
||||
'All files (*.*);;') + getFileFilter(self.param))
|
||||
path, getFileFilter(self.param))
|
||||
if filename:
|
||||
settings.setValue('/Processing/LastInputPath',
|
||||
os.path.dirname(str(filename)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user