Skip to content

Commit 337d188

Browse files
committed
[processing] Use ExpressionWidgetWrapperMixin in StringWidgetWrapper
1 parent 7bffef7 commit 337d188

File tree

2 files changed

+14
-87
lines changed

2 files changed

+14
-87
lines changed

python/plugins/processing/gui/StringInputPanel.py

Lines changed: 0 additions & 74 deletions
This file was deleted.

python/plugins/processing/gui/wrappers.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
from processing.gui.BatchInputSelectionPanel import BatchInputSelectionPanel
8989
from processing.gui.FixedTablePanel import FixedTablePanel
9090
from processing.gui.ExtentSelectionPanel import ExtentSelectionPanel
91-
from processing.gui.StringInputPanel import StringInputPanel
9291

9392

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

839838

840-
class StringWidgetWrapper(WidgetWrapper):
839+
class StringWidgetWrapper(WidgetWrapper, ExpressionWidgetWrapperMixin):
841840

842841
def createWidget(self):
843842
if self.dialogType == DIALOG_STANDARD:
844843
if self.param.multiline:
845844
widget = QPlainTextEdit()
846-
if self.param.default:
847-
widget.setPlainText(self.param.default)
848845
else:
849-
widget = StringInputPanel(self.param)
850-
if self.param.default:
851-
widget.setValue(self.param.default)
846+
self._lineedit = QLineEdit()
847+
return self.wrapWithExpressionButton(self._lineedit)
848+
852849
elif self.dialogType == DIALOG_BATCH:
853850
widget = QLineEdit()
854-
if self.param.default:
855-
widget.setText(self.param.default)
851+
856852
else:
857853
# strings, numbers, files and table fields are all allowed input types
858854
strings = self.dialog.getAvailableValuesOfType([ParameterString, ParameterNumber, ParameterFile,
859855
ParameterTableField, ParameterExpression], OutputString)
860856
options = [(self.dialog.resolveValueDescription(s), s) for s in strings]
861857
if self.param.multiline:
862858
widget = MultilineTextPanel(options)
863-
widget.setText(self.param.default or "")
864859
else:
865860
widget = QComboBox()
866861
widget.setEditable(True)
867862
for desc, val in options:
868863
widget.addItem(desc, val)
869-
widget.setEditText(self.param.default or "")
870864
return widget
871865

872866
def setValue(self, value):
873867
if self.dialogType == DIALOG_STANDARD:
874-
pass # TODO
868+
if self.param.multiline:
869+
self.widget.setPlainText(value)
870+
else:
871+
self._lineedit.setText(value)
872+
875873
elif self.dialogType == DIALOG_BATCH:
876874
self.widget.setText(value)
875+
877876
else:
878877
if self.param.multiline:
879878
self.widget.setValue(value)
@@ -885,10 +884,12 @@ def value(self):
885884
if self.param.multiline:
886885
text = self.widget.toPlainText()
887886
else:
888-
text = self.widget.getValue()
887+
text = self._lineedit.text()
889888
return text
889+
890890
elif self.dialogType == DIALOG_BATCH:
891891
return self.widget.text()
892+
892893
else:
893894
if self.param.multiline:
894895
value = self.widget.getValue()

0 commit comments

Comments
 (0)