Skip to content

Commit

Permalink
[processing] improved widgets for raster and vector layers in modeler
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Oct 5, 2016
1 parent c8f35fb commit c65cc92
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions python/plugins/processing/gui/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
***************************************************************************
"""


__author__ = 'Arnaud Morvan'
__date__ = 'May 2016'
__copyright__ = '(C) 2016, Arnaud Morvan'
Expand All @@ -28,6 +29,7 @@


import locale
import os

from qgis.core import QgsCoordinateReferenceSystem
from qgis.PyQt.QtWidgets import QCheckBox, QComboBox, QLineEdit, QPlainTextEdit
Expand Down Expand Up @@ -486,6 +488,8 @@ def createWidget(self):
files = self.dialog.getAvailableValuesOfType(ParameterRaster, OutputRaster)
for f in files:
widget.addItem(self.dialog.resolveValueDescription(f), f)
if self.param.optional:
widget.setEditText("")
return widget

def refresh(self):
Expand All @@ -512,7 +516,10 @@ def value(self):
return self.widget.getText()
else:
def validator(v):
return bool(v) or self.param.optional
if not bool(v):
return self.param.optional
else:
return os.path.exists(v)
return self.comboValue(validator)


Expand Down Expand Up @@ -555,10 +562,11 @@ def createWidget(self):
else:
widget = QComboBox()
layers = self.dialog.getAvailableValuesOfType(ParameterVector, OutputVector)
if self.param.optional:
widget.addItem(self.NOT_SELECTED, None)
widget.setEditable(True)
for layer in layers:
widget.addItem(self.dialog.resolveValueDescription(layer), layer)
if self.param.optional:
widget.setEditText("")
return widget

def _populate(self, widget):
Expand Down Expand Up @@ -594,7 +602,10 @@ def value(self):
return self.widget.getText()
else:
def validator(v):
return bool(v) or self.param.optional
if not bool(v):
return self.param.optional
else:
return os.path.exists(v)
return self.comboValue(validator)

class StringWidgetWrapper(WidgetWrapper):
Expand Down

0 comments on commit c65cc92

Please sign in to comment.