mirror of
https://github.com/qgis/QGIS.git
synced 2025-06-06 00:04:01 -04:00
[processing] Fix handling of multiple field input in modeller
This commit is contained in:
parent
a117df2205
commit
3caccd531d
@ -755,13 +755,10 @@ class TableFieldWidgetWrapper(WidgetWrapper):
|
|||||||
def createWidget(self):
|
def createWidget(self):
|
||||||
self._layer = None
|
self._layer = None
|
||||||
|
|
||||||
|
if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
|
||||||
if self.param.multiple:
|
if self.param.multiple:
|
||||||
if self.dialogType == DIALOG_STANDARD:
|
|
||||||
return MultipleInputPanel(options=[])
|
return MultipleInputPanel(options=[])
|
||||||
else:
|
else:
|
||||||
return QLineEdit()
|
|
||||||
else:
|
|
||||||
if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
|
|
||||||
widget = QComboBox()
|
widget = QComboBox()
|
||||||
return widget
|
return widget
|
||||||
else:
|
else:
|
||||||
@ -817,8 +814,8 @@ class TableFieldWidgetWrapper(WidgetWrapper):
|
|||||||
return sorted(list(fieldNames), key=cmp_to_key(locale.strcoll))
|
return sorted(list(fieldNames), key=cmp_to_key(locale.strcoll))
|
||||||
|
|
||||||
def setValue(self, value):
|
def setValue(self, value):
|
||||||
if self.param.multiple:
|
|
||||||
if self.dialogType == DIALOG_STANDARD:
|
if self.dialogType == DIALOG_STANDARD:
|
||||||
|
if self.param.multiple:
|
||||||
options = self.widget.options
|
options = self.widget.options
|
||||||
selected = []
|
selected = []
|
||||||
for i, opt in enumerate(options):
|
for i, opt in enumerate(options):
|
||||||
@ -826,24 +823,15 @@ class TableFieldWidgetWrapper(WidgetWrapper):
|
|||||||
selected.append(i)
|
selected.append(i)
|
||||||
self.widget.setSelectedItems(selected)
|
self.widget.setSelectedItems(selected)
|
||||||
else:
|
else:
|
||||||
self.widget.setText(value)
|
self.setComboValue(value)
|
||||||
else:
|
else:
|
||||||
if self.dialogType == DIALOG_STANDARD:
|
|
||||||
self.setComboValue(value)
|
self.setComboValue(value)
|
||||||
|
|
||||||
def value(self):
|
def value(self):
|
||||||
if self.param.multiple:
|
|
||||||
if self.dialogType == DIALOG_STANDARD:
|
|
||||||
return [self.widget.options[i] for i in self.widget.selectedoptions]
|
|
||||||
elif self.dialogType == DIALOG_BATCH:
|
|
||||||
return self.widget.text()
|
|
||||||
else:
|
|
||||||
text = self.widget.text()
|
|
||||||
if not bool(text) and not self.param.optional:
|
|
||||||
raise InvalidParameterValue()
|
|
||||||
return text
|
|
||||||
else:
|
|
||||||
if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
|
if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
|
||||||
|
if self.param.multiple:
|
||||||
|
return [self.widget.options[i] for i in self.widget.selectedoptions]
|
||||||
|
else:
|
||||||
if self.param.optional and self.widget.currentIndex() == 0:
|
if self.param.optional and self.widget.currentIndex() == 0:
|
||||||
return None
|
return None
|
||||||
return self.widget.currentText()
|
return self.widget.currentText()
|
||||||
|
@ -144,6 +144,13 @@ class ModelerParameterDefinitionDialog(QDialog):
|
|||||||
datatypeIndex = self.param.datatype + 1
|
datatypeIndex = self.param.datatype + 1
|
||||||
self.datatypeCombo.setCurrentIndex(datatypeIndex)
|
self.datatypeCombo.setCurrentIndex(datatypeIndex)
|
||||||
|
|
||||||
|
self.multipleCheck = QCheckBox()
|
||||||
|
self.multipleCheck.setText(self.tr('Accept multiple fields'))
|
||||||
|
self.multipleCheck.setChecked(False)
|
||||||
|
if self.param is not None:
|
||||||
|
self.multipleCheck.setChecked(self.param.multiple)
|
||||||
|
self.verticalLayout.addWidget(self.multipleCheck)
|
||||||
|
|
||||||
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_VECTOR or
|
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_VECTOR or
|
||||||
isinstance(self.param, ParameterVector)):
|
isinstance(self.param, ParameterVector)):
|
||||||
self.verticalLayout.addWidget(QLabel(self.tr('Shape type')))
|
self.verticalLayout.addWidget(QLabel(self.tr('Shape type')))
|
||||||
@ -269,7 +276,7 @@ class ModelerParameterDefinitionDialog(QDialog):
|
|||||||
return
|
return
|
||||||
parent = self.parentCombo.itemData(self.parentCombo.currentIndex())
|
parent = self.parentCombo.itemData(self.parentCombo.currentIndex())
|
||||||
datatype = self.datatypeCombo.itemData(self.datatypeCombo.currentIndex())
|
datatype = self.datatypeCombo.itemData(self.datatypeCombo.currentIndex())
|
||||||
self.param = ParameterTableField(name, description, parent, datatype)
|
self.param = ParameterTableField(name, description, parent, datatype, multiple=self.multipleCheck.isChecked())
|
||||||
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or
|
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or
|
||||||
isinstance(self.param, ParameterRaster)):
|
isinstance(self.param, ParameterRaster)):
|
||||||
self.param = ParameterRaster(
|
self.param = ParameterRaster(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user