Skip to content
Permalink
Browse files

Fix gui handling of NULL/None default values in processing script alg…

…orithms
  • Loading branch information
nyalldawson committed Jan 24, 2018
1 parent be95962 commit 2013725793badac6f850cb5fe4d31f13b0c3c3ee
Showing with 49 additions and 1 deletion.
  1. +49 −1 python/plugins/processing/gui/wrappers.py
@@ -70,7 +70,8 @@
QgsProcessingOutputString,
QgsProcessingOutputNumber,
QgsProcessingModelChildParameterSource,
QgsProcessingModelAlgorithm)
QgsProcessingModelAlgorithm,
NULL)

from qgis.PyQt.QtWidgets import (
QCheckBox,
@@ -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:
@@ -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':
@@ -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:
@@ -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:
@@ -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:
@@ -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:
@@ -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):
@@ -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):
@@ -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))
@@ -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
@@ -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))
@@ -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)
@@ -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:
@@ -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))
@@ -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
@@ -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:

0 comments on commit 2013725

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