|
25 | 25 |
|
26 | 26 | __revision__ = '$Format:%H$'
|
27 | 27 |
|
| 28 | +from qgis.PyQt.QtWidgets import QLineEdit, QComboBox |
28 | 29 | from qgis.gui import QgsRasterFormatSaveOptionsWidget
|
29 | 30 |
|
30 |
| -from processing.gui.wrappers import WidgetWrapper |
| 31 | +from processing.core.parameters import ParameterString |
| 32 | +from processing.core.outputs import OutputString |
| 33 | +from processing.gui.wrappers import WidgetWrapper, DIALOG_MODELER, DIALOG_BATCH |
31 | 34 |
|
32 | 35 |
|
33 | 36 | class RasterOptionsWidgetWrapper(WidgetWrapper):
|
34 | 37 |
|
35 | 38 | def createWidget(self):
|
36 |
| - return QgsRasterFormatSaveOptionsWidget() |
| 39 | + if self.dialogType == DIALOG_MODELER: |
| 40 | + widget = QComboBox() |
| 41 | + widget.setEditable(True) |
| 42 | + strings = self.dialog.getAvailableValuesOfType(ParameterString, OutputString) |
| 43 | + options = [(self.dialog.resolveValueDescription(s), s) for s in strings] |
| 44 | + for desc, val in options: |
| 45 | + widget.addItem(desc, val) |
| 46 | + widget.setEditText(self.param.default or '') |
| 47 | + return widget |
| 48 | + elif self.dialogType == DIALOG_BATCH: |
| 49 | + widget = QLineEdit() |
| 50 | + if self.param.default: |
| 51 | + widget.setText(self.param.default) |
| 52 | + else: |
| 53 | + return QgsRasterFormatSaveOptionsWidget() |
37 | 54 |
|
38 | 55 | def setValue(self, value):
|
39 | 56 | if value is None:
|
40 | 57 | value = ''
|
41 |
| - self.widget.setValue(value) |
| 58 | + |
| 59 | + if self.dialogType == DIALOG_MODELER: |
| 60 | + self.setComboValue(value) |
| 61 | + elif self.dialogType == DIALOG_BATCH: |
| 62 | + self.widget.setText(value) |
| 63 | + else: |
| 64 | + self.widget.setValue(value) |
42 | 65 |
|
43 | 66 | def value(self):
|
44 |
| - return ' '.join(self.widget.options()) |
| 67 | + if self.dialogType == DIALOG_MODELER: |
| 68 | + return self.comboValue() |
| 69 | + elif self.dialogType == DIALOG_BATCH: |
| 70 | + return self.widget.text() |
| 71 | + else: |
| 72 | + return ' '.join(self.widget.options()) |
0 commit comments