Skip to content
Permalink
Browse files

[processing] Fix gdal algorithm use of old wrapper API

  • Loading branch information
nyalldawson committed Sep 11, 2018
1 parent 0b40ffd commit c8abd40250f58166c723d3aa347e0de56e7c8fd1
@@ -49,6 +49,7 @@
from processing.gui.MultipleInputPanel import MultipleInputPanel
from processing.gui.NumberInputPanel import NumberInputPanel
from processing.gui.DestinationSelectionPanel import DestinationSelectionPanel
from processing.gui.wrappers import WidgetWrapper
from processing.tools.dataobjects import createContext


@@ -85,10 +86,23 @@ def __init__(self, parent, alg):

def connectParameterSignals(self):
for wrapper in list(self.wrappers.values()):
w = wrapper.widget
wrapper.widgetValueHasChanged.connect(self.parametersHaveChanged)

# TODO - remove when all wrappers correctly emit widgetValueHasChanged!

# For compatibility with 3.x API, we need to check whether the wrapper is
# the deprecated WidgetWrapper class. If not, it's the newer
# QgsAbstractProcessingParameterWidgetWrapper class
# TODO QGIS 4.0 - remove
if issubclass(wrapper.__class__, WidgetWrapper):
w = wrapper.widget
else:
w = wrapper.wrappedWidget()

self.connectWidgetChangedSignals(w)
for c in w.findChildren(QWidget):
self.connectWidgetChangedSignals(c)

for output_widget in self.outputWidgets.values():
self.connectWidgetChangedSignals(output_widget)

@@ -513,9 +513,9 @@ def updatePanelEnabledState():

def postInitialize(self, wrappers):
for wrapper in wrappers:
if wrapper.param.name() == self.parameterDefinition().parentLayerParameter():
if wrapper.value():
self.setLayer(wrapper.value())
if wrapper.parameterDefinition().name() == self.parameterDefinition().parentLayerParameter():
if wrapper.parameterValue():
self.setLayer(wrapper.parameterValue())
wrapper.widgetValueHasChanged.connect(self.parentLayerChanged)
break

@@ -182,30 +182,30 @@ def postInitialize(self, wrappers):

for wrapper in wrappers:
if wrapper.parameterDefinition().name() == self.param.parent_layer:
self.setSource(wrapper.value())
self.setSource(wrapper.parameterValue())
wrapper.widgetValueHasChanged.connect(self.parentLayerChanged)
elif wrapper.parameterDefinition().name() == self.param.radius_param:
self.setRadius(wrapper.value())
self.setRadius(wrapper.parameterValue())
wrapper.widgetValueHasChanged.connect(self.radiusChanged)
elif wrapper.parameterDefinition().name() == self.param.radius_field_param:
self.setSource(wrapper.value())
self.setSource(wrapper.parameterValue())
wrapper.widgetValueHasChanged.connect(self.radiusFieldChanged)

def parentLayerChanged(self, wrapper):
self.setSource(wrapper.value())
self.setSource(wrapper.parameterValue())

def setSource(self, source):
source = QgsProcessingUtils.variantToSource(source, self.context)
self.widget.setSource(source)

def radiusChanged(self, wrapper):
self.setRadius(wrapper.value())
self.setRadius(wrapper.parameterValue())

def setRadius(self, radius):
self.widget.setRadius(radius)

def radiusFieldChanged(self, wrapper):
self.setRadiusField(wrapper.value())
self.setRadiusField(wrapper.parameterValue())

def setRadiusField(self, radius_field):
self.widget.setRadiusField(radius_field)
@@ -258,7 +258,7 @@ def postInitialize(self, wrappers):
break

def parentValueChanged(self, wrapper):
self.setLayer(wrapper.value())
self.setLayer(wrapper.parameterValue())

def setLayer(self, layer):
if isinstance(layer, QgsMapLayer):

0 comments on commit c8abd40

Please sign in to comment.
You can’t perform that action at this time.