Skip to content
Permalink
Browse files

Support layer objects in BatchInputSelectionPanel

  • Loading branch information
arnaud-morvan authored and volaya committed Oct 5, 2016
1 parent 9e36582 commit be5f951cd111d1b3c2d1496bbfb43bb7c3dc076a
Showing with 26 additions and 11 deletions.
  1. +26 −11 python/plugins/processing/gui/BatchInputSelectionPanel.py
@@ -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
@@ -45,6 +47,8 @@

class BatchInputSelectionPanel(QWidget):

valueChanged = pyqtSignal()

def __init__(self, param, row, col, dialog):
super(BatchInputSelectionPanel, self).__init__(None)
self.param = param
@@ -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)
@@ -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
@@ -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()
@@ -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.
You can’t perform that action at this time.