Skip to content

Commit

Permalink
Fix gui handling of NULL/None default values in processing script alg…
Browse files Browse the repository at this point in the history
…orithms
  • Loading branch information
nyalldawson committed Jan 24, 2018
1 parent be95962 commit 2013725
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion python/plugins/processing/gui/wrappers.py
Expand Up @@ -70,7 +70,8 @@
QgsProcessingOutputString,
QgsProcessingOutputNumber,
QgsProcessingModelChildParameterSource,
QgsProcessingModelAlgorithm)
QgsProcessingModelAlgorithm,
NULL)

from qgis.PyQt.QtWidgets import (
QCheckBox,
Expand Down Expand Up @@ -249,6 +250,8 @@ def createWidget(self):
return widget

def setValue(self, value):
if value is None or value == NULL:
return
if self.dialogType == DIALOG_STANDARD:
self.widget.setChecked(value)
else:
Expand Down Expand Up @@ -320,6 +323,9 @@ def selectProjection(self):
self.setValue(dialog.crs().authid())

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType == DIALOG_MODELER:
self.setComboValue(value, self.combo)
elif value == 'ProjectCrs':
Expand Down Expand Up @@ -365,6 +371,9 @@ def createWidget(self):
return widget

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
self.widget.setExtentFromString(value)
else:
Expand Down Expand Up @@ -410,6 +419,9 @@ def createWidget(self):
return item

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
self.widget.setPointFromString(value)
else:
Expand Down Expand Up @@ -491,6 +503,9 @@ def selectFile(self):
self.combo.setEditText(filename)

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
self.widget.setText(value)
else:
Expand Down Expand Up @@ -610,6 +625,9 @@ def refresh(self):
self.widget.updateForOptions(opts)

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType == DIALOG_STANDARD:
pass # TODO
elif self.dialogType == DIALOG_BATCH:
Expand Down Expand Up @@ -666,6 +684,9 @@ def createWidget(self):
return ModellerNumberInputPanel(self.param, self.dialog)

def setValue(self, value):
if value is None or value == NULL:
return

self.widget.setValue(value)

def value(self):
Expand Down Expand Up @@ -694,6 +715,9 @@ def createWidget(self):
# return ModellerNumberInputPanel(self.param, self.dialog)

def setValue(self, value):
if value is None or value == NULL:
return

self.widget.setValue(value)

def value(self):
Expand Down Expand Up @@ -781,6 +805,9 @@ def selectFile(self):
self.combo.setEditText(filename)

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType == DIALOG_STANDARD:
if self.combo.findText(value) >= 0:
self.combo.setCurrentIndex(self.combo.findText(value))
Expand Down Expand Up @@ -858,6 +885,9 @@ def createWidget(self, useCheckBoxes=False, columns=1):
return widget

def setValue(self, value):
if value is None or value == NULL:
return

if self._useCheckBoxes and not self.dialogType == DIALOG_BATCH:
self.widget.setValue(value)
return
Expand Down Expand Up @@ -990,6 +1020,9 @@ def selectFile(self):
self.combo.setEditText(filename)

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType == DIALOG_STANDARD:
if self.combo.findText(value) >= 0:
self.combo.setCurrentIndex(self.combo.findText(value))
Expand Down Expand Up @@ -1077,6 +1110,9 @@ def showExpressionsBuilder(self):
self.setValue(dlg.expressionText())

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType == DIALOG_STANDARD:
if self.param.multiLine():
self.widget.setPlainText(value)
Expand Down Expand Up @@ -1166,6 +1202,9 @@ def setLayer(self, layer):
self.widget.setLayer(layer)

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
self.widget.setExpression(value)
else:
Expand Down Expand Up @@ -1273,6 +1312,9 @@ def selectFile(self):
self.combo.setEditText(filename)

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType == DIALOG_STANDARD:
if self.combo.findText(value) >= 0:
self.combo.setCurrentIndex(self.combo.findText(value))
Expand Down Expand Up @@ -1387,6 +1429,9 @@ def getFields(self):
return fieldNames

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
if self.param.allowMultiple():
options = self.widget.options
Expand Down Expand Up @@ -1471,6 +1516,9 @@ def refreshItems(self):
self.widget.setCurrentIndex(0)

def setValue(self, value):
if value is None or value == NULL:
return

if self.dialogType in (DIALOG_STANDARD, DIALOG_BATCH):
self.widget.setBand(value)
else:
Expand Down

0 comments on commit 2013725

Please sign in to comment.