Skip to content
Permalink
Browse files

[Processing] Update gui

  • Loading branch information
rldhont committed Dec 23, 2015
1 parent 9da4a76 commit cc2fb2efdaa403913774c2dba571918bd925a9eb
@@ -48,7 +48,7 @@

class ExtentSelectionPanel(BASE, WIDGET):

def __init__(self, dialog, alg, default):
def __init__(self, dialog, alg, default=None):
super(ExtentSelectionPanel, self).__init__(None)
self.setupUi(self)

@@ -66,6 +66,18 @@ def __init__(self, dialog, alg, default):
self.tool = RectangleMapTool(canvas)
self.tool.rectangleCreated.connect(self.updateExtent)

if default:
tokens = unicode(default).split(',')
if len(tokens) == 4:
try:
float(tokens[0])
float(tokens[1])
float(tokens[2])
float(tokens[3])
self.leText.setText(unicode(default))
except:
pass

def canUseAutoExtent(self):
for param in self.params:
if isinstance(param, (ParameterRaster, ParameterVector)):
@@ -82,7 +82,7 @@ def onRightLayerChange(self):

def updatePredicates(self):
if (isinstance(self.leftLayer, QgsVectorLayer)
and isinstance(self.rightLayer, QgsVectorLayer)):
and isinstance(self.rightLayer, QgsVectorLayer)):
leftType = self.leftLayer.geometryType()
rightType = self.rightLayer.geometryType()
unusablePredicates = self.unusablePredicates[leftType][rightType]
@@ -115,7 +115,8 @@ def value(self):
return values

def setValue(self, values):
for predicate in ParameterGeometryPredicate.predicates:
widget = self.getWidget(predicate)
widget.setChecked(predicate in values)
if values:
for predicate in ParameterGeometryPredicate.predicates:
widget = self.getWidget(predicate)
widget.setChecked(predicate in values)
return True
@@ -60,8 +60,16 @@ def __init__(self, number, minimum, maximum, isInteger):
else:
self.spnValue.setMinimum(-99999999)

self.spnValue.setValue(float(number))
self.spnValue.setClearValue(float(number))
#Set default value
if number == 0 or number:
self.spnValue.setValue(float(number))
self.spnValue.setClearValue(float(number))
elif minimum == 0 or minimum:
self.spnValue.setValue(float(minimum))
self.spnValue.setClearValue(float(minimum))
else:
self.spnValue.setValue(0)
self.spnValue.setClearValue(0)

self.btnCalc.clicked.connect(self.showNumberInputDialog)

@@ -286,7 +286,8 @@ def getWidgetFromParameter(self, param):
elif isinstance(param, ParameterSelection):
item = QComboBox()
item.addItems(param.options)
item.setCurrentIndex(param.default)
if param.default:
item.setCurrentIndex(param.default)
elif isinstance(param, ParameterFixedTable):
item = FixedTablePanel(param)
elif isinstance(param, ParameterRange):
@@ -320,12 +321,14 @@ def getWidgetFromParameter(self, param):
verticalLayout.setSizeConstraint(
QLayout.SetDefaultConstraint)
textEdit = QPlainTextEdit()
textEdit.setPlainText(param.default)
if param.default:
textEdit.setPlainText(param.default)
verticalLayout.addWidget(textEdit)
item = textEdit
else:
item = QLineEdit()
item.setText(unicode(param.default))
if param.default:
item.setText(unicode(param.default))
elif isinstance(param, ParameterGeometryPredicate):
item = GeometryPredicateSelectionPanel(param.enabledPredicates)
if param.left:
@@ -341,10 +344,12 @@ def getWidgetFromParameter(self, param):
widget.currentIndexChanged.connect(item.onRightLayerChange)
item.rightLayer = widget.itemData(widget.currentIndex())
item.updatePredicates()
item.setValue(param.default)
if param.default:
item.setValue(param.default)
else:
item = QLineEdit()
item.setText(unicode(param.default))
if param.default:
item.setText(unicode(param.default))

return item

@@ -362,7 +367,7 @@ def updateDependentFields(self):
if self.alg.getParameterFromName(child).optional:
widget.addItem(self.tr('[not set]'))
widget.addItems(self.getFields(layer,
self.alg.getParameterFromName(child).datatype))
self.alg.getParameterFromName(child).datatype))

def getFields(self, layer, datatype):
fieldTypes = []

0 comments on commit cc2fb2e

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