Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Correctly handle layer type parameter values when
creating an algorithm dialog using processing.execAlgorithmDialog()

(cherry-picked from c65afbd)
  • Loading branch information
nyalldawson committed Jul 19, 2018
1 parent 850e70b commit 693e83b
Showing 1 changed file with 54 additions and 21 deletions.
75 changes: 54 additions & 21 deletions python/plugins/processing/gui/wrappers.py
Expand Up @@ -908,13 +908,24 @@ def setValue(self, value):
return

if self.dialogType == DIALOG_STANDARD:
if self.combo.findText(value) >= 0:
self.combo.setCurrentIndex(self.combo.findText(value))
else:
items = self.combo.additionalItems()
items.append(value)
self.combo.setAdditionalItems(items)
self.combo.setCurrentIndex(self.combo.findText(value))
if isinstance(value, str):
layer = QgsProject.instance().mapLayer(value)
if layer is not None:
value = layer

found = False
if isinstance(value, QgsMapLayer):
self.combo.setLayer(value)
found = self.combo.currentIndex() != -1

if not found:
if self.combo.findText(value) >= 0:
self.combo.setCurrentIndex(self.combo.findText(value))
else:
items = self.combo.additionalItems()
items.append(value)
self.combo.setAdditionalItems(items)
self.combo.setCurrentIndex(self.combo.findText(value))
elif self.dialogType == DIALOG_BATCH:
self.widget.setValue(value)
else:
Expand Down Expand Up @@ -1146,13 +1157,24 @@ def setValue(self, value):
return

if self.dialogType == DIALOG_STANDARD:
if self.combo.findText(value) >= 0:
self.combo.setCurrentIndex(self.combo.findText(value))
else:
items = self.combo.additionalItems()
items.append(value)
self.combo.setAdditionalItems(items)
self.combo.setCurrentIndex(self.combo.findText(value))
if isinstance(value, str):
layer = QgsProject.instance().mapLayer(value)
if layer is not None:
value = layer

found = False
if isinstance(value, QgsMapLayer):
self.combo.setLayer(value)
found = self.combo.currentIndex() != -1

if not found:
if self.combo.findText(value) >= 0:
self.combo.setCurrentIndex(self.combo.findText(value))
else:
items = self.combo.additionalItems()
items.append(value)
self.combo.setAdditionalItems(items)
self.combo.setCurrentIndex(self.combo.findText(value))
elif self.dialogType == DIALOG_BATCH:
self.widget.setValue(value)
else:
Expand Down Expand Up @@ -1448,13 +1470,24 @@ def setValue(self, value):
return

if self.dialogType == DIALOG_STANDARD:
if self.combo.findText(value) >= 0:
self.combo.setCurrentIndex(self.combo.findText(value))
else:
items = self.combo.additionalItems()
items.append(value)
self.combo.setAdditionalItems(items)
self.combo.setCurrentIndex(self.combo.findText(value))
if isinstance(value, str):
layer = QgsProject.instance().mapLayer(value)
if layer is not None:
value = layer

found = False
if isinstance(value, QgsMapLayer):
self.combo.setLayer(value)
found = self.combo.currentIndex() != -1

if not found:
if self.combo.findText(value) >= 0:
self.combo.setCurrentIndex(self.combo.findText(value))
else:
items = self.combo.additionalItems()
items.append(value)
self.combo.setAdditionalItems(items)
self.combo.setCurrentIndex(self.combo.findText(value))
elif self.dialogType == DIALOG_BATCH:
return self.widget.setValue(value)
else:
Expand Down

0 comments on commit 693e83b

Please sign in to comment.