Skip to content

Commit

Permalink
[processing] Use ExpressionWidgetWrapperMixin in StringWidgetWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-morvan committed Feb 10, 2017
1 parent 7bffef7 commit 337d188
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 87 deletions.
74 changes: 0 additions & 74 deletions python/plugins/processing/gui/StringInputPanel.py

This file was deleted.

27 changes: 14 additions & 13 deletions python/plugins/processing/gui/wrappers.py
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 337d188

Please sign in to comment.