[QGIS Commit] r13037 - trunk/qgis/python/plugins/fTools/tools

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Mar 9 20:11:11 EST 2010


Author: cfarmer
Date: 2010-03-09 20:11:11 -0500 (Tue, 09 Mar 2010)
New Revision: 13037

Modified:
   trunk/qgis/python/plugins/fTools/tools/doDefineProj.py
   trunk/qgis/python/plugins/fTools/tools/doJoinAttributes.py
   trunk/qgis/python/plugins/fTools/tools/doMeanCoords.py
   trunk/qgis/python/plugins/fTools/tools/doPointsInPolygon.py
   trunk/qgis/python/plugins/fTools/tools/doRandPoints.py
   trunk/qgis/python/plugins/fTools/tools/doRandom.py
   trunk/qgis/python/plugins/fTools/tools/doReProject.py
   trunk/qgis/python/plugins/fTools/tools/doRegPoints.py
   trunk/qgis/python/plugins/fTools/tools/doSelectByLocation.py
   trunk/qgis/python/plugins/fTools/tools/doSubsetSelect.py
   trunk/qgis/python/plugins/fTools/tools/doSumLines.py
   trunk/qgis/python/plugins/fTools/tools/doVectorGrid.py
   trunk/qgis/python/plugins/fTools/tools/doVectorSplit.py
   trunk/qgis/python/plugins/fTools/tools/frmRandom.ui
   trunk/qgis/python/plugins/fTools/tools/frmSubsetSelect.ui
   trunk/qgis/python/plugins/fTools/tools/ftools_utils.py
Log:
Large commit with several related bug fixes:
1) All fTools functions should now add all layers to dropdowns (including non-visible layers), 
2) All fTools functions should now be non-modal
3) Several fTools functions have been spead up slightly
4) Where possible, internal (cpp) functions have be used to replace older Python functions
5) Defining projections now also considers .qpj files
Fixes bugs #2502 and #2506, and possibly others?


Modified: trunk/qgis/python/plugins/fTools/tools/doDefineProj.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doDefineProj.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doDefineProj.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -30,11 +30,13 @@
         self.cmbLayer.addItems(layers)
 
     def updateProj1(self, layerName):
+        self.inRef.clear()
         tempLayer = ftools_utils.getVectorLayerByName(layerName)
         crs = tempLayer.dataProvider().crs().toProj4()
         self.inRef.insert(unicode(crs))
 
     def updateProj2(self, layerName):
+        self.outRef.clear()
         tempLayer = ftools_utils.getVectorLayerByName(layerName)
         crs = tempLayer.dataProvider().crs().toProj4()
         self.outRef.insert(unicode(crs))
@@ -82,11 +84,17 @@
                         outputFile = QFile( inPath + ".prj" )
                         outputFile.open( QIODevice.WriteOnly | QIODevice.Text )
                         outputPrj = QTextStream( outputFile )
-                        self.progressBar.setValue(70)
                         outputPrj << outputWkt
-                        self.progressBar.setValue(75)
                         outputPrj.flush()
                         outputFile.close()
+                        self.progressBar.setValue(70)
+                        checkFile = QFile( inPath + ".qpj" )
+                        if checkFile.exists():
+                            checkFile.open( QIODevice.WriteOnly | QIODevice.Text )
+                            outputPrj = QTextStream( checkFile )
+                            outputPrj << outputWkt
+                            outputPrj.flush()
+                            checkFile.close()
                         self.progressBar.setValue(95)
                         vLayer.setCrs(srsDefine)
                         self.progressBar.setValue(100)

Modified: trunk/qgis/python/plugins/fTools/tools/doJoinAttributes.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doJoinAttributes.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doJoinAttributes.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -56,15 +56,13 @@
     # populate layer list
     self.progressBar.setValue(0)
     mapCanvas = self.iface.mapCanvas()
-    for i in range(mapCanvas.layerCount()):
-      layer = mapCanvas.layer(i)
-      if layer.type() == layer.VectorLayer:
-        self.inShape.addItem(layer.name())
-        self.joinShape.addItem(layer.name())
+    layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
+    self.inShape.addItems(layers)
+    self.joinShape.addItems(layers)
 
   def iupdate(self, inputLayer):
-    changedLayer = self.getVectorLayerByName(unicode(inputLayer))
-    changedField = self.getFieldList(changedLayer)
+    changedLayer = ftools_utils.getVectorLayerByName(unicode(inputLayer))
+    changedField = ftools_utils.getFieldList(changedLayer)
     self.inField.clear()
     for i in changedField:
       self.inField.addItem(unicode(changedField[i].name()))
@@ -72,8 +70,8 @@
   def jupdate(self):
     inputLayer = self.joinShape.currentText()
     if inputLayer != "":
-      changedLayer = self.getVectorLayerByName(unicode(inputLayer))
-      changedField = self.getFieldList(changedLayer)
+      changedLayer = ftools_utils.getVectorLayerByName(unicode(inputLayer))
+      changedField = ftools_utils.getFieldList(changedLayer)
       self.joinField.clear()
       for i in changedField:
         self.joinField.addItem(unicode(changedField[i].name()))
@@ -103,18 +101,12 @@
         useTable = True
       joinField = self.joinField.currentText()
       outPath = self.outShape.text()
