Fix evaluation of Python wrapper values

This commit is contained in:
Nyall Dawson 2018-09-03 10:16:51 +10:00
parent 70c1680754
commit 8082497724
4 changed files with 15 additions and 18 deletions

View File

@ -59,6 +59,7 @@ from processing.gui.BatchAlgorithmDialog import BatchAlgorithmDialog
from processing.gui.AlgorithmDialogBase import AlgorithmDialogBase
from processing.gui.AlgorithmExecutor import executeIterating, execute
from processing.gui.Postprocessing import handleAlgorithmResults
from processing.gui.wrappers import WidgetWrapper
from processing.tools import dataobjects
@ -103,10 +104,11 @@ class AlgorithmDialog(QgsProcessingAlgorithmDialogBase):
except KeyError:
continue
try:
widget = wrapper.wrappedWidget()
except AttributeError:
if issubclass(wrapper.__class__, WidgetWrapper):
widget = wrapper.widget
else:
widget = wrapper.wrappedWidget()
if widget is None:
continue

View File

@ -83,8 +83,8 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
if param.flags() & QgsProcessingParameterDefinition.FlagHidden or param.isDestination():
continue
wrapper = self.mainWidget().wrappers[row][col]
parameters[param.name()] = wrapper.value()
if not param.checkValueIsAcceptable(wrapper.value()):
parameters[param.name()] = wrapper.parameterValue()
if not param.checkValueIsAcceptable(wrapper.parameterValue()):
self.messageBar().pushMessage("", self.tr('Wrong or missing parameter value: {0} (row {1})').format(
param.description(), row + 1),
level=Qgis.Warning, duration=5)

View File

@ -36,9 +36,8 @@ from qgis.core import (Qgis,
QgsApplication,
QgsSettings,
QgsProcessingParameterDefinition)
from qgis.gui import QgsAbstractProcessingParameterWidgetWrapper
from processing.gui.wrappers import WidgetWrapperFactory
from processing.gui.wrappers import WidgetWrapperFactory, WidgetWrapper
from processing.gui.BatchOutputSelectionPanel import BatchOutputSelectionPanel
from processing.tools import dataobjects
@ -235,7 +234,7 @@ class BatchPanel(BASE, WIDGET):
def setCellWrapper(self, row, column, wrapper, context):
self.wrappers[row][column] = wrapper
is_cpp_wrapper = issubclass(wrapper.__class__, QgsAbstractProcessingParameterWidgetWrapper)
is_cpp_wrapper = not issubclass(wrapper.__class__, WidgetWrapper)
if is_cpp_wrapper:
widget = wrapper.createWrappedWidget(context)
else:

View File

@ -38,14 +38,10 @@ from qgis.core import (QgsProcessingParameterDefinition,
QgsProcessingParameterExtent,
QgsProcessingParameterPoint,
QgsProcessingParameterFeatureSource,
QgsProcessingOutputVectorLayer,
QgsProcessingOutputRasterLayer,
QgsProcessingParameterRasterDestination,
QgsProcessingParameterFeatureSink,
QgsProcessingParameterVectorDestination,
QgsProject)
from qgis.gui import (QgsGui,
QgsAbstractProcessingParameterWidgetWrapper)
from qgis.PyQt import uic
from qgis.PyQt.QtCore import QCoreApplication, Qt
@ -54,7 +50,7 @@ from qgis.PyQt.QtWidgets import (QWidget, QHBoxLayout, QToolButton,
from qgis.PyQt.QtGui import QIcon
from processing.gui.DestinationSelectionPanel import DestinationSelectionPanel
from processing.gui.wrappers import WidgetWrapperFactory
from processing.gui.wrappers import WidgetWrapperFactory, WidgetWrapper
from processing.tools.dataobjects import createContext
pluginPath = os.path.split(os.path.dirname(__file__))[0]\
@ -123,14 +119,14 @@ class ParametersPanel(BASE, WIDGET):
else:
wrapper = WidgetWrapperFactory.create_wrapper(param, self.parent)
self.wrappers[param.name()] = wrapper
is_cpp_wrapper = issubclass(wrapper.__class__, QgsAbstractProcessingParameterWidgetWrapper)
if is_cpp_wrapper:
is_python_wrapper = issubclass(wrapper.__class__, WidgetWrapper)
if not is_python_wrapper:
widget = wrapper.createWrappedWidget(context)
else:
widget = wrapper.widget
if widget is not None:
if not is_cpp_wrapper:
if is_python_wrapper:
widget.setToolTip(param.toolTip())
if isinstance(param, QgsProcessingParameterFeatureSource):
@ -152,7 +148,7 @@ class ParametersPanel(BASE, WIDGET):
widget.setLayout(layout)
label = None
if is_cpp_wrapper:
if not is_python_wrapper:
label = wrapper.createWrappedLabel()
else:
label = wrapper.label
@ -163,7 +159,7 @@ class ParametersPanel(BASE, WIDGET):
else:
self.layoutMain.insertWidget(
self.layoutMain.count() - 2, label)
elif not is_cpp_wrapper:
elif is_python_wrapper:
desc = param.description()
if isinstance(param, QgsProcessingParameterExtent):
desc += self.tr(' (xmin, xmax, ymin, ymax)')