Skip to content
Permalink
Browse files

[processing] improved widgets for raster and vector layers in modeler

  • Loading branch information
volaya committed Oct 5, 2016
1 parent c8f35fb commit c65cc920098e39cfb4838ab1fa8d336e1de8448d
Showing with 15 additions and 4 deletions.
  1. +15 −4 python/plugins/processing/gui/wrappers.py
@@ -18,6 +18,7 @@
***************************************************************************
"""


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


import locale
import os

from qgis.core import QgsCoordinateReferenceSystem
from qgis.PyQt.QtWidgets import QCheckBox, QComboBox, QLineEdit, QPlainTextEdit
@@ -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):
@@ -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)


@@ -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):
@@ -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):

0 comments on commit c65cc92

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