Skip to content

Commit

Permalink
[processing] fixed handling of folders and files in settings
Browse files Browse the repository at this point in the history
fixes #12511
  • Loading branch information
volaya committed Jun 26, 2015
1 parent 38d5980 commit b80a1bc
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def initializeSettings(self):
if isWindows() or isMac():
ProcessingConfig.addSetting(Setting(self.getDescription(),
GrassUtils.GRASS_FOLDER, self.tr('GRASS folder'),
GrassUtils.grassPath()))
GrassUtils.grassPath(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
GrassUtils.GRASS_WIN_SHELL, self.tr('Msys folder'),
GrassUtils.grassWinShell()))
GrassUtils.grassWinShell(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
GrassUtils.GRASS_LOG_COMMANDS,
self.tr('Log execution commands'), False))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(
self.getDescription(),
Grass7Utils.GRASS_FOLDER, self.tr('GRASS7 folder'),
Grass7Utils.grassPath()))
Grass7Utils.grassPath(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
Grass7Utils.GRASS_WIN_SHELL, self.tr('Msys folder'),
Grass7Utils.grassWinShell()))
Grass7Utils.grassWinShell(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
Grass7Utils.GRASS_LOG_COMMANDS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,17 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(
self.getDescription(),
LAStoolsUtils.LASTOOLS_FOLDER,
self.tr('LAStools folder'), LAStoolsUtils.LAStoolsPath()))
self.tr('LAStools folder'), LAStoolsUtils.LAStoolsPath(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
FusionUtils.FUSION_FOLDER,
self.tr('Fusion folder'), FusionUtils.FusionPath()))
self.tr('Fusion folder'), FusionUtils.FusionPath(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
LAStoolsUtils.WINE_FOLDER,
self.tr('Wine folder'), ''))
self.tr('Wine folder'), '', valuetype=Setting.FOLDER))

def getName(self):
return 'lidartools'
Expand Down
12 changes: 8 additions & 4 deletions python/plugins/processing/algs/otb/OTBAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,21 @@ def initializeSettings(self):
if OTBUtils.findOtbPath() is None:
ProcessingConfig.addSetting(Setting(self.getDescription(),
OTBUtils.OTB_FOLDER,
self.tr("OTB command line tools folder"), OTBUtils.otbPath()))
self.tr("OTB command line tools folder"), OTBUtils.otbPath(),
valuetype=Setting.FOLDER))
if OTBUtils.findOtbLibPath() is None:
ProcessingConfig.addSetting(Setting(self.getDescription(),
OTBUtils.OTB_LIB_FOLDER,
self.tr("OTB applications folder"), OTBUtils.otbLibPath()))
self.tr("OTB applications folder"), OTBUtils.otbLibPath(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
OTBUtils.OTB_SRTM_FOLDER,
self.tr("SRTM tiles folder"), OTBUtils.otbSRTMPath()))
self.tr("SRTM tiles folder"), OTBUtils.otbSRTMPath(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
OTBUtils.OTB_GEOID_FILE,
self.tr("Geoid file"), OTBUtils.otbGeoidPath()))
self.tr("Geoid file"), OTBUtils.otbGeoidPath(),
valuetype=Setting.FOLDER))

def unload(self):
AlgorithmProvider.unload(self)
Expand Down
11 changes: 7 additions & 4 deletions python/plugins/processing/algs/r/RAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,18 @@ def __init__(self):
def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.RSCRIPTS_FOLDER, self.tr('R Scripts folder'), RUtils.RScriptsFolder()))
self.getDescription(), RUtils.RSCRIPTS_FOLDER,
self.tr('R Scripts folder'), RUtils.RScriptsFolder(),
valuetype=Setting.FOLDER))
if isWindows():
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.R_FOLDER, self.tr('R folder'), RUtils.RFolder()))
RUtils.R_FOLDER, self.tr('R folder'), RUtils.RFolder(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.R_LIBS_USER, self.tr('R user library folder'), RUtils.RLibs()))
RUtils.R_LIBS_USER, self.tr('R user library folder'),
RUtils.RLibs(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
RUtils.R_USE64, self.tr('Use 64 bit version'), False))
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def __init__(self):
def initializeSettings(self):
if isWindows() or isMac():
ProcessingConfig.addSetting(Setting("SAGA",
SagaUtils.SAGA_FOLDER, self.tr('SAGA folder'), ''))
SagaUtils.SAGA_FOLDER, self.tr('SAGA folder'), '',
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting("SAGA",
SagaUtils.SAGA_IMPORT_EXPORT_OPTIMIZATION,
self.tr('Enable SAGA Import/Export optimizations'), False))
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/saga/SagaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def getSagaInstalledVersion(runSaga=False):