-      if outPath.contains("\\"):
-        outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
-      else:
-        outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
-      if outName.endsWith(".shp"):
-        outName = outName.left(outName.length() - 4)
       self.compute(inName, inField, joinName, joinField, outPath, keep, useTable, self.progressBar)
       self.outShape.clear()
       addToTOC = QMessageBox.question(self, self.tr("Join Attributes"), self.tr("Created output shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg( unicode(self.shapefileName) ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
       if addToTOC == QMessageBox.Yes:
-        vlayer = QgsVectorLayer(self.shapefileName, outName, "ogr")
-        QgsMapLayerRegistry.instance().addMapLayer(vlayer)
+        if not ftools_utils.addShapeToCanvas( unicode( outPath ) ):
+          QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%1" ).arg( unicode( outPath ) ))
     self.progressBar.setValue(0)
 
   def outFile(self):
@@ -152,11 +144,11 @@
       table = None
 
   def compute(self, inName, inField, joinName, joinField, outName, keep, useTable, progressBar):
-    layer1 = self.getVectorLayerByName(inName)
+    layer1 = ftools_utils.getVectorLayerByName(inName)
     provider1 = layer1.dataProvider()
     allAttrs = provider1.attributeIndexes()
     provider1.select(allAttrs)
-    fieldList1 = self.getFieldList(layer1).values()
+    fieldList1 = ftools_utils.getFieldList(layer1).values()
     index1 = provider1.fieldNameIndex(inField)
     if useTable:
       f = open(unicode(joinName), 'rb')
@@ -168,11 +160,11 @@
       table = map(lambda f: map(func, f), table)
 
     else:
-      layer2 = self.getVectorLayerByName(joinName)
+      layer2 = ftools_utils.getVectorLayerByName(joinName)
       provider2 = layer2.dataProvider()
       allAttrs = provider2.attributeIndexes()
       provider2.select(allAttrs)
-      fieldList2 = self.getFieldList(layer2)
+      fieldList2 = ftools_utils.getFieldList(layer2)
       index2 = provider2.fieldNameIndex(joinField)
     fieldList2 = self.testForUniqueness(fieldList1, fieldList2.values())
     seq = range(0, len(fieldList1) + len(fieldList2))
@@ -185,7 +177,6 @@
       if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
         return
     writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList1, provider1.geometryType(), sRs)
-
     inFeat = QgsFeature()
     outFeat = QgsFeature()
     joinFeat = QgsFeature()
@@ -196,7 +187,7 @@
     count = 0
     provider1.rewind()
     while provider1.nextFeature(inFeat):
-      inGeom = inFeat.geometry()
+      inGeom = QgsGeometry(inFeat.geometry())
       atMap1 = inFeat.attributeMap()
       outFeat.setAttributeMap(atMap1)
       outFeat.setGeometry(inGeom)
@@ -265,45 +256,10 @@
       for i in fieldList1:
         for j in fieldList2:
           if j.name() == i.name():
-            j = self.createUniqueFieldName(j)
+            j = ftools_utils.createUniqueFieldName(j)
             changed = True
     return fieldList2
-  
-  def createUniqueFieldName(self, field):
-    check = field.name().right(2)
-    if check.startsWith("_"):
-      (val,test) = check.right(1).toInt()
-      if test:
-        if val < 2:
-          val = 2
-        else:
-          val = val + 1
-        field.setName(field.name().left(len(field.name())-1) + unicode(val))
-      else:
-        field.setName(field.name() + "_2")
-    else:
-      field.setName(field.name() + "_2")
-    return field
-  
-  def getVectorLayerByName(self, myName):
-    mc = self.iface.mapCanvas()
-    nLayers = mc.layerCount()
-    for l in range(nLayers):
-      layer = mc.layer(l)
-      if layer.name() == unicode(myName):
-        vlayer = QgsVectorLayer(unicode(layer.source()),  unicode(myName),  unicode(layer.dataProvider().name()))
-        if vlayer.isValid():
-          return vlayer
-        else:
-          QMessageBox.information(self, self.tr("Join Attributes"), self.tr("Vector layer is not valid"))
 
-  def getFieldList(self, vlayer):
-    fProvider = vlayer.dataProvider()
-    feat = QgsFeature()
-    allAttrs = fProvider.attributeIndexes()
-    fProvider.select(allAttrs)
-    myFields = fProvider.fields()
-    return myFields
   def dbfreader(self, f):
       """Returns an iterator over records in a Xbase DBF file.
 

Modified: trunk/qgis/python/plugins/fTools/tools/doMeanCoords.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doMeanCoords.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doMeanCoords.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -19,10 +19,8 @@
         # populate layer list
         self.progressBar.setValue(0)
         mapCanvas = self.iface.mapCanvas()
-        for i in range(mapCanvas.layerCount()):
-            layer = mapCanvas.layer(i)
-            if layer.type() == layer.VectorLayer:
-                self.inShape.addItem(layer.name())
+        layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
+        self.inShape.addItems(layers)
 
     def updateUi(self):
         if self.function == 1:

Modified: trunk/qgis/python/plugins/fTools/tools/doPointsInPolygon.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doPointsInPolygon.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doPointsInPolygon.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -104,7 +104,7 @@
         index = polyProvider.fieldNameIndex(unicode(inField))
         if index == -1:
             index = polyProvider.fieldCount()
-            field = QgsField(unicode(inField), QVariant.Int, "real", 24, 15, self.tr("point count field"))
+            field = QgsField(unicode(inField), QVariant.Double, "real", 24, 15, self.tr("point count field"))
             fieldList[index] = field
         sRs = polyProvider.crs()
         check = QFile(self.shapefileName)

Modified: trunk/qgis/python/plugins/fTools/tools/doRandPoints.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doRandPoints.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doRandPoints.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -49,22 +49,20 @@
         self.progressBar.setValue(0)
         self.setWindowTitle(self.tr("Random Points"))
         self.mapCanvas = self.iface.mapCanvas()
-        for i in range(self.mapCanvas.layerCount()):
-            layer = self.mapCanvas.layer(i)
-            if (layer.type() == layer.VectorLayer and layer.geometryType() == QGis.Polygon) or layer.type() == layer.RasterLayer:
-                self.inShape.addItem(layer.name())
+        layers = ftools_utils.getLayerNames([QGis.Polygon, "Raster"])
+        self.inShape.addItems(layers)
 
 # If input layer is changed, update field list                
     def update(self, inputLayer):
         self.cmbField.clear()
-        changedLayer = self.getMapLayerByName(inputLayer)
+        changedLayer = ftools_utils.getMapLayerByName(unicode(inputLayer))
         if changedLayer.type() == changedLayer.VectorLayer:
             self.rdoStratified.setEnabled(True)
             self.rdoDensity.setEnabled(True)
             self.rdoField.setEnabled(True)
             self.label_4.setEnabled(True)
-            changedLayer = self.getVectorLayerByName(inputLayer)
-            changedFields = self.getFieldList(changedLayer)
+            changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
+            changedFields = ftools_utils.getFieldList(changedLayer)
             for i in changedFields:
                 self.cmbField.addItem(unicode(changedFields[i].name()))
         else:
@@ -95,7 +93,7 @@
             if outName.endsWith(".shp"):
                 outName = outName.left(outName.length() - 4)
             self.progressBar.setValue(5)
-            mLayer = self.getMapLayerByName(unicode(inName))
+            mLayer = ftools_utils.getMapLayerByName(unicode(inName))
             if mLayer.type() == mLayer.VectorLayer:
                 inLayer = QgsVectorLayer(unicode(mLayer.source()),  unicode(mLayer.name()),  unicode(mLayer.dataProvider().name()))
                 if self.rdoUnstratified.isChecked():
@@ -174,38 +172,6 @@
                 count = count + add
                 self.progressBar.setValue(count)
         return points
-    
-# Get vector layer by name from TOC     
-    def getVectorLayerByName(self, myName):
-        mc = self.mapCanvas
-        nLayers = mc.layerCount()
-        for l in range(nLayers):
-            layer = mc.layer(l)
-            if layer.name() == unicode(myName):
-                vlayer = QgsVectorLayer(unicode(layer.source()),  unicode(myName),  unicode(layer.dataProvider().name()))
-                if vlayer.isValid():
-                    return vlayer
-                else:
-                    QMessageBox.information(self, self.tr("Random Points"), self.tr("Vector layer is not valid"))
-    
-# Get map layer by name from TOC     
-    def getMapLayerByName(self, myName):
-        mc = self.mapCanvas
-        nLayers = mc.layerCount()
-        for l in range(nLayers):
-            layer = mc.layer(l)
-            if layer.name() == unicode(myName):
-                if layer.isValid():
-                    return layer
-# Retrieve the field map of a vector Layer
-    def getFieldList(self, vlayer):
-        fProvider = vlayer.dataProvider()
-        feat = QgsFeature()
-        allAttrs = fProvider.attributeIndexes()
-        fProvider.select(allAttrs)
-        myFields = fProvider.fields()
-        return myFields
-    
 
     def randomize(self, inLayer, outPath, minimum, design, value):
         outFeat = QgsFeature()

Modified: trunk/qgis/python/plugins/fTools/tools/doRandom.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doRandom.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doRandom.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
@@ -2,3 +3,3 @@
 from qgis.core import *
-
+import ftools_utils
 from ui_frmRandom import Ui_Dialog
@@ -16,13 +17,11 @@
         # populate layer list
         self.progressBar.setValue(0)
         mapCanvas = self.iface.mapCanvas()
-        for i in range(mapCanvas.layerCount()):
-            layer = mapCanvas.layer(i)
-            if layer.type() == layer.VectorLayer:
-                self.inShape.addItem(layer.name())
+        layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
+        self.inShape.addItems(layers)
         
     def changed(self, inputLayer):
-	changedLayer = self.getVectorLayerByName(inputLayer)
+	changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
 	changedProvider = changedLayer.dataProvider()
 	upperVal = changedProvider.featureCount()
 	self.spnNumber.setMaximum(upperVal)
@@ -34,7 +33,7 @@
             self.progressBar.setValue(10)
             inName = self.inShape.currentText()
 	    self.progressBar.setValue(20)
-    	    layer = self.getVectorLayerByName(inName)
+    	    layer = ftools_utils.getVectorLayerByName(inName)
     	    self.progressBar.setValue(30)
 	    if self.rdoNumber.isChecked():
 		value = self.spnNumber.value()
@@ -51,14 +50,3 @@
 	    self.progressBar.setValue(100)
 	    layer.setSelectedFeatures(selran)
 	    self.progressBar.setValue(0)
-
-#Gets vector layer by layername in canvas
-#Return: QgsVectorLayer            
-    def getVectorLayerByName(self, myName):
- 	mc = self.iface.mapCanvas()
- 	nLayers = mc.layerCount()
- 	for l in range(nLayers):
- 	    layer = mc.layer(l)
- 	    if layer.name() == unicode(myName):
- 	        if layer.isValid():
- 	           return layer

Modified: trunk/qgis/python/plugins/fTools/tools/doReProject.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doReProject.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doReProject.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 import ftools_utils
@@ -8,193 +9,118 @@
 import types
 
 class Dialog(QDialog, Ui_Dialog):
-	def __init__(self, iface):
-		QDialog.__init__(self)
-		self.iface = iface
-		self.setupUi(self)
-		QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
-		QObject.connect(self.btnProjection, SIGNAL("clicked()"), self.outProjFile)
-		QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1)
-		QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2)
-		self.setWindowTitle( self.tr("Export to new projection") )
-		self.progressBar.setValue(0)
-		mapCanvas = self.iface.mapCanvas()
-		for i in range(mapCanvas.layerCount()):
-			layer = mapCanvas.layer(i)
-			if layer.type() == layer.VectorLayer:
-				self.inShape.addItem(layer.name())
-				self.cmbLayer.addItem(layer.name())
+    def __init__(self, iface):
+        QDialog.__init__(self)
+        self.iface = iface
+        self.setupUi(self)
+        QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
+        QObject.connect(self.btnProjection, SIGNAL("clicked()"), self.outProjFile)
+        QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1)
+        QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2)
+        self.setWindowTitle( self.tr("Export to new projection") )
+        self.progressBar.setValue(0)
+        mapCanvas = self.iface.mapCanvas()
+        layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
+        self.inShape.addItems(layers)
+        self.cmbLayer.addItems(layers)
 
-	def updateProj1(self, layerName):
-		tempLayer = self.getVectorLayerByName(layerName)
-		crs = tempLayer.dataProvider().crs().toProj4()
-		self.inRef.insert(unicode(crs))
+    def updateProj1(self, layerName):
+        self.inRef.clear()
+        tempLayer = ftools_utils.getVectorLayerByName(layerName)
+        crs = tempLayer.dataProvider().crs().toProj4()
+        self.inRef.insert(unicode(crs))
 
-	def updateProj2(self, layerName):
-		tempLayer = self.getVectorLayerByName(layerName)
-		crs = tempLayer.dataProvider().crs().toProj4()
-		self.outRef.insert(unicode(crs))		
+    def updateProj2(self, layerName):
+        self.outRef.clear()
+        tempLayer = ftools_utils.getVectorLayerByName(layerName)
+        crs = tempLayer.dataProvider().crs().toProj4()
+        self.outRef.insert(unicode(crs))
 
-	def accept(self):
-		if self.inShape.currentText() == "":
-			QMessageBox.information(self, self.tr("Export to new projection"), self.tr("No input layer specified"))
-		elif self.outShape.text() == "":
-			QMessageBox.information(self, self.tr("Export to new projection"), self.tr("Please specify output shapefile"))
-		elif self.txtProjection.text() == "" and self.rdoProjection.isChecked():
-			QMessageBox.information(self, self.tr("Define current projection"), self.tr("Please specify spatial reference system"))
-		elif self.cmbLayer.currentText() == "" and self.rdoLayer.isChecked():
-			QMessageBox.information(self, self.tr("Define current projection"), self.tr("Please specify spatial reference system"))
-		else:
-			inName = self.inShape.currentText()
-			self.progressBar.setValue(5)
-			outPath = self.outShape.text()
-			self.progressBar.setValue(10)
-			if self.rdoProjection.isChecked(): outProj = self.txtProjection.text()
-			else: outProj = self.cmbLayer.currentText()
-			self.progressBar.setValue(15)
-			if outPath.contains("\\"): outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
-			else: outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
-			if outName.endsWith(".shp"): outName = outName.left(outName.length() - 4)
-			if self.reProject(inName, unicode(outPath), unicode(outProj), self.rdoProjection.isChecked(), self.progressBar):
-				self.outShape.clear()
-				self.progressBar.setValue(100)
-				addToTOC = QMessageBox.question(self, self.tr("Export to new projection"), self.tr("Created projected shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg( outPath ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
-				if addToTOC == QMessageBox.Yes:
-					self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
-					QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
-		self.progressBar.setValue(0)
+    def accept(self):
+        if self.inShape.currentText() == "":
+            QMessageBox.information(self, self.tr("Export to new projection"), self.tr("No input layer specified"))
+        elif self.outShape.text() == "":
+            QMessageBox.information(self, self.tr("Export to new projection"), self.tr("Please specify output shapefile"))
+        elif self.txtProjection.text() == "" and self.rdoProjection.isChecked():
+            QMessageBox.information(self, self.tr("Define current projection"), self.tr("Please specify spatial reference system"))
+        elif self.cmbLayer.currentText() == "" and self.rdoLayer.isChecked():
+            QMessageBox.information(self, self.tr("Define current projection"), self.tr("Please specify spatial reference system"))
+        else:
+            inName = self.inShape.currentText()
+            self.progressBar.setValue(5)
+            outPath = self.outShape.text()
+            self.progressBar.setValue(10)
+            if self.rdoProjection.isChecked(): outProj = self.txtProjection.text()
+            else: outProj = self.cmbLayer.currentText()
+            self.progressBar.setValue(15)
+            if outPath.contains("\\"): outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
+            else: outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
+            if outName.endsWith(".shp"): outName = outName.left(outName.length() - 4)
+            if self.reProject(inName, unicode(outPath), unicode(outProj), self.rdoProjection.isChecked(), self.progressBar):
+                self.outShape.clear()
+                self.progressBar.setValue(100)
+                addToTOC = QMessageBox.question(self, self.tr("Export to new projection"), self.tr("Created projected shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg( outPath ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
+                if addToTOC == QMessageBox.Yes:
+                    self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
+                    QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
+        self.progressBar.setValue(0)
 
-	def outProjFile(self):
-		format = QString( "<h2>%1</h2>%2 <br/> %3" )
-		header = self.tr( "Choose output CRS:" )
-		sentence1 = self.tr( "Please select the projection system to be used by the output layer." )
-		sentence2 = self.tr( "Output layer will be projected from it's current CRS to the output CRS." )
-		self.projSelect = QgsGenericProjectionSelector(self, Qt.Widget)
-		self.projSelect.setMessage( format.arg( header ).arg( sentence1 ).arg( sentence2 ))
-		if self.projSelect.exec_():
-			projString = self.projSelect.selectedProj4String()
-			if projString == "":
-				QMessageBox.information(self, self.tr("Export to new projection"), self.tr("No Valid CRS selected"))
-				return
-			else:
-				self.txtProjection.clear()
-				self.txtProjection.insert(projString)
-		else:
-			return
+    def outProjFile(self):
+        format = QString( "<h2>%1</h2>%2 <br/> %3" )
+        header = self.tr( "Choose output CRS:" )
+        sentence1 = self.tr( "Please select the projection system to be used by the output layer." )
+        sentence2 = self.tr( "Output layer will be projected from it's current CRS to the output CRS." )
+        self.projSelect = QgsGenericProjectionSelector(self, Qt.Widget)
+        self.projSelect.setMessage( format.arg( header ).arg( sentence1 ).arg( sentence2 ))
+        if self.projSelect.exec_():
+            projString = self.projSelect.selectedProj4String()
+            if projString == "":
+                QMessageBox.information(self, self.tr("Export to new projection"), self.tr("No Valid CRS selected"))
+                return
+            else:
+                self.txtProjection.clear()
+                self.txtProjection.insert(projString)
+        else:
+            return
 
-	def outFile(self):
-		self.outShape.clear()
-		( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
-		if self.shapefileName is None or self.encoding is None:
-			return
-		self.outShape.setText( QString( self.shapefileName ) )
+    def outFile(self):
+        self.outShape.clear()
+        ( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
+        if self.shapefileName is None or self.encoding is None:
+            return
+        self.outShape.setText( QString( self.shapefileName ) )
 
-	def reProject(self, inName, outPath, outProj, predefined, progressBar):
-		vlayer = self.getVectorLayerByName(inName)
-		provider = vlayer.dataProvider()
-		feat = QgsFeature()
-		allAttrs = provider.attributeIndexes()
-		progressBar.setValue(2)
-		provider.select(allAttrs)
-		fieldList = self.getFieldList(vlayer)
-		crsDest = QgsCoordinateReferenceSystem()
-		if predefined:
-			crsDest.createFromProj4(outProj)
-		else:
-			destLayer = self.getVectorLayerByName(outProj)
-			crsDest = destLayer.dataProvider().crs()
-		if not crsDest.isValid():
-			QMessageBox.information(self, self.tr("Export to new projection"), self.tr("Output spatial reference system is not valid"))
-			return False
-		else:
-			progressBar.setValue(5)
-			crsSrc = provider.crs()
-			if crsSrc != crsDest:
-				xform = QgsCoordinateTransform(crsSrc, crsDest)
-				progressBar.setValue(10)
-				check = QFile(self.shapefileName)
-				if check.exists():
-					if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
-						return
-				writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, provider.geometryType(), crsDest)
-				#writer = QgsVectorFileWriter(outPath, "UTF-8", fieldList, provider.geometryType(), crsDest)
-				if self.pointReproject(vlayer, xform, writer, progressBar): return True
-				else: return False
-			else:
-				QMessageBox.information(self, self.tr("Export to new projection"), self.tr("Identical output spatial reference system chosen"))
-				return False
+    def reProject(self, inName, outPath, outProj, predefined, progressBar):
+        vlayer = ftools_utils.getVectorLayerByName(inName)
+        provider = vlayer.dataProvider()
+        feat = QgsFeature()
+        allAttrs = provider.attributeIndexes()
+        progressBar.setValue(2)
+        provider.select(allAttrs)
+        fieldList = ftools_utils.getFieldList(vlayer)
+        crsDest = QgsCoordinateReferenceSystem()
+        if predefined:
+            crsDest.createFromProj4(outProj)
+        else:
+            destLayer = ftools_utils.getVectorLayerByName(outProj)
+            crsDest = destLayer.dataProvider().crs()
+        if not crsDest.isValid():
+            QMessageBox.information(self, self.tr("Export to new projection"), self.tr("Output spatial reference system is not valid"))
+            return False
+        else:
+            progressBar.setValue(5)
+            crsSrc = provider.crs()
+            if crsSrc != crsDest:
+                xform = QgsCoordinateTransform(crsSrc, crsDest)
+                progressBar.setValue(10)
+                check = QFile(self.shapefileName)
+                if check.exists():
+                    if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
+                        return
+                error = QgsVectorFileWriter.writeAsShapefile(vlayer, self.shapefileName, self.encoding, crsDest, False)
+                if error == QgsVectorFileWriter.NoError: return True
+                else: return False
+            else:
+                QMessageBox.information(self, self.tr("Export to new projection"), self.tr("Identical output spatial reference system chosen"))
+                return False
 
-# Gets vector layer by layername in canvas
-	def getVectorLayerByName(self, myName):
-		mc = self.iface.mapCanvas()
-		nLayers = mc.layerCount()
-		for l in range(nLayers):
-			layer = mc.layer(l)
-			if unicode(layer.name()) == unicode(myName):
-				vlayer = QgsVectorLayer(unicode(layer.source()),  unicode(myName),  unicode(layer.dataProvider().name()))
-				if vlayer.isValid():
-					return vlayer
-
-#Retrieve the field map of a vector Layer
-#Return: QgsFieldMap
-	def getFieldList(self, vlayer):
-		fProvider = vlayer.dataProvider()
-		feat = QgsFeature()
-		allAttrs = fProvider.attributeIndexes()
-		fProvider.select(allAttrs)
-		myFields = fProvider.fields()
-		return myFields
-
-#Converts all geometries to points, and reprojects using specified QgsCoordinateTransformation   
-#Output: Reprojected shapefile with attributes...
-	def pointReproject(self, vlayer, xform, writer, progressBar):
-		provider = vlayer.dataProvider()
-		if provider.featureCount() == 0:
-		  return
-
-		allAttrs = provider.attributeIndexes()
-		provider.select(allAttrs)
-		feat = QgsFeature()
-		outfeat = QgsFeature()
-		count = 90.00 / provider.featureCount()
-		
-		while provider.nextFeature(feat):
-			geom = feat.geometry()
-			multi_geom = QgsGeometry()
-			temp_geom = []
-			if geom.type() == 0: # it's a point
-				if geom.isMultipart():
-					multi_geom = geom.asMultiPoint() #multi_geom is a multipoint
-					outfeat.setGeometry(QgsGeometry.fromMultiPoint([xform.transform(item) for item in multi_geom]))
-				else:
-					tpoint = xform.transform(geom.asPoint())
-					outfeat.setGeometry(QgsGeometry.fromPoint(tpoint))
-					#outfeat.setGeometry(QgsGeometry.fromPoint(xform.transform(geom.asPoint()))
-			elif geom.type() == 1: # it's a line
-				temp_lines = []
-				if geom.isMultipart():
-					multi_geom = geom.asMultiPolyline() #multi_geog is a multiline
-					outfeat.setGeometry(QgsGeometry.fromMultiPolyline([mappedTransform(xform, item) for item in multi_geom]))
-				else:
-					multi_geom = geom.asPolyline() #multi_geom is a line
-					outfeat.setGeometry(QgsGeometry.fromPolyline([xform.transform(item) for item in multi_geom]))
-			elif geom.type() == 2: # it's a polygon
-				if geom.isMultipart():
-					multi_geom = geom.asMultiPolygon() #multi_geom is a multipolygon
-					#outfeat.setGeometry(QgsGeometry.fromMultiPolygon(multi_geom))
-					outfeat.setGeometry(QgsGeometry.fromMultiPolygon([[mappedTransform(xform, item) for item in temp] for temp in multi_geom]))
-				else:
-					multi_geom = geom.asPolygon() #multi_geom is a polygon
-					outfeat.setGeometry(QgsGeometry.fromPolygon([mappedTransform(xform, item) for item in multi_geom]))
-			else: # don't know what it is...
-				return False
-			atMap = feat.attributeMap()
-			outfeat.setAttributeMap(atMap)
-			writer.addFeature(outfeat)
-			progressBar.setValue(progressBar.value() + count)
-		del writer
-		return True
-
-def mappedTransform(xform, inList):
-	return [xform.transform(elem) for elem in inList]
-

Modified: trunk/qgis/python/plugins/fTools/tools/doRegPoints.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doRegPoints.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doRegPoints.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -48,9 +48,8 @@
         self.setWindowTitle( self.tr("Regular points") )
         self.progressBar.setValue(0)
         self.mapCanvas = self.iface.mapCanvas()
-        for i in range(self.mapCanvas.layerCount()):
-            layer = self.mapCanvas.layer(i)
-            self.inShape.addItem(layer.name())
+        layers = ftools_utils.getLayerNames("all")
+        self.inShape.addItems(layers)
 
     def accept(self):
         if not self.rdoCoordinates.isChecked() and self.inShape.currentText() == "":
@@ -74,7 +73,7 @@
             if self.chkRandom.isChecked(): offset = True
             else: offset = False
             if self.rdoBoundary.isChecked():
-                mLayer = self.getMapLayerByName(unicode(inName))
+                mLayer = ftools_utils.getMapLayerByName(unicode(inName))
                 boundBox = mLayer.extent()
                 crs = mLayer.crs()
             else:
@@ -106,32 +105,8 @@
             if pGeom.intersects(bound):
                 points.append(pGeom)
                 i = i + 1
-        return points
-    
-# Get vector layer by name from TOC     
-    def getVectorLayerByName(self, myName):
-        mc = self.mapCanvas
-        nLayers = mc.layerCount()
-        for l in range(nLayers):
-            layer = mc.layer(l)
-            if layer.name() == unicode(myName):
-                vlayer = QgsVectorLayer(unicode(layer.source()),  unicode(myName),  unicode(layer.dataProvider().name()))
-                if vlayer.isValid():
-                    return vlayer
-                else:
-                    QMessageBox.information(self, self.tr("Generate Regular Points"), self.tr("Vector layer is not valid"))
-    
-# Get map layer by name from TOC     
-    def getMapLayerByName(self, myName):
-        mc = self.mapCanvas
-        nLayers = mc.layerCount()
-        for l in range(nLayers):
-            layer = mc.layer(l)
-            if layer.name() == unicode(myName):
-                if layer.isValid():
-                    return layer
-    
- 
+        return points    
+
     def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
         area = bound.width() * bound.height()
         if offset:

Modified: trunk/qgis/python/plugins/fTools/tools/doSelectByLocation.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doSelectByLocation.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doSelectByLocation.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -1,91 +1,79 @@
-from PyQt4.QtCore import *
+# -*- coding: utf-8 -*-
+from PyQt4.QtCore import *
 from PyQt4.QtGui import *
-
+import ftools_utils
 from qgis.core import *
 from ui_frmPointsInPolygon import Ui_Dialog
 
 class Dialog(QDialog, Ui_Dialog):
 
-	def __init__(self, iface):
-		QDialog.__init__(self)
-		self.iface = iface
-		# Set up the user interface from Designer.
-		self.setupUi(self)
+    def __init__(self, iface):
+        QDialog.__init__(self)
+        self.iface = iface
+        # Set up the user interface from Designer.
+        self.setupUi(self)
 
-		# populate layer list
-		self.progressBar.setValue(0)
-		mapCanvas = self.iface.mapCanvas()
-		for i in range(mapCanvas.layerCount()):
-			layer = mapCanvas.layer(i)
-			if layer.type() == layer.VectorLayer:
-				self.inPolygon.addItem(layer.name())
-				self.inPoint.addItem(layer.name())
-		self.updateUI()
-		self.cmbModify.addItems([self.tr("creating new selection"), self.tr("adding to current selection"), self.tr("removing from current selection")])
+        # populate layer list
+        self.progressBar.setValue(0)
+        mapCanvas = self.iface.mapCanvas()
+        layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
+        self.inPolygon.addItems(layers)
+        self.inPoint.addItems(layers)
+        self.updateUI()
+        self.cmbModify.addItems([self.tr("creating new selection"), self.tr("adding to current selection"), self.tr("removing from current selection")])
 
-	def updateUI(self):
-		self.label_5.setVisible(False)
-		self.lnField.setVisible(False)
-		self.outShape.setVisible(False)
-		self.toolOut.setVisible(False)
-		self.label_2.setVisible(False)
-		self.setWindowTitle(self.tr("Select by location"))
-		self.label_3.setText(self.tr("Select features in:"))
-		self.label_4.setText(self.tr("that intersect features in:"))
-		self.label_mod = QLabel(self)
-		self.label_mod.setObjectName("label_mod")
-		self.label_mod.setText(self.tr("Modify current selection by:"))
-		self.cmbModify = QComboBox(self)
-		self.cmbModify.setObjectName("cmbModify")
-		self.gridLayout.addWidget(self.label_mod,2,0,1,1)
-		self.gridLayout.addWidget(self.cmbModify,3,0,1,1)
-		self.resize(381, 100)
+    def updateUI(self):
+        self.label_5.setVisible(False)
+        self.lnField.setVisible(False)
+        self.outShape.setVisible(False)
+        self.toolOut.setVisible(False)
+        self.label_2.setVisible(False)
+        self.setWindowTitle(self.tr("Select by location"))
+        self.label_3.setText(self.tr("Select features in:"))
+        self.label_4.setText(self.tr("that intersect features in:"))
+        self.label_mod = QLabel(self)
+        self.label_mod.setObjectName("label_mod")
+        self.label_mod.setText(self.tr("Modify current selection by:"))
+        self.cmbModify = QComboBox(self)
+        self.cmbModify.setObjectName("cmbModify")
+        self.gridLayout.addWidget(self.label_mod,2,0,1,1)
+        self.gridLayout.addWidget(self.cmbModify,3,0,1,1)
+        self.resize(381, 100)
 
-	def accept(self):
-		if self.inPolygon.currentText() == "":
-			QMessageBox.information(self, self.tr("Select by location"), self.tr( "Please specify input layer"))
-		elif self.inPoint.currentText() == "":
-			QMessageBox.information(self, self.tr("Select by location"), self.tr("Please specify select layer"))
-		else:
-			inPoly = self.inPolygon.currentText()
-			inPts = self.inPoint.currentText()
-			self.compute(inPoly, inPts, self.cmbModify.currentText())
-		self.progressBar.setValue(0)
+    def accept(self):
+        if self.inPolygon.currentText() == "":
+            QMessageBox.information(self, self.tr("Select by location"), self.tr( "Please specify input layer"))
+        elif self.inPoint.currentText() == "":
+            QMessageBox.information(self, self.tr("Select by location"), self.tr("Please specify select layer"))
+        else:
+            inPoly = self.inPolygon.currentText()
+            inPts = self.inPoint.currentText()
+            self.compute(inPoly, inPts, self.cmbModify.currentText())
+        self.progressBar.setValue(0)
 
-	def compute(self, inPoly, inPts, modify):
-		inputLayer = self.getVectorLayerByName(inPoly)
-		selectLayer = self.getVectorLayerByName(inPts)
-		inputProvider = inputLayer.dataProvider()
-		selectProvider = selectLayer.dataProvider()
-		feat = QgsFeature()
-		geom = QgsGeometry()
-		selectedSet = []
-		selectProvider.nextFeature(feat)
-		geomLayer = QgsGeometry(feat.geometry())
+    def compute(self, inPoly, inPts, modify):
+        inputLayer = ftools_utils.getVectorLayerByName(inPoly)
+        selectLayer = ftools_utils.getVectorLayerByName(inPts)
+        inputProvider = inputLayer.dataProvider()
+        selectProvider = selectLayer.dataProvider()
+        feat = QgsFeature()
+        geom = QgsGeometry()
+        selectedSet = []
+        selectProvider.nextFeature(feat)
+        geomLayer = QgsGeometry(feat.geometry())
 
-		self.progressBar.setMaximum( inputProvider.featureCount() + selectProvider.featureCount() )
+        self.progressBar.setMaximum( inputProvider.featureCount() + selectProvider.featureCount() )
 
-		while selectProvider.nextFeature(feat):
-			geomLayer = geomLayer.combine(QgsGeometry(feat.geometry()))
-			self.progressBar.setValue( self.progressBarValue() + 1 )
-		while inputProvider.nextFeature(feat):
-			geom = QgsGeometry(feat.geometry())
-			if geom.intersects(geomLayer):
-				selectedSet.append(feat.id())
-			self.progressBar.setValue( self.progressBarValue() + 1 )
-		if modify == self.tr("adding to current selection"):
-			selectedSet = list(set(inputLayer.selectedFeaturesIds()).union(selectedSet))
-		elif modify == self.tr("removing from current selection"):
-			selectedSet = list(set(inputLayer.selectedFeaturesIds()).difference(selectedSet))
-		inputLayer.setSelectedFeatures(selectedSet)
-
-#Gets vector layer by layername in canvas
-#Return: QgsVectorLayer
-	def getVectorLayerByName(self, myName):
-		mc = self.iface.mapCanvas()
-		nLayers = mc.layerCount()
-		for l in range(nLayers):
-			layer = mc.layer(l)
-			if layer.name() == unicode(myName):
-				if layer.isValid():
-					return layer
+        while selectProvider.nextFeature(feat):
+            geomLayer = geomLayer.combine(QgsGeometry(feat.geometry()))
+            self.progressBar.setValue( self.progressBar.value() + 1 )
+        while inputProvider.nextFeature(feat):
+            geom = QgsGeometry(feat.geometry())
+            if geom.intersects(geomLayer):
+                selectedSet.append(feat.id())
+            self.progressBar.setValue( self.progressBar.value() + 1 )
+        if modify == self.tr("adding to current selection"):
+            selectedSet = list(set(inputLayer.selectedFeaturesIds()).union(selectedSet))
+        elif modify == self.tr("removing from current selection"):
+            selectedSet = list(set(inputLayer.selectedFeaturesIds()).difference(selectedSet))
+        inputLayer.setSelectedFeatures(selectedSet)

Modified: trunk/qgis/python/plugins/fTools/tools/doSubsetSelect.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doSubsetSelect.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doSubsetSelect.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 #-----------------------------------------------------------
 #
 # Random selection within subsets
@@ -31,143 +32,108 @@
 #--------------------------------------------------------------------
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
-import random
+import random, ftools_utils
 from qgis.core import *
 from ui_frmSubsetSelect import Ui_Dialog
 
 class Dialog(QDialog, Ui_Dialog):
 
-	def __init__(self, iface):
-		QDialog.__init__(self)
-		self.iface = iface
-		# Set up the user interface from Designer.
-		self.setupUi(self)
-		QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
-		self.setWindowTitle(self.tr("Random selection within subsets"))
-		# populate layer list
-		self.progressBar.setValue(0)
-		mapCanvas = self.iface.mapCanvas()
-		for i in range(mapCanvas.layerCount()):
-			layer = mapCanvas.layer(i)
-			if layer.type() == layer.VectorLayer:
-				self.inShape.addItem(layer.name())
+    def __init__(self, iface):
+        QDialog.__init__(self)
+        self.iface = iface
+        # Set up the user interface from Designer.
+        self.setupUi(self)
+        QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
+        self.setWindowTitle(self.tr("Random selection within subsets"))
+        # populate layer list
+        self.progressBar.setValue(0)
+        mapCanvas = self.iface.mapCanvas()
+        layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
+        self.inShape.addItems(layers)
 
-	def update(self, inputLayer):
-		self.inField.clear()
-		changedLayer = self.getVectorLayerByName(inputLayer)
-		changedField = self.getFieldList(changedLayer)
-		for i in changedField:
-			self.inField.addItem(unicode(changedField[i].name()))
-		maxFeatures = changedLayer.dataProvider().featureCount()
-		self.spnNumber.setMaximum( maxFeatures )
+    def update(self, inputLayer):
+        self.inField.clear()
+        changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
+        changedField = ftools_utils.getFieldList(changedLayer)
+        for i in changedField:
+            self.inField.addItem(unicode(changedField[i].name()))
+        maxFeatures = changedLayer.dataProvider().featureCount()
+        self.spnNumber.setMaximum( maxFeatures )
 
-	def accept(self):
-		if self.inShape.currentText() == "":
-			QMessageBox.information(self, self.tr("Random selection within subsets"), self.tr("Please specify input vector layer"))
-		elif self.inField.currentText() == "":
-			QMessageBox.information(self, self.tr("Random selection within subsets"), self.tr("Please specify an input field"))
-		else:
-			inVect = self.inShape.currentText()
-			uidField = self.inField.currentText()
-			if self.rdoNumber.isChecked():
-				value = self.spnNumber.value()
-				perc = False
-			else:
-				value = self.spnPercent.value()
-				perc = True
-			self.compute(inVect, uidField, value, perc, self.progressBar)
-			self.progressBar.setValue(100)
-		self.progressBar.setValue(0)
+    def accept(self):
+        if self.inShape.currentText() == "":
+            QMessageBox.information(self, self.tr("Random selection within subsets"), self.tr("Please specify input vector layer"))
+        elif self.inField.currentText() == "":
+            QMessageBox.information(self, self.tr("Random selection within subsets"), self.tr("Please specify an input field"))
+        else:
+            inVect = self.inShape.currentText()
+            uidField = self.inField.currentText()
+            if self.rdoNumber.isChecked():
+                value = self.spnNumber.value()
+                perc = False
+            else:
+                value = self.spnPercent.value()
+                perc = True
+            self.compute(inVect, uidField, value, perc, self.progressBar)
+            self.progressBar.setValue(100)
+        self.progressBar.setValue(0)
 
-	def outFile(self):
-		self.outShape.clear()
-		fileDialog = QFileDialog()
-		fileDialog.setConfirmOverwrite(False)
-		outName = fileDialog.getSaveFileName(self, self.tr("Output Shapefile"),".", self.tr("Shapefiles (*.shp)"))
-		fileCheck = QFile(outName)
-		if fileCheck.exists():
-			QMessageBox.warning(self, self.tr("Random selection within subsets"), self.tr("Cannot overwrite existing shapefile..."))
-		else:
-			filePath = QFileInfo(outName).absoluteFilePath()
-			if filePath.right(4) != ".shp": filePath = filePath + ".shp"
-			if not outName.isEmpty():
-				self.outShape.clear()
-				self.outShape.insert(filePath)
+    def outFile(self):
+        self.outShape.clear()
+        fileDialog = QFileDialog()
+        fileDialog.setConfirmOverwrite(False)
+        outName = fileDialog.getSaveFileName(self, self.tr("Output Shapefile"),".", self.tr("Shapefiles (*.shp)"))
+        fileCheck = QFile(outName)
+        if fileCheck.exists():
+            QMessageBox.warning(self, self.tr("Random selection within subsets"), self.tr("Cannot overwrite existing shapefile..."))
+        else:
+            filePath = QFileInfo(outName).absoluteFilePath()
+            if filePath.right(4) != ".shp": filePath = filePath + ".shp"
+            if not outName.isEmpty():
+                self.outShape.clear()
+                self.outShape.insert(filePath)
 
-	def compute(self, inVect, inField, value, perc, progressBar):
-		vlayer = self.getVectorLayerByName(inVect)
-		vprovider = vlayer.dataProvider()
-		mlayer = self.getMapLayerByName(inVect)
-		allAttrs = vprovider.attributeIndexes()
-		vprovider.select(allAttrs)
-		index = vprovider.fieldNameIndex(inField)
-		#unique = []
-		#vprovider.uniqueValues(index, unique)
-		unique = self.getUniqueValues(vprovider, int(index))
-		inFeat = QgsFeature()
-		selran = []
-		mlayer.removeSelection(True)
-		nFeat = vprovider.featureCount() * len(unique)
-		nElement = 0
-		self.progressBar.setValue(0)
-		self.progressBar.setRange(0, nFeat)
-		if not len(unique) == mlayer.featureCount():
-			for i in unique:
-				vprovider.rewind()
-				FIDs= []
-				while vprovider.nextFeature(inFeat):
-					atMap = inFeat.attributeMap()
-					if atMap[index] == QVariant(i):
-						FID = inFeat.id()
-						FIDs.append(FID)
-					nElement += 1
-					self.progressBar.setValue(nElement)
-				if perc: selVal = int(round((value / 100.0000) * len(FIDs), 0))
-				else: selVal = value
-				if selVal >= len(FIDs): selran = FIDs
-				else: selran = random.sample(FIDs, selVal)
-				selran.extend(mlayer.selectedFeaturesIds())
-				mlayer.setSelectedFeatures(selran)
-		else:
-			mlayer.setSelectedFeatures(range(0, mlayer.featureCount()))
+    def compute(self, inVect, inField, value, perc, progressBar):
+        vlayer = ftools_utils.getVectorLayerByName(inVect)
+        vprovider = vlayer.dataProvider()
+        mlayer = self.getMapLayerByName(inVect)
+        allAttrs = vprovider.attributeIndexes()
+        vprovider.select(allAttrs)
+        index = vprovider.fieldNameIndex(inField)
+        #unique = []
+        #vprovider.uniqueValues(index, unique)
+        unique = ftools_utils.getUniqueValues(vprovider, int(index))
+        inFeat = QgsFeature()
+        selran = []
+        mlayer.removeSelection(True)
+        nFeat = vprovider.featureCount() * len(unique)
+        nElement = 0
+        self.progressBar.setValue(0)
+        self.progressBar.setRange(0, nFeat)
+        if not len(unique) == mlayer.featureCount():
+            for i in unique:
+                vprovider.rewind()
+                FIDs= []
+                while vprovider.nextFeature(inFeat):
+                    atMap = inFeat.attributeMap()
+                    if atMap[index] == QVariant(i):
+                        FID = inFeat.id()
+                        FIDs.append(FID)
+                    nElement += 1
+                    self.progressBar.setValue(nElement)
+                if perc: selVal = int(round((value / 100.0000) * len(FIDs), 0))
+                else: selVal = value
+                if selVal >= len(FIDs): selran = FIDs
+                else: selran = random.sample(FIDs, selVal)
+                selran.extend(mlayer.selectedFeaturesIds())
+                mlayer.setSelectedFeatures(selran)
+        else:
+            mlayer.setSelectedFeatures(range(0, mlayer.featureCount()))
 
-	def getVectorLayerByName(self, myName):
-		mc = self.iface.mapCanvas()
-		nLayers = mc.layerCount()
-		for l in range(nLayers):
-			layer = mc.layer(l)
-			if layer.name() == unicode(myName,'latin1'):
-				vlayer = QgsVectorLayer(unicode(layer.source()),  unicode(myName),  unicode(layer.dataProvider().name()))
-				if vlayer.isValid():
-					return vlayer
-				else:
-					QMessageBox.information(self, self.tr("Random selection within subsets"), self.tr("Vector layer is not valid"))
-
-	def getMapLayerByName(self, myName):
-		mc = self.iface.mapCanvas()
-		nLayers = mc.layerCount()
-		for l in range(nLayers):
-			layer = mc.layer(l)
-			if layer.name() == unicode(myName,'latin1'):
-				return layer
-
-	def getFieldList(self, vlayer):
-		fProvider = vlayer.dataProvider()
-		feat = QgsFeature()
-		allAttrs = fProvider.attributeIndexes()
-		fProvider.select(allAttrs)
-		myFields = fProvider.fields()
-		return myFields
-
-	def getUniqueValues(self, provider, index):
-		allAttrs = provider.attributeIndexes()
-		provider.select(allAttrs)
-		feat = QgsFeature()
-		values = []
-		check = []
-		provider.rewind()
-		while provider.nextFeature(feat):
-			if not feat.attributeMap()[index].toString() in check:
-				values.append( feat.attributeMap()[index] )
-				check.append( feat.attributeMap()[index].toString() )
-		return values
+    def getMapLayerByName(self, myName):
+        mc = self.iface.mapCanvas()
+        nLayers = mc.layerCount()
+        for l in range(nLayers):
+            layer = mc.layer(l)
+            if layer.name() == unicode(myName,'latin1'):
+                return layer

Modified: trunk/qgis/python/plugins/fTools/tools/doSumLines.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doSumLines.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doSumLines.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -1,4 +1,5 @@
-#-----------------------------------------------------------
+# -*- coding: utf-8 -*-
+#-----------------------------------------------------------
 # 
 # Sum Lines In Polygons
 #
@@ -38,130 +39,112 @@
 
 class Dialog(QDialog, Ui_Dialog):
 
-	def __init__(self, iface):
-		QDialog.__init__(self)
-		self.iface = iface
-		# Set up the user interface from Designer.
-		self.setupUi(self)
-		QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
-		self.setWindowTitle(self.tr("Sum line lengths"))
-		# populate layer list
-		self.progressBar.setValue(0)
-		mapCanvas = self.iface.mapCanvas()
-		for i in range(mapCanvas.layerCount()):
-			layer = mapCanvas.layer(i)
-			if layer.type() == layer.VectorLayer:
-				if layer.geometryType() == QGis.Polygon:
-					self.inPolygon.addItem(layer.name())
-				elif layer.geometryType() == QGis.Line:
-					self.inPoint.addItem(layer.name())
-		
-	def accept(self):
-		if self.inPolygon.currentText() == "":
-			QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input polygon vector layer"))
-		elif self.outShape.text() == "":
-			QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify output shapefile"))
-		elif self.inPoint.currentText() == "":
-			QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input line vector layer"))
-		elif self.lnField.text() == "":
-			QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify output length field"))
-		else:
-			inPoly = self.inPolygon.currentText()
-			inLns = self.inPoint.currentText()
-			inField = self.lnField.text()
-			outPath = self.outShape.text()
-			if outPath.contains("\\"):
-				outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
-			else:
-				outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
-			if outName.endsWith(".shp"):
-				outName = outName.left(outName.length() - 4)
-			self.compute(inPoly, inLns, inField, outPath, self.progressBar)
-			self.outShape.clear()
-			addToTOC = QMessageBox.question(self, self.tr("Sum line lengths"), self.tr("Created output shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg(unicode(outPath)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
-			if addToTOC == QMessageBox.Yes:
-				self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
-				QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
-		self.progressBar.setValue(0)
+    def __init__(self, iface):
+        QDialog.__init__(self)
+        self.iface = iface
+        # Set up the user interface from Designer.
+        self.setupUi(self)
+        QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
+        self.setWindowTitle(self.tr("Sum line lengths"))
+        # populate layer list
+        self.progressBar.setValue(0)
+        mapCanvas = self.iface.mapCanvas()
+        layers = ftools_utils.getLayerNames([QGis.Line])
+        self.inPoint.addItems(layers)
+        layers = ftools_utils.getLayerNames([QGis.Polygon])
+        self.inPolygon.addItems(layers)
+    
+    def accept(self):
+        if self.inPolygon.currentText() == "":
+            QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input polygon vector layer"))
+        elif self.outShape.text() == "":
+            QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify output shapefile"))
+        elif self.inPoint.currentText() == "":
+            QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify input line vector layer"))
+        elif self.lnField.text() == "":
+            QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Please specify output length field"))
+        else:
+            inPoly = self.inPolygon.currentText()
+            inLns = self.inPoint.currentText()
+            inField = self.lnField.text()
+            outPath = self.outShape.text()
+            if outPath.contains("\\"):
+                outName = outPath.right((outPath.length() - outPath.lastIndexOf("\\")) - 1)
+            else:
+                outName = outPath.right((outPath.length() - outPath.lastIndexOf("/")) - 1)
+            if outName.endsWith(".shp"):
+                outName = outName.left(outName.length() - 4)
+            self.compute(inPoly, inLns, inField, outPath, self.progressBar)
+            self.outShape.clear()
+            addToTOC = QMessageBox.question(self, self.tr("Sum line lengths"), self.tr("Created output shapefile:\n%1\n\nWould you like to add the new layer to the TOC?").arg(unicode(outPath)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
+            if addToTOC == QMessageBox.Yes:
+                self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
+                QgsMapLayerRegistry.instance().addMapLayer(self.vlayer)
+        self.progressBar.setValue(0)
 
-	def outFile(self):
-		self.outShape.clear()
-		( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
-		if self.shapefileName is None or self.encoding is None:
-			return
-		self.outShape.setText( QString( self.shapefileName ) )
+    def outFile(self):
+        self.outShape.clear()
+        ( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
+        if self.shapefileName is None or self.encoding is None:
+            return
+        self.outShape.setText( QString( self.shapefileName ) )
 
-	def compute(self, inPoly, inLns, inField, outPath, progressBar):
-		polyLayer = self.getVectorLayerByName(inPoly)
-		lineLayer = self.getVectorLayerByName(inLns)
-		polyProvider = polyLayer.dataProvider()
-		lineProvider = lineLayer.dataProvider()
-		if polyProvider.crs() <> lineProvider.crs():
-			QMessageBox.warning(self, self.tr("CRS warning!"), self.tr("Warning: Input layers have non-matching CRS.\nThis may cause unexpected results."))
-		allAttrs = polyProvider.attributeIndexes()
-		polyProvider.select(allAttrs)
-		allAttrs = lineProvider.attributeIndexes()
-		lineProvider.select(allAttrs)
-		fieldList = self.getFieldList(polyLayer)
-		index = polyProvider.fieldNameIndex(unicode(inField))
-		if index == -1:
-			index = polyProvider.fieldCount()
-			field = QgsField(unicode(inField), QVariant.Int, "real", 24, 15, self.tr("length field"))
-			fieldList[index] = field
-		sRs = polyProvider.crs()
-		inFeat = QgsFeature()
-		outFeat = QgsFeature()
-		inGeom = QgsGeometry()
-		outGeom = QgsGeometry()
-		distArea = QgsDistanceArea()
-		lineProvider.rewind()
-		start = 15.00
-		add = 85.00 / polyProvider.featureCount()
-		check = QFile(self.shapefileName)
-		if check.exists():
-			if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
-				return
-		writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, polyProvider.geometryType(), sRs)
-		#writer = QgsVectorFileWriter(outPath, "UTF-8", fieldList, polyProvider.geometryType(), sRs)
-		while polyProvider.nextFeature(inFeat):
-			inGeom = inFeat.geometry()
-			atMap = inFeat.attributeMap()
-			lineList = []
-			length = 0
-			#(check, lineList) = lineLayer.featuresInRectangle(inGeom.boundingBox(), True, False)
-			lineLayer.select(inGeom.boundingBox(), False)
-			lineList = lineLayer.selectedFeatures()
-			if len(lineList) > 0: check = 0
-			else: check = 1
-			if check == 0:
-				for i in lineList:
-					if inGeom.intersects(i.geometry()):
-						outGeom = inGeom.intersection(i.geometry())
-						length = length + distArea.measure(outGeom)
-			outFeat.setGeometry(inGeom)
-			outFeat.setAttributeMap(atMap)
-			outFeat.addAttribute(index, QVariant(length))
-			writer.addFeature(outFeat)
-			start = start + 1
-			progressBar.setValue(start)
-		del writer
-				
-	def getVectorLayerByName(self, myName):
-		mc = self.iface.mapCanvas()
-		nLayers = mc.layerCount()
-		for l in range(nLayers):
-			layer = mc.layer(l)
-			if layer.name() == unicode(myName):
-				vlayer = QgsVectorLayer(unicode(layer.source()),  unicode(myName),  unicode(layer.dataProvider().name()))
-				if vlayer.isValid():
-					return vlayer
-				else:
-					QMessageBox.information(self, self.tr("Sum Line Lengths In Polyons"), self.tr("Vector layer is not valid"))
-
-	def getFieldList(self, vlayer):
-		fProvider = vlayer.dataProvider()
-		feat = QgsFeature()
-		allAttrs = fProvider.attributeIndexes()
-		fProvider.select(allAttrs)
-		myFields = fProvider.fields()
-		return myFields
+    def compute(self, inPoly, inLns, inField, outPath, progressBar):
+        polyLayer = ftools_utils.getVectorLayerByName(inPoly)
+        lineLayer = ftools_utils.getVectorLayerByName(inLns)
+        polyProvider = polyLayer.dataProvider()
+        lineProvider = lineLayer.dataProvider()
+        if polyProvider.crs() <> lineProvider.crs():
+            QMessageBox.warning(self, self.tr("CRS warning!"), self.tr("Warning: Input layers have non-matching CRS.\nThis may cause unexpected results."))
+        allAttrs = polyProvider.attributeIndexes()
+        polyProvider.select(allAttrs)
+        allAttrs = lineProvider.attributeIndexes()
+        lineProvider.select(allAttrs)
+        fieldList = ftools_utils.getFieldList(polyLayer)
+        index = polyProvider.fieldNameIndex(unicode(inField))
+        if index == -1:
+            index = polyProvider.fieldCount()
+            field = QgsField(unicode(inField), QVariant.Double, "real", 24, 15, self.tr("length field"))
+            fieldList[index] = field
+        sRs = polyProvider.crs()
+        inFeat = QgsFeature()
+        inFeatB = QgsFeature()
+        outFeat = QgsFeature()
+        inGeom = QgsGeometry()
+        outGeom = QgsGeometry()
+        distArea = QgsDistanceArea()
+        lineProvider.rewind()
+        start = 15.00
+        add = 85.00 / polyProvider.featureCount()
+        check = QFile(self.shapefileName)
+        if check.exists():
+            if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
+                return
+        writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, polyProvider.geometryType(), sRs)
+        #writer = QgsVectorFileWriter(outPath, "UTF-8", fieldList, polyProvider.geometryType(), sRs)
+        spatialIndex = ftools_utils.createIndex( lineProvider )
+        while polyProvider.nextFeature(inFeat):
+            inGeom = QgsGeometry(inFeat.geometry())
+            atMap = inFeat.attributeMap()
+            lineList = []
+            length = 0
+            #(check, lineList) = lineLayer.featuresInRectangle(inGeom.boundingBox(), True, False)
+            #lineLayer.select(inGeom.boundingBox(), False)
+            #lineList = lineLayer.selectedFeatures()
+            lineList = spatialIndex.intersects(inGeom.boundingBox())
+            if len(lineList) > 0: check = 0
+            else: check = 1
+            if check == 0:
+                for i in lineList:
+                    lineProvider.featureAtId( int( i ), inFeatB , True, allAttrs )
+                    tmpGeom = QgsGeometry( inFeatB.geometry() )
+                    if inGeom.intersects(tmpGeom):
+                        outGeom = inGeom.intersection(tmpGeom)
+                        length = length + distArea.measure(outGeom)
+            outFeat.setGeometry(inGeom)
+            outFeat.setAttributeMap(atMap)
+            outFeat.addAttribute(index, QVariant(length))
+            writer.addFeature(outFeat)
+            start = start + 1
+            progressBar.setValue(start)
+        del writer

Modified: trunk/qgis/python/plugins/fTools/tools/doVectorGrid.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doVectorGrid.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doVectorGrid.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -179,22 +179,3 @@
         if self.shapefileName is None or self.encoding is None:
             return
         self.outShape.setText( QString( self.shapefileName ) )
-
-    def getVectorLayerByName(self, myName):
-        mc = self.iface.mapCanvas()
-        nLayers = mc.layerCount()
-        for l in range(nLayers):
-            layer = mc.layer(l)
-            if unicode(layer.name()) == unicode(myName):
-                vlayer = QgsVectorLayer(unicode(layer.source()),  unicode(myName),  unicode(layer.dataProvider().name()))
-                if vlayer.isValid():
-                    return vlayer
-
-    def getMapLayerByName(self, myName):
-        mc = self.iface.mapCanvas()
-        nLayers = mc.layerCount()
-        for l in range(nLayers):
-            layer = mc.layer(l)
-            if unicode(layer.name()) == unicode(myName):
-                if layer.isValid():
-                    return layer

Modified: trunk/qgis/python/plugins/fTools/tools/doVectorSplit.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doVectorSplit.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/doVectorSplit.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 #-----------------------------------------------------------
 # 
 # Vector Split
@@ -32,177 +33,142 @@
 from PyQt4.QtGui import *
 from qgis.core import *
 #import os, sys, string, math
+import ftools_utils
 from ui_frmVectorSplit import Ui_Dialog
 
 class Dialog(QDialog, Ui_Dialog):
-	def __init__(self, iface):
-		QDialog.__init__(self)
-		self.iface = iface
-		# Set up the user interface from Designer.
-		self.setupUi(self)
-		QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
-		QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
-		self.setWindowTitle(self.tr("Split vector layer"))
-		# populate layer list
-		self.progressBar.setValue(0)
-		mapCanvas = self.iface.mapCanvas()
-		for i in range(mapCanvas.layerCount()):
-			layer = mapCanvas.layer(i)
-			if layer.type() == layer.VectorLayer:
-				self.inShape.addItem(layer.name())
+    def __init__(self, iface):
+        QDialog.__init__(self)
+        self.iface = iface
+        # Set up the user interface from Designer.
+        self.setupUi(self)
+        QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
+        QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
+        self.setWindowTitle(self.tr("Split vector layer"))
+        # populate layer list
+        self.progressBar.setValue(0)
+        mapCanvas = self.iface.mapCanvas()
+        layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
+        self.inShape.addItems(layers)
 
-	def update(self, inputLayer):
-		self.inField.clear()
-		changedLayer = self.getVectorLayerByName(inputLayer)
-		changedField = self.getFieldList(changedLayer)
-		for i in changedField:
-			self.inField.addItem(unicode(changedField[i].name()))
+    def update(self, inputLayer):
+        self.inField.clear()
+        changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
+        changedField = ftools_utils.getFieldList(changedLayer)
+        for i in changedField:
+            self.inField.addItem(unicode(changedField[i].name()))
 
-	def accept(self):
-		if self.inShape.currentText() == "":
-			QMessageBox.information(self, self.tr("Vector Split"), self.tr("No input shapefile specified"))
-		elif self.outShape.text() == "":
-			QMessageBox.information(self, self.tr("Vector Split"), self.tr("Please specify output shapefile"))
-		else:
-			inField = self.inField.currentText()
-			inLayer = self.getVectorLayerByName(unicode(self.inShape.currentText()))
-			self.progressBar.setValue(5)
-			outPath = QString(self.folderName)
-			self.progressBar.setValue(10)
-			if outPath.contains("\\"):
-				outPath.replace("\\", "/")
-			self.progressBar.setValue(15)
-			if not outPath.endsWith("/"): outPath = outPath + "/"
-			self.split(inLayer, unicode(outPath), unicode(inField), self.progressBar)
-			self.progressBar.setValue(100)
-			self.outShape.clear()
-			QMessageBox.information(self, self.tr("Vector Split"), self.tr("Created output shapefiles in folder:\n%1").arg( outPath))
-			self.progressBar.setValue(0)
+    def accept(self):
+        if self.inShape.currentText() == "":
+            QMessageBox.information(self, self.tr("Vector Split"), self.tr("No input shapefile specified"))
+        elif self.outShape.text() == "":
+            QMessageBox.information(self, self.tr("Vector Split"), self.tr("Please specify output shapefile"))
+        else:
+            inField = self.inField.currentText()
+            inLayer = ftools_utils.getVectorLayerByName(unicode(self.inShape.currentText()))
+            self.progressBar.setValue(5)
+            outPath = QString(self.folderName)
+            self.progressBar.setValue(10)
+            if outPath.contains("\\"):
+                outPath.replace("\\", "/")
+            self.progressBar.setValue(15)
+            if not outPath.endsWith("/"): outPath = outPath + "/"
+            self.split(inLayer, unicode(outPath), unicode(inField), self.progressBar)
+            self.progressBar.setValue(100)
+            self.outShape.clear()
+            QMessageBox.information(self, self.tr("Vector Split"), self.tr("Created output shapefiles in folder:\n%1").arg( outPath))
+            self.progressBar.setValue(0)
 
-	def outFile(self):
-		fileDialog = QFileDialog()
-		settings = QSettings()
-		dirName = settings.value("/UI/lastShapefileDir").toString()
-		fileDialog.setDirectory(dirName)
-		encodingBox = QComboBox()
-		l = QLabel("Encoding:",fileDialog)
-		fileDialog.layout().addWidget(l)
-		fileDialog.layout().addWidget(encodingBox)
-		encodingBox.addItem("BIG5") 
-		encodingBox.addItem("BIG5-HKSCS")
-		encodingBox.addItem("EUCJP")
-		encodingBox.addItem("EUCKR")
-		encodingBox.addItem("GB2312")
-		encodingBox.addItem("GBK") 
-		encodingBox.addItem("GB18030")
-		encodingBox.addItem("JIS7") 
-		encodingBox.addItem("SHIFT-JIS")
-		encodingBox.addItem("TSCII")
-		encodingBox.addItem("UTF-8")
-		encodingBox.addItem("UTF-16")
-		encodingBox.addItem("KOI8-R")
-		encodingBox.addItem("KOI8-U") 
-		encodingBox.addItem("ISO8859-1")
-		encodingBox.addItem("ISO8859-2")
-		encodingBox.addItem("ISO8859-3")
-		encodingBox.addItem("ISO8859-4")
-		encodingBox.addItem("ISO8859-5")
-		encodingBox.addItem("ISO8859-6")
-		encodingBox.addItem("ISO8859-7")
-		encodingBox.addItem("ISO8859-8") 
-		encodingBox.addItem("ISO8859-8-I")
-		encodingBox.addItem("ISO8859-9")
-		encodingBox.addItem("ISO8859-10")
-		encodingBox.addItem("ISO8859-13")
-		encodingBox.addItem("ISO8859-14")
-		encodingBox.addItem("ISO8859-15")
-		encodingBox.addItem("IBM 850")
-		encodingBox.addItem("IBM 866")
-		encodingBox.addItem("CP874") 
-		encodingBox.addItem("CP1250")
-		encodingBox.addItem("CP1251")
-		encodingBox.addItem("CP1252")
-		encodingBox.addItem("CP1253")
-		encodingBox.addItem("CP1254")
-		encodingBox.addItem("CP1255")
-		encodingBox.addItem("CP1256")
-		encodingBox.addItem("CP1257") 
-		encodingBox.addItem("CP1258") 
-		encodingBox.addItem("Apple Roman")
-		encodingBox.addItem("TIS-620")
-		encodingBox.setItemText(encodingBox.currentIndex(), QString(QTextCodec.codecForLocale().name()))
-		fileDialog.setAcceptMode(QFileDialog.AcceptSave)
-		fileDialog.setFileMode(QFileDialog.DirectoryOnly)
-		fileDialog.setConfirmOverwrite(False)
-		if not fileDialog.exec_() == 1:
-			return
-		folders = fileDialog.selectedFiles()
-		self.folderName = unicode(folders.first())
-		self.encoding = unicode(encodingBox.currentText())
-		self.outShape.clear()
-		self.outShape.insert(self.folderName)
+    def outFile(self):
+        fileDialog = QFileDialog()
+        settings = QSettings()
+        dirName = settings.value("/UI/lastShapefileDir").toString()
+        fileDialog.setDirectory(dirName)
+        encodingBox = QComboBox()
+        l = QLabel("Encoding:",fileDialog)
+        fileDialog.layout().addWidget(l)
+        fileDialog.layout().addWidget(encodingBox)
+        encodingBox.addItem("BIG5")
+        encodingBox.addItem("BIG5-HKSCS")
+        encodingBox.addItem("EUCJP")
+        encodingBox.addItem("EUCKR")
+        encodingBox.addItem("GB2312")
+        encodingBox.addItem("GBK")
+        encodingBox.addItem("GB18030")
+        encodingBox.addItem("JIS7")
+        encodingBox.addItem("SHIFT-JIS")
+        encodingBox.addItem("TSCII")
+        encodingBox.addItem("UTF-8")
+        encodingBox.addItem("UTF-16")
+        encodingBox.addItem("KOI8-R")
+        encodingBox.addItem("KOI8-U")
+        encodingBox.addItem("ISO8859-1")
+        encodingBox.addItem("ISO8859-2")
+        encodingBox.addItem("ISO8859-3")
+        encodingBox.addItem("ISO8859-4")
+        encodingBox.addItem("ISO8859-5")
+        encodingBox.addItem("ISO8859-6")
+        encodingBox.addItem("ISO8859-7")
+        encodingBox.addItem("ISO8859-8")
+        encodingBox.addItem("ISO8859-8-I")
+        encodingBox.addItem("ISO8859-9")
+        encodingBox.addItem("ISO8859-10")
+        encodingBox.addItem("ISO8859-13")
+        encodingBox.addItem("ISO8859-14")
+        encodingBox.addItem("ISO8859-15")
+        encodingBox.addItem("IBM 850")
+        encodingBox.addItem("IBM 866")
+        encodingBox.addItem("CP874")
+        encodingBox.addItem("CP1250")
+        encodingBox.addItem("CP1251")
+        encodingBox.addItem("CP1252")
+        encodingBox.addItem("CP1253")
+        encodingBox.addItem("CP1254")
+        encodingBox.addItem("CP1255")
+        encodingBox.addItem("CP1256")
+        encodingBox.addItem("CP1257")
+        encodingBox.addItem("CP1258")
+        encodingBox.addItem("Apple Roman")
+        encodingBox.addItem("TIS-620")
+        encodingBox.setItemText(encodingBox.currentIndex(), QString(QTextCodec.codecForLocale().name()))
+        fileDialog.setAcceptMode(QFileDialog.AcceptSave)
+        fileDialog.setFileMode(QFileDialog.DirectoryOnly)
+        fileDialog.setConfirmOverwrite(False)
+        if not fileDialog.exec_() == 1:
+            return
+        folders = fileDialog.selectedFiles()
+        self.folderName = unicode(folders.first())
+        self.encoding = unicode(encodingBox.currentText())
+        self.outShape.clear()
+        self.outShape.insert(self.folderName)
 
-	def split(self, vlayer, outPath, inField, progressBar):
-		provider = vlayer.dataProvider()
-		#unique = []
-		index = provider.fieldNameIndex(inField)
-		#provider.uniqueValues(index, unique)
-		unique = self.getUniqueValues(vlayer.dataProvider(), int(index))
-		baseName = outPath + vlayer.name() + "_" + inField + "_"
-		allAttrs = provider.attributeIndexes()
-		provider.select(allAttrs)
-		fieldList = self.getFieldList(vlayer)
-		sRs = provider.crs()
-		inFeat = QgsFeature()
-		progressBar.setValue(20)
-		start = 20.00
-		add = 80.00 / len(unique)
-		for i in unique:
-			check = QFile(baseName + "_" + unicode(i) + ".shp")
-			if check.exists():
-				if not QgsVectorFileWriter.deleteShapeFile(baseName + "_" + unicode(i.toString().trimmed()) + ".shp"):
-					return
-			writer = QgsVectorFileWriter(baseName + "_" + unicode(i.toString().trimmed()) + ".shp", self.encoding, fieldList, vlayer.dataProvider().geometryType(), sRs)
-			provider.rewind()
-			while provider.nextFeature(inFeat):
-				atMap = inFeat.attributeMap()
-				#changed from QVariant(i) to below:
-				if atMap[index] == i:
-					writer.addFeature(inFeat)
-			del writer
-			start = start + add
-			progressBar.setValue(start)
-
-	def getVectorLayerByName(self, myName):
-		mc = self.iface.mapCanvas()
-		nLayers = mc.layerCount()
-		for l in range(nLayers):
-			layer = mc.layer(l)
-			if unicode(layer.name()) == unicode(myName):
-				vlayer = QgsVectorLayer(unicode(layer.source()),  unicode(myName),  unicode(layer.dataProvider().name()))
-				if vlayer.isValid():
-					return vlayer
-
-	def getFieldList(self, vlayer):
-		fProvider = vlayer.dataProvider()
-		feat = QgsFeature()
-		allAttrs = fProvider.attributeIndexes()
-		# fetch all attributes for each feature
-		fProvider.select(allAttrs)
-		# retrieve all fields
-		myFields = fProvider.fields()
-		return myFields
-
-	def getUniqueValues(self, provider, index):
-		allAttrs = provider.attributeIndexes()    
-		provider.select(allAttrs)
-		feat = QgsFeature()
-		values = []
-		check = []
-		provider.rewind()
-		while provider.nextFeature(feat):
-			if not feat.attributeMap()[index].toString() in check:
-				values.append( feat.attributeMap()[index] )
-				check.append( feat.attributeMap()[index].toString() )
-		return values
-
+    def split(self, vlayer, outPath, inField, progressBar):
+        provider = vlayer.dataProvider()
+        #unique = []
+        index = provider.fieldNameIndex(inField)
+        #provider.uniqueValues(index, unique)
+        unique = ftools_utils.getUniqueValues(vlayer.dataProvider(), int(index))
+        baseName = outPath + vlayer.name() + "_" + inField + "_"
+        allAttrs = provider.attributeIndexes()
+        provider.select(allAttrs)
+        fieldList = ftools_utils.getFieldList(vlayer)
+        sRs = provider.crs()
+        inFeat = QgsFeature()
+        progressBar.setValue(20)
+        start = 20.00
+        add = 80.00 / len(unique)
+        for i in unique:
+            check = QFile(baseName + "_" + unicode(i) + ".shp")
+            if check.exists():
+                if not QgsVectorFileWriter.deleteShapeFile(baseName + "_" + unicode(i.toString().trimmed()) + ".shp"):
+                    return
+            writer = QgsVectorFileWriter(baseName + "_" + unicode(i.toString().trimmed()) + ".shp", self.encoding, fieldList, vlayer.dataProvider().geometryType(), sRs)
+            provider.rewind()
+            while provider.nextFeature(inFeat):
+                atMap = inFeat.attributeMap()
+                #changed from QVariant(i) to below:
+                if atMap[index] == i:
+                    writer.addFeature(inFeat)
+            del writer
+            start = start + add
+            progressBar.setValue(start)

Modified: trunk/qgis/python/plugins/fTools/tools/frmRandom.ui
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/frmRandom.ui	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/frmRandom.ui	2010-03-10 01:11:11 UTC (rev 13037)
@@ -1,10 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>Dialog</class>
- <widget class="QDialog" name="Dialog" >
-  <property name="windowModality" >
-   <enum>Qt::WindowModal</enum>
-  </property>
-  <property name="geometry" >
+ <widget class="QDialog" name="Dialog">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
@@ -12,48 +10,48 @@
     <height>287</height>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string>Random Selection Tool</string>
   </property>
-  <property name="sizeGripEnabled" >
+  <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QGridLayout" name="gridLayout" >
-   <item row="0" column="0" colspan="2" >
-    <widget class="QLabel" name="label_3" >
-     <property name="text" >
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0" colspan="2">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
       <string>Input Vector Layer</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="0" colspan="2" >
-    <widget class="QComboBox" name="inShape" />
+   <item row="1" column="0" colspan="2">
+    <widget class="QComboBox" name="inShape"/>
    </item>
-   <item row="2" column="0" colspan="2" >
-    <widget class="QLabel" name="label_2" >
-     <property name="text" >
+   <item row="2" column="0" colspan="2">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
       <string>Randomly Select</string>
      </property>
     </widget>
    </item>
-   <item row="3" column="0" colspan="2" >
-    <layout class="QHBoxLayout" >
+   <item row="3" column="0" colspan="2">
+    <layout class="QHBoxLayout">
      <item>
-      <widget class="QRadioButton" name="rdoNumber" >
-       <property name="text" >
+      <widget class="QRadioButton" name="rdoNumber">
+       <property name="text">
         <string>Number of Features</string>
        </property>
-       <property name="checked" >
+       <property name="checked">
         <bool>true</bool>
        </property>
       </widget>
      </item>
      <item>
       <spacer>
-       <property name="orientation" >
+       <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
-       <property name="sizeHint" stdset="0" >
+       <property name="sizeHint" stdset="0">
         <size>
          <width>40</width>
          <height>20</height>
@@ -62,29 +60,29 @@
       </spacer>
      </item>
      <item>
-      <widget class="QSpinBox" name="spnNumber" >
-       <property name="minimum" >
+      <widget class="QSpinBox" name="spnNumber">
+       <property name="minimum">
         <number>1</number>
        </property>
       </widget>
      </item>
     </layout>
    </item>
-   <item row="4" column="0" colspan="2" >
-    <layout class="QHBoxLayout" >
+   <item row="4" column="0" colspan="2">
+    <layout class="QHBoxLayout">
      <item>
-      <widget class="QRadioButton" name="rdoPercent" >
-       <property name="text" >
+      <widget class="QRadioButton" name="rdoPercent">
+       <property name="text">
         <string>Percentage of Features</string>
        </property>
       </widget>
      </item>
      <item>
       <spacer>
-       <property name="orientation" >
+       <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
-       <property name="sizeHint" stdset="0" >
+       <property name="sizeHint" stdset="0">
         <size>
          <width>40</width>
          <height>20</height>
@@ -93,32 +91,32 @@
       </spacer>
      </item>
      <item>
-      <widget class="QSpinBox" name="spnPercent" >
-       <property name="suffix" >
+      <widget class="QSpinBox" name="spnPercent">
+       <property name="suffix">
         <string>%</string>
        </property>
-       <property name="prefix" >
+       <property name="prefix">
         <string/>
        </property>
-       <property name="minimum" >
+       <property name="minimum">
         <number>1</number>
        </property>
-       <property name="maximum" >
+       <property name="maximum">
         <number>100</number>
        </property>
-       <property name="value" >
+       <property name="value">
         <number>50</number>
        </property>
       </widget>
      </item>
     </layout>
    </item>
-   <item row="5" column="0" colspan="2" >
+   <item row="5" column="0" colspan="2">
     <spacer>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" stdset="0" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>40</height>
@@ -126,25 +124,25 @@
      </property>
     </spacer>
    </item>
-   <item row="6" column="0" >
-    <widget class="QProgressBar" name="progressBar" >
-     <property name="value" >
+   <item row="6" column="0">
+    <widget class="QProgressBar" name="progressBar">
+     <property name="value">
       <number>0</number>
      </property>
-     <property name="alignment" >
+     <property name="alignment">
       <set>Qt::AlignCenter</set>
      </property>
-     <property name="textVisible" >
+     <property name="textVisible">
       <bool>true</bool>
      </property>
     </widget>
    </item>
-   <item row="6" column="1" >
-    <widget class="QDialogButtonBox" name="buttonBox_2" >
-     <property name="orientation" >
+   <item row="6" column="1">
+    <widget class="QDialogButtonBox" name="buttonBox_2">
+     <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="standardButtons" >
+     <property name="standardButtons">
       <set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
      </property>
     </widget>
@@ -159,11 +157,11 @@
    <receiver>Dialog</receiver>
    <slot>accept()</slot>
    <hints>
-    <hint type="sourcelabel" >
+    <hint type="sourcelabel">
      <x>133</x>
      <y>273</y>
     </hint>
-    <hint type="destinationlabel" >
+    <hint type="destinationlabel">
      <x>215</x>
      <y>290</y>
     </hint>
@@ -175,11 +173,11 @@
    <receiver>Dialog</receiver>
    <slot>close()</slot>
    <hints>
-    <hint type="sourcelabel" >
+    <hint type="sourcelabel">
      <x>59</x>
      <y>273</y>
     </hint>
-    <hint type="destinationlabel" >
+    <hint type="destinationlabel">
      <x>132</x>
      <y>239</y>
     </hint>

Modified: trunk/qgis/python/plugins/fTools/tools/frmSubsetSelect.ui
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/frmSubsetSelect.ui	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/frmSubsetSelect.ui	2010-03-10 01:11:11 UTC (rev 13037)
@@ -1,10 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>Dialog</class>
- <widget class="QDialog" name="Dialog" >
-  <property name="windowModality" >
-   <enum>Qt::WindowModal</enum>
-  </property>
-  <property name="geometry" >
+ <widget class="QDialog" name="Dialog">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
@@ -12,70 +10,70 @@
     <height>285</height>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string>Random Selection From Within Subsets</string>
   </property>
-  <property name="sizeGripEnabled" >
+  <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QGridLayout" name="gridLayout" >
-   <item row="0" column="0" colspan="2" >
-    <layout class="QVBoxLayout" >
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0" colspan="2">
+    <layout class="QVBoxLayout">
      <item>
-      <widget class="QLabel" name="label_3" >
-       <property name="text" >
+      <widget class="QLabel" name="label_3">
+       <property name="text">
         <string>Input Vector Layer</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QComboBox" name="inShape" />
+      <widget class="QComboBox" name="inShape"/>
      </item>
     </layout>
    </item>
-   <item row="1" column="0" colspan="2" >
-    <layout class="QVBoxLayout" >
+   <item row="1" column="0" colspan="2">
+    <layout class="QVBoxLayout">
      <item>
-      <widget class="QLabel" name="label_4" >
-       <property name="text" >
+      <widget class="QLabel" name="label_4">
+       <property name="text">
         <string>Input subset field (unique ID field)</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QComboBox" name="inField" />
+      <widget class="QComboBox" name="inField"/>
      </item>
     </layout>
    </item>
-   <item row="2" column="0" colspan="2" >
-    <layout class="QVBoxLayout" >
+   <item row="2" column="0" colspan="2">
+    <layout class="QVBoxLayout">
      <item>
-      <layout class="QVBoxLayout" >
+      <layout class="QVBoxLayout">
        <item>
-        <widget class="QLabel" name="label_2" >
-         <property name="text" >
+        <widget class="QLabel" name="label_2">
+         <property name="text">
           <string>Randomly Select</string>
          </property>
         </widget>
        </item>
        <item>
-        <layout class="QHBoxLayout" >
+        <layout class="QHBoxLayout">
          <item>
-          <widget class="QRadioButton" name="rdoNumber" >
-           <property name="text" >
+          <widget class="QRadioButton" name="rdoNumber">
+           <property name="text">
             <string>Number of Features</string>
            </property>
-           <property name="checked" >
+           <property name="checked">
             <bool>true</bool>
            </property>
           </widget>
          </item>
          <item>
           <spacer>
-           <property name="orientation" >
+           <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeHint" stdset="0" >
+           <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
@@ -84,8 +82,8 @@
           </spacer>
          </item>
          <item>
-          <widget class="QSpinBox" name="spnNumber" >
-           <property name="minimum" >
+          <widget class="QSpinBox" name="spnNumber">
+           <property name="minimum">
             <number>1</number>
            </property>
           </widget>
@@ -95,20 +93,20 @@
       </layout>
      </item>
      <item>
-      <layout class="QHBoxLayout" >
+      <layout class="QHBoxLayout">
        <item>
-        <widget class="QRadioButton" name="rdoPercent" >
-         <property name="text" >
+        <widget class="QRadioButton" name="rdoPercent">
+         <property name="text">
           <string>Percentage of Features</string>
          </property>
         </widget>
        </item>
        <item>
         <spacer>
-         <property name="orientation" >
+         <property name="orientation">
           <enum>Qt::Horizontal</enum>
          </property>
-         <property name="sizeHint" stdset="0" >
+         <property name="sizeHint" stdset="0">
           <size>
            <width>40</width>
            <height>20</height>
@@ -117,20 +115,20 @@
         </spacer>
        </item>
        <item>
-        <widget class="QSpinBox" name="spnPercent" >
-         <property name="suffix" >
+        <widget class="QSpinBox" name="spnPercent">
+         <property name="suffix">
           <string>%</string>
          </property>
-         <property name="prefix" >
+         <property name="prefix">
           <string/>
          </property>
-         <property name="minimum" >
+         <property name="minimum">
           <number>1</number>
          </property>
-         <property name="maximum" >
+         <property name="maximum">
           <number>100</number>
          </property>
-         <property name="value" >
+         <property name="value">
           <number>50</number>
          </property>
         </widget>
@@ -139,12 +137,12 @@
      </item>
     </layout>
    </item>
-   <item row="3" column="0" colspan="2" >
+   <item row="3" column="0" colspan="2">
     <spacer>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" stdset="0" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>20</height>
@@ -152,25 +150,25 @@
      </property>
     </spacer>
    </item>
-   <item row="4" column="0" >
-    <widget class="QProgressBar" name="progressBar" >
-     <property name="value" >
+   <item row="4" column="0">
+    <widget class="QProgressBar" name="progressBar">
+     <property name="value">
       <number>24</number>
      </property>
-     <property name="alignment" >
+     <property name="alignment">
       <set>Qt::AlignCenter</set>
      </property>
-     <property name="textVisible" >
+     <property name="textVisible">
       <bool>true</bool>
      </property>
     </widget>
    </item>
-   <item row="4" column="1" >
-    <widget class="QDialogButtonBox" name="buttonBox_2" >
-     <property name="orientation" >
+   <item row="4" column="1">
+    <widget class="QDialogButtonBox" name="buttonBox_2">
+     <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="standardButtons" >
+     <property name="standardButtons">
       <set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
      </property>
     </widget>
@@ -185,11 +183,11 @@
    <receiver>Dialog</receiver>
    <slot>accept()</slot>
    <hints>
-    <hint type="sourcelabel" >
+    <hint type="sourcelabel">
      <x>133</x>
      <y>273</y>
     </hint>
-    <hint type="destinationlabel" >
+    <hint type="destinationlabel">
      <x>215</x>
      <y>290</y>
     </hint>
@@ -201,11 +199,11 @@
    <receiver>Dialog</receiver>
    <slot>close()</slot>
    <hints>
-    <hint type="sourcelabel" >
+    <hint type="sourcelabel">
      <x>59</x>
      <y>273</y>
     </hint>
-    <hint type="destinationlabel" >
+    <hint type="destinationlabel">
      <x>132</x>
      <y>239</y>
     </hint>

Modified: trunk/qgis/python/plugins/fTools/tools/ftools_utils.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/ftools_utils.py	2010-03-10 00:49:23 UTC (rev 13036)
+++ trunk/qgis/python/plugins/fTools/tools/ftools_utils.py	2010-03-10 01:11:11 UTC (rev 13037)
@@ -170,6 +170,9 @@
             if layer.type() == QgsMapLayer.VectorLayer:
                 if layer.geometryType() in vTypes:
                     layerlist.append( unicode( layer.name() ) )
+            elif layer.type() == QgsMapLayer.RasterLayer:
+                if "Raster" in vTypes:
+                    layerlist.append( unicode( layer.name() ) )
     return layerlist
 
 # Return list of names of all fields from input QgsVectorLayer



More information about the QGIS-commit mailing list