Skip to content

Commit

Permalink
Support layer objects in BatchInputSelectionPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-morvan authored and volaya committed Oct 5, 2016
1 parent 9e36582 commit be5f951
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions python/plugins/processing/gui/BatchInputSelectionPanel.py
Expand Up @@ -29,10 +29,12 @@

import os

from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtCore import QSettings, pyqtSignal
from qgis.PyQt.QtWidgets import QWidget, QHBoxLayout, QMenu, QPushButton, QLineEdit, QSizePolicy, QAction, QFileDialog
from qgis.PyQt.QtGui import QCursor

from qgis.core import QgsMapLayer

from processing.gui.MultipleInputDialog import MultipleInputDialog

from processing.core.parameters import ParameterMultipleInput
Expand All @@ -45,6 +47,8 @@

class BatchInputSelectionPanel(QWidget):

valueChanged = pyqtSignal()

def __init__(self, param, row, col, dialog):
super(BatchInputSelectionPanel, self).__init__(None)
self.param = param
Expand All @@ -55,8 +59,10 @@ def __init__(self, param, row, col, dialog):
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setMargin(0)
self.text = QLineEdit()
self.text.setObjectName('text')
self.text.setMinimumWidth(300)
self.text.setText('')
self.setValue('')
self.text.editingFinished.connect(self.on_text_EditingFinished)
self.text.setSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
Expand All @@ -67,7 +73,7 @@ def __init__(self, param, row, col, dialog):
self.setLayout(self.horizontalLayout)

def _panel(self):
return self.dialog.mainWidget()
return self.dialog.mainWidget

def _table(self):
return self._panel().tblParameters
Expand Down Expand Up @@ -118,7 +124,7 @@ def showLayerSelectionDialog(self):
self._panel().addRow()
for i, layeridx in enumerate(selected):
self._table().cellWidget(i + self.row,
self.col).setText(layers[layeridx].name())
self.col).setValue(layers[layeridx])

def showFileSelectionDialog(self):
settings = QSettings()
Expand Down Expand Up @@ -151,10 +157,19 @@ def showFileSelectionDialog(self):
self._panel().addRow()
for i, f in enumerate(files):
self._table().cellWidget(i + self.row,
self.col).setText(f)

def setText(self, text):
return self.text.setText(text)

def getText(self):
return self.text.text()
self.col).setValue(f)

def on_text_EditingFinished(self):
self._value = self.text.text()
self.valueChanged.emit()

def value(self):
return self._value

def setValue(self, value):
self._value = value
if isinstance(value, QgsMapLayer):
self.text.setText(value.name())
else: # should be basestring
self.text.setText(value)
self.valueChanged.emit()

0 comments on commit be5f951

Please sign in to comment.