Skip to content
Permalink
Browse files

[processing] Allow data type for numeric inputs to be specified

  • Loading branch information
nyalldawson committed Mar 10, 2019
1 parent 9f6ddaf commit 82b186f00f1d717bac881b32ca883e4c74651fcd
Showing with 12 additions and 2 deletions.
  1. +12 −2 python/plugins/processing/modeler/ModelerParameterDefinitionDialog.py
@@ -229,6 +229,14 @@ def setupUi(self):
self.parentCombo.setCurrentIndex(idx)
idx += 1
self.verticalLayout.addWidget(self.parentCombo)
else:
self.verticalLayout.addWidget(QLabel(self.tr('Number type')))
self.type_combo = QComboBox()
self.type_combo.addItem(self.tr('Float'), QgsProcessingParameterNumber.Double)
self.type_combo.addItem(self.tr('Integer'), QgsProcessingParameterNumber.Integer)
if self.param:
self.type_combo.setCurrentIndex(self.type_combo.findData(self.param.dataType()))
self.verticalLayout.addWidget(self.type_combo)

self.verticalLayout.addWidget(QLabel(self.tr('Min value')))
self.minTextBox = QLineEdit()
@@ -245,7 +253,7 @@ def setupUi(self):
if self.param is not None:
default = self.param.defaultValue()
if self.param.dataType() == QgsProcessingParameterNumber.Integer:
default = int(math.floor(default))
default = int(math.floor(float(default)))
if default:
self.defaultTextBox.setText(str(default))
self.verticalLayout.addWidget(self.defaultTextBox)
@@ -445,7 +453,9 @@ def accept(self):
self.param.setParentParameterName(parent)
elif (self.paramType == parameters.PARAMETER_NUMBER or
isinstance(self.param, QgsProcessingParameterNumber)):
self.param = QgsProcessingParameterNumber(name, description, QgsProcessingParameterNumber.Double,

type = self.type_combo.currentData()
self.param = QgsProcessingParameterNumber(name, description, type,
self.defaultTextBox.text())
try:
vmin = self.minTextBox.text().strip()

0 comments on commit 82b186f

Please sign in to comment.
You can’t perform that action at this time.