mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing] added extension option to ParameterFile.py
This commit is contained in:
parent
3d152393d7
commit
72d33852f1
@ -32,8 +32,9 @@ from processing.tools.system import *
|
||||
|
||||
class FileSelectionPanel(QtGui.QWidget):
|
||||
|
||||
def __init__(self, isFolder):
|
||||
def __init__(self, isFolder, ext = None):
|
||||
super(FileSelectionPanel, self).__init__(None)
|
||||
self.ext = ext or '*'
|
||||
self.isFolder = isFolder
|
||||
self.horizontalLayout = QtGui.QHBoxLayout(self)
|
||||
self.horizontalLayout.setSpacing(2)
|
||||
@ -70,7 +71,7 @@ class FileSelectionPanel(QtGui.QWidget):
|
||||
os.path.dirname(unicode(folder)))
|
||||
else:
|
||||
filenames = QtGui.QFileDialog.getOpenFileNames(self, 'Open file',
|
||||
path, '*.*')
|
||||
path, '*.' + self.ext)
|
||||
if filenames:
|
||||
self.text.setText(u';'.join(filenames))
|
||||
settings.setValue('/Processing/LastInputPath',
|
||||
|
@ -277,7 +277,7 @@ class ParametersPanel(QtGui.QWidget):
|
||||
elif isinstance(param, ParameterRange):
|
||||
item = RangePanel(param)
|
||||
elif isinstance(param, ParameterFile):
|
||||
item = FileSelectionPanel(param.isFolder)
|
||||
item = FileSelectionPanel(param.isFolder, param.ext)
|
||||
elif isinstance(param, ParameterMultipleInput):
|
||||
if param.datatype == ParameterMultipleInput.TYPE_FILE:
|
||||
item = MultipleFileInputPanel()
|
||||
|
@ -30,9 +30,10 @@ from processing.parameters.Parameter import Parameter
|
||||
|
||||
class ParameterFile(Parameter):
|
||||
|
||||
def __init__(self, name='', description='', isFolder=False, optional=True):
|
||||
def __init__(self, name='', description='', isFolder=False, optional=True, ext = None):
|
||||
Parameter.__init__(self, name, description)
|
||||
self.value = None
|
||||
self.ext = ext
|
||||
self.isFolder = isFolder
|
||||
self.optional = optional
|
||||
|
||||
@ -51,6 +52,8 @@ class ParameterFile(Parameter):
|
||||
return False
|
||||
else:
|
||||
self.value = ''
|
||||
if self.ext is not None and self.value != '':
|
||||
return self.value.endswith(self.ext)
|
||||
return True
|
||||
|
||||
def deserialize(self, s):
|
||||
|
Loading…
x
Reference in New Issue
Block a user