mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Merge pull request #1490 from radosuav/small_processing_fixes2
[processing] Small fixes 2
This commit is contained in:
commit
5c9cb5a0cd
@ -138,7 +138,7 @@ class GdalUtils:
|
||||
def escapeAndJoin(strList):
|
||||
joined = ''
|
||||
for s in strList:
|
||||
if ' ' in s:
|
||||
if s[0]!='-' and ' ' in s:
|
||||
escaped = '"' + s.replace('\\', '\\\\').replace('"', '\\"') \
|
||||
+ '"'
|
||||
else:
|
||||
|
@ -361,17 +361,10 @@ class GeoAlgorithm:
|
||||
if layer.source() == inputlayer:
|
||||
self.crs = layer.crs()
|
||||
return
|
||||
if isinstance(param, ParameterRaster) \
|
||||
or isinstance(param, ParameterMultipleInput) \
|
||||
and param.datatype \
|
||||
== ParameterMultipleInput.TYPE_RASTER:
|
||||
p = QgsProviderRegistry.instance().provider('gdal',
|
||||
inputlayer)
|
||||
else:
|
||||
p = QgsProviderRegistry.instance().provider('ogr',
|
||||
inputlayer)
|
||||
p = dataobjects.getObjectFromUri(inputlayer)
|
||||
if p is not None:
|
||||
self.crs = p.crs()
|
||||
p = None
|
||||
return
|
||||
try:
|
||||
from qgis.utils import iface
|
||||
|
@ -286,24 +286,39 @@ class Processing:
|
||||
if alg is None:
|
||||
print 'Error: Algorithm not found\n'
|
||||
return
|
||||
if len(args) != alg.getVisibleParametersCount() \
|
||||
+ alg.getVisibleOutputsCount():
|
||||
print 'Error: Wrong number of parameters'
|
||||
processing.alghelp(algOrName)
|
||||
return
|
||||
|
||||
alg = alg.getCopy()
|
||||
if isinstance(args, dict):
|
||||
# Set params by name
|
||||
for (name, value) in args.items():
|
||||
if alg.getParameterFromName(name).setValue(value):
|
||||
|
||||
if len(args) == 1 and isinstance(args[0], dict):
|
||||
# Set params by name and try to run the alg even if not all parameter values are provided,
|
||||
# by using the default values instead.
|
||||
setParams = []
|
||||
for (name, value) in args[0].items():
|
||||
param = alg.getParameterFromName(name)
|
||||
if param and param.setValue(value):
|
||||
setParams.append(name)
|
||||
continue
|
||||
if alg.getOutputFromName(name).setValue(value):
|
||||
output = alg.getOutputFromName(name)
|
||||
if output and output.setValue(value):
|
||||
continue
|
||||
print 'Error: Wrong parameter value %s for parameter %s.' \
|
||||
% (value, name)
|
||||
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, "Error in %s. Wrong parameter value %s for parameter %s." \
|
||||
% (alg.name, value, name))
|
||||
return
|
||||
# fill any missing parameters with default values if allowed
|
||||
for param in alg.parameters:
|
||||
if param.name not in setParams:
|
||||
if not param.setValue(None):
|
||||
print ("Error: Missing parameter value for parameter %s." % (param.name))
|
||||
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, "Error in %s. Missing parameter value for parameter %s." \
|
||||
% (alg.name, param.name))
|
||||
return
|
||||
else:
|
||||
if len(args) != alg.getVisibleParametersCount() \
|
||||
+ alg.getVisibleOutputsCount():
|
||||
print 'Error: Wrong number of parameters'
|
||||
processing.alghelp(algOrName)
|
||||
return
|
||||
i = 0
|
||||
for param in alg.parameters:
|
||||
if not param.hidden:
|
||||
|
@ -63,7 +63,7 @@ class InputLayerSelectorPanel(QtGui.QWidget):
|
||||
path = ''
|
||||
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self, self.param.description, path,
|
||||
self.param.getFileFilter())
|
||||
'All files(*.*);;' + self.param.getFileFilter())
|
||||
if filename:
|
||||
self.text.addItem(filename, filename)
|
||||
self.text.setCurrentIndex(self.text.count() - 1)
|
||||
|
@ -123,6 +123,10 @@ class ProcessingToolbox(QDockWidget, Ui_ProcessingToolbox):
|
||||
if isinstance(child, TreeProviderItem):
|
||||
if child.providerName == providerName:
|
||||
child.refresh()
|
||||
# sort categories and items in categories
|
||||
child.sortChildren(0, Qt.AscendingOrder)
|
||||
for i in xrange(child.childCount()):
|
||||
child.child(i).sortChildren(0, Qt.AscendingOrder)
|
||||
break
|
||||
|
||||
def showPopupMenu(self, point):
|
||||
|
Loading…
x
Reference in New Issue
Block a user