Skip to content
Permalink
Browse files
Processing - Support OutputVector with no geometry in GUI
  • Loading branch information
arnaud-morvan committed May 17, 2016
1 parent fc5f70c commit afbe9141146f790fdf1c0d613c648f18a5192d61
Showing with 35 additions and 9 deletions.
  1. +5 −2 python/plugins/processing/gui/OutputSelectionPanel.py
  2. +30 −7 python/plugins/processing/gui/ParametersPanel.py
@@ -142,7 +142,9 @@ def saveToPostGIS(self):
password = settings.value(mySettings + '/password')
uri = QgsDataSourceURI()
uri.setConnection(host, str(port), dbname, user, password)
uri.setDataSource(dlg.schema, dlg.table, "the_geom")
uri.setDataSource(dlg.schema, dlg.table,
"the_geom" if self.output.hasGeometry() else None)

connInfo = uri.connectionInfo()
(success, user, passwd) = QgsCredentials.instance().get(connInfo, None, None)
if success:
@@ -182,7 +184,8 @@ def saveToSpatialite(self):

uri = QgsDataSourceURI()
uri.setDatabase(fileName)
uri.setDataSource('', self.output.name.lower(), 'the_geom')
uri.setDataSource('', self.output.name.lower(),
'the_geom' if self.output.hasGeometry() else None)
self.leText.setText("spatialite:" + uri.uri())

def saveToMemory(self):
@@ -259,6 +259,22 @@ def initWidgets(self):
self.checkBoxes[output.name] = check
self.valueItems[output.name] = widget

if isinstance(output, OutputVector):
if output.base_input in self.dependentItems:
items = self.dependentItems[output.base_input]
else:
items = []
self.dependentItems[output.base_input] = items
items.append(output)

base_input = self.alg.getParameterFromName(output.base_input)
if isinstance(base_input, ParameterVector):
layers = dataobjects.getVectorLayers(base_input.shapetype)
else:
layers = dataobjects.getTables()
if len(layers) > 0:
output.base_layer = layers[0]

def buttonToggled(self, value):
if value:
sender = self.sender()
@@ -343,7 +359,7 @@ def getWidgetFromParameter(self, param):
else:
items = []
self.dependentItems[param.parent] = items
items.append(param.name)
items.append(param)
parent = self.alg.getParameterFromName(param.parent)
if isinstance(parent, ParameterVector):
layers = dataobjects.getVectorLayers(parent.shapetype)
@@ -434,12 +450,15 @@ def updateDependentFields(self):
return
children = self.dependentItems[sender.name]
for child in children:
widget = self.valueItems[child]
widget.clear()
if self.alg.getParameterFromName(child).optional:
widget.addItem(self.tr('[not set]'))
widget.addItems(self.getFields(layer,
self.alg.getParameterFromName(child).datatype))
if isinstance(child, ParameterTableField):
widget = self.valueItems[child.name]
widget.clear()
if self.alg.getParameterFromName(child).optional:
widget.addItem(self.tr('[not set]'))
widget.addItems(self.getFields(layer,
self.alg.getParameterFromName(child).datatype))
if isinstance(child, OutputVector):
child.base_layer = layer

def getFields(self, layer, datatype):
fieldTypes = []
@@ -460,4 +479,8 @@ def somethingDependsOnThisParameter(self, parent):
if isinstance(param, ParameterTableField):
if param.parent == parent.name:
return True
for output in self.alg.outputs:
if isinstance(output, OutputVector):
if output.base_layer == parent.name:
return True
return False

0 comments on commit afbe914

Please sign in to comment.