Skip to content
Permalink
Browse files

[processing] populate batch interface with rows when multiple layers

selected (#21859)
  • Loading branch information
alexbruy authored and nyalldawson committed Apr 30, 2019
1 parent cdaf2b9 commit 24510cb888067f7a8928baa981a6c654b60b9d25
@@ -87,13 +87,11 @@ def showPopupMenu(self):

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 = QAction(self.tr('Select from Open Layers…'), self.pushButton)
selectLayerAction.triggered.connect(self.showLayerSelectionDialog)
popupmenu.addAction(selectLayerAction)

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

@@ -151,13 +149,13 @@ def generate_layer_id(layer):

def showFileSelectionDialog(self):
settings = QgsSettings()
text = str(self.text.text())
text = 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 = str(settings.value('/Processing/LastInputPath'))
path = settings.value('/Processing/LastInputPath')
else:
path = ''

@@ -166,7 +164,7 @@ def showFileSelectionDialog(self):
if ret:
files = list(ret)
settings.setValue('/Processing/LastInputPath',
os.path.dirname(str(files[0])))
os.path.dirname(files[0]))
for i, filename in enumerate(files):
files[i] = dataobjects.getRasterSublayer(filename, self.param)
if len(files) == 1:
@@ -35,6 +35,11 @@
from qgis.core import (Qgis,
QgsApplication,
QgsSettings,
QgsProcessingParameterMapLayer,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterMeshLayer,
QgsProcessingParameterFile,
QgsProcessingParameterDefinition,
QgsProcessingModelAlgorithm)
from qgis.gui import (QgsProcessingParameterWidgetContext,
@@ -43,6 +48,7 @@

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
@@ -289,9 +295,17 @@ def addRow(self):
if param.flags() & QgsProcessingParameterDefinition.FlagHidden or param.isDestination():
continue

wrapper = WidgetWrapperFactory.create_wrapper(param, self.parent, row, column)
wrappers[param.name()] = wrapper
self.setCellWrapper(row, column, wrapper, context)
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)

column += 1

for out in self.alg.destinationParameterDefinitions():
@@ -85,7 +85,7 @@ def getFileFilter(param):
return param.fileFilter() + ';;' + tr('All files (*.*)')
elif param.type() == 'mesh':
return tr('All files (*.*)')
if param.defaultFileExtension():
if hasattr(param, 'defaultFileExtension') and param.defaultFileExtension():
return tr('Default extension') + ' (*.' + param.defaultFileExtension() + ')'
else:
return ''

0 comments on commit 24510cb

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