maxRetries = 5
retries = 0
if _installedVersionFound or not runSaga:
if _installedVersionFound and not runSaga:
return _installedVersion

if isWindows():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.TAUDEM_FOLDER,
self.tr('TauDEM command line tools folder'),
TauDEMUtils.taudemPath()))
TauDEMUtils.taudemPath(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.TAUDEM_MULTIFILE_FOLDER,
self.tr('TauDEM multifile command line tools folder'),
TauDEMUtils.taudemMultifilePath()))
TauDEMUtils.taudemMultifilePath(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.TAUDEM_USE_SINGLEFILE,
self.tr('Enable singlefile TauDEM tools'), True))
Expand All @@ -93,7 +93,7 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.MPIEXEC_FOLDER,
self.tr('MPICH2/OpenMPI bin directory'),
TauDEMUtils.mpiexecPath()))
TauDEMUtils.mpiexecPath(), valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.MPI_PROCESSES,
self.tr('Number of MPI parallel processes to use'), 2))
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/core/ProcessingConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def initialize():
ProcessingConfig.addSetting(Setting(
ProcessingConfig.tr('General'),
ProcessingConfig.OUTPUT_FOLDER,
ProcessingConfig.tr('Output folder'), tempFolder()))
ProcessingConfig.tr('Output folder'), tempFolder(),
valuetype=Setting.FOLDER))
ProcessingConfig.addSetting(Setting(
ProcessingConfig.tr('General'),
ProcessingConfig.SHOW_CRS_DEF,
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/processing/gui/ConfigDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
***************************************************************************
"""


__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand All @@ -33,7 +34,7 @@
QStandardItemModel, QStandardItem, QMessageBox, QStyledItemDelegate,
QLineEdit, QSpinBox, QDoubleSpinBox, QWidget, QToolButton, QHBoxLayout)

from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.ProcessingConfig import ProcessingConfig, Setting
from processing.core.Processing import Processing

pluginPath = os.path.split(os.path.dirname(__file__))[0]
Expand Down Expand Up @@ -165,7 +166,7 @@ class SettingItem(QStandardItem):
def __init__(self, setting):
QStandardItem.__init__(self)
self.setting = setting

self.setData(setting.valuetype, Qt.UserRole)
if isinstance(setting.value, bool):
self.setCheckable(True)
self.setEditable(False)
Expand Down Expand Up @@ -199,10 +200,9 @@ def createEditor(
spnBox.setDecimals(6)
return spnBox
elif isinstance(value, (str, unicode)):
if os.path.isdir(value):
valuetype = self.convertValue(index.model().data(index, Qt.UserRole))
if valuetype == Setting.FOLDER:
return FileDirectorySelector(parent)
elif os.path.isfile(value):
return FileDirectorySelector(parent, True)
else:
return FileDirectorySelector(parent, True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
ProcessingConfig.addSetting(Setting(self.getDescription(),
ModelerUtils.MODELS_FOLDER, self.tr('Models folder', 'ModelerAlgorithmProvider'),
ModelerUtils.modelsFolder()))
ModelerUtils.modelsFolder(), valuetype=Setting.FOLDER))

def setAlgsList(self, algs):
ModelerUtils.allAlgs = algs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(self.getDescription(),
ScriptUtils.SCRIPTS_FOLDER,
self.tr('Scripts folder', 'ScriptAlgorithmProvider'),
ScriptUtils.scriptsFolder()))
ScriptUtils.scriptsFolder(), valuetype=Setting.FOLDER))

def unload(self):
AlgorithmProvider.unload(self)
Expand Down

0 comments on commit b80a1bc

Please sign in to comment.