Skip to content
Permalink
Browse files

[processing] Use ExpressionWidgetWrapperMixin in StringWidgetWrapper

  • Loading branch information
arnaud-morvan committed Feb 10, 2017
1 parent 7bffef7 commit 337d1889b8032bfbbdb077e57cec93b88f3cc135
Showing with 14 additions and 87 deletions.
  1. +0 −74 python/plugins/processing/gui/StringInputPanel.py
  2. +14 −13 python/plugins/processing/gui/wrappers.py

This file was deleted.

@@ -88,7 +88,6 @@
from processing.gui.BatchInputSelectionPanel import BatchInputSelectionPanel
from processing.gui.FixedTablePanel import FixedTablePanel
from processing.gui.ExtentSelectionPanel import ExtentSelectionPanel
from processing.gui.StringInputPanel import StringInputPanel


DIALOG_STANDARD = 'standard'
@@ -837,43 +836,43 @@ def validator(v):
return self.comboValue(validator, combobox=self.combo)


class StringWidgetWrapper(WidgetWrapper):
class StringWidgetWrapper(WidgetWrapper, ExpressionWidgetWrapperMixin):

def createWidget(self):
if self.dialogType == DIALOG_STANDARD:
if self.param.multiline:
widget = QPlainTextEdit()
if self.param.default:
widget.setPlainText(self.param.default)
else:
widget = StringInputPanel(self.param)
if self.param.default:
widget.setValue(self.param.default)
self._lineedit = QLineEdit()
return self.wrapWithExpressionButton(self._lineedit)

elif self.dialogType == DIALOG_BATCH:
widget = QLineEdit()
if self.param.default:
widget.setText(self.param.default)

else:
# strings, numbers, files and table fields are all allowed input types
strings = self.dialog.getAvailableValuesOfType([ParameterString, ParameterNumber, ParameterFile,
ParameterTableField, ParameterExpression], OutputString)
options = [(self.dialog.resolveValueDescription(s), s) for s in strings]
if self.param.multiline:
widget = MultilineTextPanel(options)
widget.setText(self.param.default or "")
else:
widget = QComboBox()
widget.setEditable(True)
for desc, val in options:
widget.addItem(desc, val)
widget.setEditText(self.param.default or "")
return widget

def setValue(self, value):
if self.dialogType == DIALOG_STANDARD:
pass # TODO
if self.param.multiline:
self.widget.setPlainText(value)
else:
self._lineedit.setText(value)

elif self.dialogType == DIALOG_BATCH:
self.widget.setText(value)

else:
if self.param.multiline:
self.widget.setValue(value)
@@ -885,10 +884,12 @@ def value(self):
if self.param.multiline:
text = self.widget.toPlainText()
else:
text = self.widget.getValue()
text = self._lineedit.text()
return text

elif self.dialogType == DIALOG_BATCH:
return self.widget.text()

else:
if self.param.multiline:
value = self.widget.getValue()

0 comments on commit 337d188

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