Skip to content

Commit

Permalink
Revert "[processing] populate batch interface with rows when multiple…
Browse files Browse the repository at this point in the history
… layers"

This reverts commits f8890d8,
f085f55 and 5844a0f
  • Loading branch information
alexbruy committed May 30, 2019
1 parent 3885944 commit 1d1d2ca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
30 changes: 14 additions & 16 deletions python/plugins/processing/gui/BatchInputSelectionPanel.py
Expand Up @@ -52,10 +52,9 @@ class BatchInputSelectionPanel(QWidget):
def __init__(self, param, row, col, dialog):
super(BatchInputSelectionPanel, self).__init__(None)
self.param = param
self.dialog = dialog
self.row = row
self.col = col
self.dialog = dialog

self.horizontalLayout = QHBoxLayout(self)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setMargin(0)
Expand All @@ -64,7 +63,8 @@ def __init__(self, param, row, col, dialog):
self.text.setMinimumWidth(300)
self.setValue('')
self.text.editingFinished.connect(self.textEditingFinished)
self.text.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.text.setSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text)
self.pushButton = QPushButton()
self.pushButton.setText('…')
Expand All @@ -81,18 +81,15 @@ def _table(self):
def showPopupMenu(self):
popupmenu = QMenu()

isLayerParam = isinstance(self.param, (QgsProcessingParameterRasterLayer,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterMeshLayer,
QgsProcessingParameterFeatureSource))

if isLayerParam or (isinstance(self.param, QgsProcessingParameterMultipleLayers) and
self.param.layerType() != QgsProcessing.TypeFile):
selectLayerAction = QAction(self.tr('Select from Open Layers…'), self.pushButton)
if not (isinstance(self.param, QgsProcessingParameterMultipleLayers) and
self.param.layerType == dataobjects.TYPE_FILE):
selectLayerAction = QAction(
QCoreApplication.translate('BatchInputSelectionPanel', 'Select from Open Layers…'), self.pushButton)
selectLayerAction.triggered.connect(self.showLayerSelectionDialog)
popupmenu.addAction(selectLayerAction)

selectFileAction = QAction(self.tr('Select from File System…'), self.pushButton)
selectFileAction = QAction(
QCoreApplication.translate('BatchInputSelectionPanel', 'Select from File System…'), self.pushButton)
selectFileAction.triggered.connect(self.showFileSelectionDialog)
popupmenu.addAction(selectFileAction)

Expand Down Expand Up @@ -150,21 +147,22 @@ def generate_layer_id(layer):

def showFileSelectionDialog(self):
settings = QgsSettings()
text = self.text.text()
text = str(self.text.text())
if os.path.isdir(text):
path = text
elif os.path.isdir(os.path.dirname(text)):
path = os.path.dirname(text)
elif settings.contains('/Processing/LastInputPath'):
path = settings.value('/Processing/LastInputPath')
path = str(settings.value('/Processing/LastInputPath'))
else:
path = ''

ret, selected_filter = QFileDialog.getOpenFileNames(self, self.tr('Select Files'), path,
getFileFilter(self.param))
if ret:
files = list(ret)
settings.setValue('/Processing/LastInputPath', os.path.dirname(files[0]))
settings.setValue('/Processing/LastInputPath',
os.path.dirname(str(files[0])))
for i, filename in enumerate(files):
files[i] = dataobjects.getRasterSublayer(filename, self.param)
if len(files) == 1:
Expand All @@ -185,7 +183,7 @@ def textEditingFinished(self):
self._value = self.text.text()
self.valueChanged.emit()

def getValue(self):
def value(self):
return self._value if self._value else None

def setValue(self, value):
Expand Down
15 changes: 3 additions & 12 deletions python/plugins/processing/gui/BatchPanel.py
Expand Up @@ -75,7 +75,6 @@

from processing.gui.wrappers import WidgetWrapperFactory, WidgetWrapper
from processing.gui.BatchOutputSelectionPanel import BatchOutputSelectionPanel
from processing.gui.BatchInputSelectionPanel import BatchInputSelectionPanel

from processing.tools import dataobjects
from processing.tools.dataobjects import createContext
Expand Down Expand Up @@ -525,17 +524,9 @@ def addRow(self):
if param.flags() & QgsProcessingParameterDefinition.FlagHidden or param.isDestination():
continue

if isinstance(param, (QgsProcessingParameterMapLayer, QgsProcessingParameterRasterLayer,
QgsProcessingParameterVectorLayer, QgsProcessingParameterMeshLayer,
QgsProcessingParameterFile)):
self.tblParameters.setCellWidget(
row, column, BatchInputSelectionPanel(
param, row, column, self.parent))
else:
wrapper = WidgetWrapperFactory.create_wrapper(param, self.parent, row, column)
wrappers[param.name()] = wrapper
self.setCellWrapper(row, column, wrapper, context)

wrapper = WidgetWrapperFactory.create_wrapper(param, self.parent, row, column)
wrappers[param.name()] = wrapper
self.setCellWrapper(row, column, wrapper, context)
column += 1

for out in self.alg.destinationParameterDefinitions():
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/ParameterGuiUtils.py
Expand Up @@ -81,7 +81,7 @@ def getFileFilter(param):
return param.fileFilter() + ';;' + tr('All files (*.*)')
elif param.type() == 'mesh':
return tr('All files (*.*)')
if hasattr(param, 'defaultFileExtension') and param.defaultFileExtension():
if param.defaultFileExtension():
return tr('Default extension') + ' (*.' + param.defaultFileExtension() + ')'
else:
return ''

0 comments on commit 1d1d2ca

Please sign in to comment.