mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Support layer objects in BatchInputSelectionPanel
This commit is contained in:
parent
9e36582feb
commit
be5f951cd1
@ -29,10 +29,12 @@ __revision__ = '$Format:%H$'
|
||||
|
||||
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 @@ from processing.tools import dataobjects
|
||||
|
||||
class BatchInputSelectionPanel(QWidget):
|
||||
|
||||
valueChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, param, row, col, dialog):
|
||||
super(BatchInputSelectionPanel, self).__init__(None)
|
||||
self.param = param
|
||||
@ -55,8 +59,10 @@ class BatchInputSelectionPanel(QWidget):
|
||||
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 @@ class BatchInputSelectionPanel(QWidget):
|
||||
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 @@ class BatchInputSelectionPanel(QWidget):
|
||||
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 @@ class BatchInputSelectionPanel(QWidget):
|
||||
self._panel().addRow()
|
||||
for i, f in enumerate(files):
|
||||
self._table().cellWidget(i + self.row,
|
||||
self.col).setText(f)
|
||||
self.col).setValue(f)
|
||||
|
||||
def setText(self, text):
|
||||
return self.text.setText(text)
|
||||
def on_text_EditingFinished(self):
|
||||
self._value = self.text.text()
|
||||
self.valueChanged.emit()
|
||||
|
||||
def getText(self):
|
||||
return self.text.text()
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user