Skip to content

Commit

Permalink
[sextante] fixes in batch processing interface for #7348
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Mar 15, 2013
1 parent 08f2e84 commit a2bd6d8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
23 changes: 18 additions & 5 deletions python/plugins/sextante/gui/BatchInputSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
from PyQt4 import QtGui, QtCore
from sextante.parameters.ParameterMultipleInput import ParameterMultipleInput

Expand All @@ -49,13 +49,26 @@ def __init__(self, param, row, col, batchDialog, parent = None):
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)

def showSelectionDialog(self):
ret = QtGui.QFileDialog.getOpenFileNames(self, "Open file", QtCore.QString(), "All files (*.*)")
if ret:
files = list(ret)
def showSelectionDialog(self):
settings = QtCore.QSettings()
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("/SextanteQGIS/LastInputPath"):
path = str(settings.value( "/SextanteQGIS/LastInputPath",QtCore.QVariant( "" ) ).toString())
else:
path = ""

ret = QtGui.QFileDialog.getOpenFileNames(self, "Open file", path, "All files (*.*)")
if ret:
files = list(ret)
if len(files) == 1:
settings.setValue("/SextanteQGIS/LastInputPath", os.path.dirname(str(files[0])))
self.text.setText(str(files[0]))
else:
settings.setValue("/SextanteQGIS/LastInputPath", os.path.dirname(str(files[0])))
if isinstance(self.param, ParameterMultipleInput):
self.text.setText(";".join(str(f) for f in files))
else:
Expand Down
23 changes: 15 additions & 8 deletions python/plugins/sextante/gui/BatchProcessingDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* *
***************************************************************************
"""
from sextante.gui.SextantePostprocessing import SextantePostprocessing

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand All @@ -27,7 +25,9 @@
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from sextante.core.QGisLayers import QGisLayers
from sextante.gui.SextantePostprocessing import SextantePostprocessing
from sextante.parameters.ParameterFile import ParameterFile
from sextante.gui.FileSelectionPanel import FileSelectionPanel
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.parameters.ParameterTable import ParameterTable
from sextante.parameters.ParameterVector import ParameterVector
Expand Down Expand Up @@ -95,25 +95,27 @@ def headerDoubleClicked(self, col):
widgetValue = widget.currentIndex()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setCurrentIndex(widgetValue)

elif isinstance(widget, ExtentSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
if widgetValue != None:
self.table.cellWidget(row, col).text.setText(widgetValue)
else:
self.table.cellWidget(row, col).text.setText("")

elif isinstance(widget, CrsSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).epsg = widgetValue
self.table.cellWidget(row, col).setText()

elif isinstance(widget, QtGui.QLineEdit):
widgetValue = widget.text()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setText(widgetValue)
elif isinstance(widget, BatchInputSelectionPanel):
widgetValue = widget.getText()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setText(widgetValue)

else:
pass

Expand Down Expand Up @@ -264,7 +266,10 @@ def finishAll(self):

def setParameterValueFromWidget(self, param, widget, alg = None):
if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable, ParameterMultipleInput)):
return param.setValue(widget.getText())
value = widget.getText()
if unicode(value.strip()) == "":
value = None
return param.setValue(value)
elif isinstance(param, ParameterBoolean):
return param.setValue(widget.currentIndex() == 0)
elif isinstance(param, ParameterSelection):
Expand All @@ -275,7 +280,7 @@ def setParameterValueFromWidget(self, param, widget, alg = None):
if alg != None:
widget.useNewAlg(alg)
return param.setValue(widget.getValue())
elif isinstance(param, ParameterCrs):
elif isinstance(param, (ParameterCrs, ParameterFile)):
return param.setValue(widget.getValue())
else:
return param.setValue(widget.text())
Expand All @@ -300,6 +305,8 @@ def getWidgetFromParameter(self, param, row, col):
item = ExtentSelectionPanel(self, self.alg, param.default)
elif isinstance(param, ParameterCrs):
item = CrsSelectionPanel(param.default)
elif isinstance(param, ParameterFile):
item = FileSelectionPanel(param.isFolder)
else:
item = QtGui.QLineEdit()
try:
Expand Down

0 comments on commit a2bd6d8

Please sign in to comment.