mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
73 lines
2.7 KiB
Python
73 lines
2.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
***************************************************************************
|
|
RasterOptionsWidget.py
|
|
---------------------
|
|
Date : December 2016
|
|
Copyright : (C) 2016 by Alexander Bruy
|
|
Email : alexander dot bruy at gmail dot com
|
|
***************************************************************************
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
***************************************************************************
|
|
"""
|
|
|
|
__author__ = 'Alexander Bruy'
|
|
__date__ = 'December 2016'
|
|
__copyright__ = '(C) 2016, Alexander Bruy'
|
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
from qgis.PyQt.QtWidgets import QLineEdit, QComboBox
|
|
from qgis.gui import QgsRasterFormatSaveOptionsWidget
|
|
|
|
from processing.core.parameters import ParameterString
|
|
from processing.core.outputs import OutputString
|
|
from processing.gui.wrappers import WidgetWrapper, DIALOG_MODELER, DIALOG_BATCH
|
|
|
|
|
|
class RasterOptionsWidgetWrapper(WidgetWrapper):
|
|
|
|
def createWidget(self):
|
|
if self.dialogType == DIALOG_MODELER:
|
|
widget = QComboBox()
|
|
widget.setEditable(True)
|
|
strings = self.dialog.getAvailableValuesOfType(ParameterString, OutputString)
|
|
options = [(self.dialog.resolveValueDescription(s), s) for s in strings]
|
|
for desc, val in options:
|
|
widget.addItem(desc, val)
|
|
widget.setEditText(self.param.default or '')
|
|
return widget
|
|
elif self.dialogType == DIALOG_BATCH:
|
|
widget = QLineEdit()
|
|
if self.param.default:
|
|
widget.setText(self.param.default)
|
|
else:
|
|
return QgsRasterFormatSaveOptionsWidget()
|
|
|
|
def setValue(self, value):
|
|
if value is None:
|
|
value = ''
|
|
|
|
if self.dialogType == DIALOG_MODELER:
|
|
self.setComboValue(value)
|
|
elif self.dialogType == DIALOG_BATCH:
|
|
self.widget.setText(value)
|
|
else:
|
|
self.widget.setValue(value)
|
|
|
|
def value(self):
|
|
if self.dialogType == DIALOG_MODELER:
|
|
return self.comboValue()
|
|
elif self.dialogType == DIALOG_BATCH:
|
|
return self.widget.text()
|
|
else:
|
|
return ' '.join(self.widget.options())
|