Skip to content
Permalink
Browse files

Merge pull request #6340 from nyalldawson/batch_layer_name

[processing] In batch dialog, use layer names for input layers
  • Loading branch information
alexbruy committed Feb 14, 2018
2 parents 5cd452a + 8ceb6fc commit b664f12ed689b19754d35d24ab4b8e27697d21e4
Showing with 11 additions and 2 deletions.
  1. +11 −2 python/plugins/processing/gui/BatchInputSelectionPanel.py
@@ -120,10 +120,19 @@ def showLayerSelectionDialog(self):

dlg = MultipleInputDialog([layer.name() for layer in layers])
dlg.exec_()

def generate_layer_id(layer):
# prefer layer name if unique
if len([l for l in layers if l.name().lower() == layer.name().lower()]) == 1:
return layer.name()
else:
# otherwise fall back to layer id
return layer.id()

if dlg.selectedoptions is not None:
selected = dlg.selectedoptions
if len(selected) == 1:
self.setValue(layers[selected[0]].id())
self.setValue(generate_layer_id(layers[selected[0]]))
else:
if isinstance(self.param, QgsProcessingParameterMultipleLayers):
self.text.setText(';'.join(layers[idx].id() for idx in selected))
@@ -133,7 +142,7 @@ def showLayerSelectionDialog(self):
self._panel().addRow()
for i, layeridx in enumerate(selected):
self._table().cellWidget(i + self.row,
self.col).setValue(layers[layeridx].id())
self.col).setValue(generate_layer_id(layers[layeridx]))

def showFileSelectionDialog(self):
settings = QgsSettings()

0 comments on commit b664f12

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