Skip to content
Permalink
Browse files

added table field support

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@17 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com
volayaf@gmail.com committed Jan 18, 2012
1 parent 7a356f5 commit 9c5fcdffd6e0609abd86078110463b969f964ad8

This file was deleted.

@@ -13,6 +13,7 @@
from sextante.parameters.ParameterNumber import ParameterNumber
from sextante.parameters.ParameterRange import ParameterRange
from sextante.parameters.ParameterTableField import ParameterTableField
from sextante.parameters.ParameterTable import ParameterTable

try:
_fromUtf8 = QtCore.QString.fromUtf8
@@ -36,7 +37,7 @@ def setupUi(self, dialog, alg):
self.alg = alg
self.dialog = dialog
self.valueItems = {}
self.depentItems = {}
self.dependentItems = {}
dialog.setObjectName(_fromUtf8("Parameters"))
dialog.resize(650, 450)
self.buttonBox = QtGui.QDialogButtonBox(dialog)
@@ -77,13 +78,25 @@ def getWidgetFromParameter(self, param):
item.addItem(self.NOT_SELECTED, None)
for layer in layers:
item.addItem(layer.name(), layer)
item.currentIndexChanged.connect(self.updateDependentFields)
item.name = param.name
elif isinstance(param, ParameterBoolean):
item = QtGui.QComboBox()
item.addItem("Yes")
item.addItem("No")
elif isinstance(param, ParameterTableField):
item = QtGui.QComboBox()
item = self.getFields(QGisLayers.getVectorLayers()[0])
if param.parent in self.dependentItems:
list = self.dependentItems[param.parent]
else:
list = []
self.dependentItems[param.parent] = list
list.append(param.name)
layers = QGisLayers.getVectorLayers()
if len(layers)>0:
fields = self.getFields(layers[0])
for i in fields:
item.addItem(fields[i].name())
elif isinstance(param, ParameterSelection):
item = QtGui.QComboBox()
item.addItems(param.options)
@@ -108,7 +121,23 @@ def getWidgetFromParameter(self, param):

return item

def updateDependentFields(self):
sender = self.dialog.sender()
if not isinstance(sender, QComboBox):
return
layer = sender.itemData(sender.currentIndex()).toPyObject()
children = self.dependentItems[sender.name]
for child in children:
widget = self.valueItems[child]
widget.clear()
fields = self.getFields(layer)
for i in fields:
widget.addItem(fields[i].name())


def getFields(self, layer):
return layer.dataProvider().fields()



def setTableContent(self):
@@ -160,9 +189,11 @@ def setParamValues(self):
def setParamValue(self, param, widget):

if isinstance(param, ParameterRaster):
param.value = widget.itemData(widget.currentIndex())
param.value = widget.itemData(widget.currentIndex()).toPyObject()
elif isinstance(param, ParameterVector):
param.value = widget.itemData(widget.currentIndex())
param.value = widget.itemData(widget.currentIndex()).toPyObject()
elif isinstance(param, ParameterTable):
param.value = widget.itemData(widget.currentIndex()).toPyObject()
elif isinstance(param, ParameterBoolean):
param.value = widget.currentIndex() == 0
elif isinstance(param, ParameterSelection):
@@ -128,13 +128,14 @@ def fillTree(self):
providerItem.setText(0,providerName)

for groupItem in groups.values():
groupItem.sortChildren(0, Qt.AscendingOrder)
#groupItem.sortChildren(0, Qt.AscendingOrder)
providerItem.addChild(groupItem)
self.algorithmTree.addTopLevelItem(providerItem)
providerItem.setExpanded(True)
for groupItem in groups.values():
if text != "":
groupItem.setExpanded(True)
self.algorithmTree.sortItems(0, Qt.AscendingOrder)


class TreeAlgorithmItem(QtGui.QTreeWidgetItem):
@@ -75,7 +75,7 @@ def defineCharacteristicsFromFile(self):
param = ParameterTable()
param.name = paramName
param.description = paramDescription
param.optional = not ("optional" in line)
param.optional = ("optional" in line)
lastParentParameterName = paramName;
self.putParameter(param)
elif "static" in line:
@@ -113,14 +113,14 @@ def defineCharacteristicsFromFile(self):
param = ParameterMultipleInput()
param.name = paramName
param.description = paramDescription
param.optional = not ("optional" in line)
param.optional = ("optional" in line)
param.datatype=ParameterMultipleInput.TYPE_RASTER
self.putParameter(param)
else:
param = ParameterRaster()
param.name = paramName
param.description = paramDescription
param.optional = not ("optional" in line)
param.optional = ("optional" in line)
self.putParameter(param)
else:
output = OutputRaster()
@@ -133,14 +133,14 @@ def defineCharacteristicsFromFile(self):
param = ParameterMultipleInput()
param.name = paramName
param.description = paramDescription
param.optional = not ("optional" in line)
param.optional = ("optional" in line)
param.datatype=ParameterMultipleInput.TYPE_VECTOR_ANY
self.putParameter(param)
else:
param = ParameterVector()
param.name = paramName
param.description = paramDescription
param.optional = not ("optional" in line)
param.optional = ("optional" in line)
param.shapetype = ParameterVector.VECTOR_TYPE_ANY
lastParentParameterName = paramName;
self.putParameter(param)

0 comments on commit 9c5fcdf

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