4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doPointDistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def compute(self, line1, line2, field1, field2, outPath, matType, nearest, progr
provider2 = layer2.dataProvider()
sindex = QgsSpatialIndex()
inFeat = QgsFeature()
fit2 = provider2.getFeatures()
fit2 = provider2.getFeatures()
while fit2.nextFeature(inFeat):
sindex.insertFeature(inFeat)
if nearest < 1: nearest = layer2.featureCount()
Expand Down Expand Up @@ -190,7 +190,7 @@ def regularMatrix(self, writer, provider1, provider2, index1, index2, nearest, d
first = True
start = 15.00
add = 85.00 / provider1.featureCount()
fit1 = provider1.getFeatures()
fit1 = provider1.getFeatures()
while fit1.nextFeature(inFeat):
inGeom = inFeat.geometry()
inID = inFeat.attributes()[index1]
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/fTools/tools/doPointsInPolygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def outFile(self):
(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))
self.outShape.setText(self.shapefileName)

def accept(self):
if self.inPolygon.currentText() == "":
Expand Down Expand Up @@ -188,7 +188,7 @@ def run(self):
pntFeat = QgsFeature()
outFeat = QgsFeature()
inGeom = QgsGeometry()
polyFit = polyProvider.getFeatures()
polyFit = polyProvider.getFeatures()
while polyFit.nextFeature(polyFeat):
inGeom = polyFeat.geometry()
atMap = polyFeat.attributes()
Expand Down Expand Up @@ -218,7 +218,7 @@ def run(self):
interrupted = True
break

atMap.append(QVariant(count))
atMap.append(count)
outFeat.setAttributes(atMap)
writer.addFeature(outFeat)

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doRandPoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def outFile(self):
( 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 ) )
self.outShape.setText( self.shapefileName )

# combine all polygons in layer to create single polygon (slow for complex polygons)
def createSinglePolygon(self, vlayer):
Expand Down Expand Up @@ -225,7 +225,7 @@ def randomize(self, inLayer, outPath, minimum, design, value):
add = ( 100.00 - 70.00 ) / len(points)
for i in points:
outFeat.setGeometry(i)
outFeat.setAttribute(0, QVariant(idVar))
outFeat.setAttribute(0, idVar)
writer.addFeature(outFeat)
idVar = idVar + 1
count = count + add
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doRegPoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def outFile(self):
( 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 ) )
self.outShape.setText( self.shapefileName )

# Generate list of random points
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
Expand Down Expand Up @@ -149,7 +149,7 @@ def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
pGeom = QgsGeometry().fromPoint(QgsPoint(x, y))
if pGeom.intersects(bound):
outFeat.setGeometry(pGeom)
outFeat.setAttribute(0, QVariant(idVar))
outFeat.setAttribute(0, idVar)
writer.addFeature(outFeat)
idVar = idVar + 1
x = x + pointSpacing
Expand Down
14 changes: 7 additions & 7 deletions python/plugins/fTools/tools/doSimplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def selectOutputFile( self ):
( self.shapeFileName, self.encoding ) = ftools_utils.saveDialog( self )
if self.shapeFileName is None or self.encoding is None:
return
self.edOutputFile.setText( QString( self.shapeFileName ) )
self.edOutputFile.setText( self.shapeFileName )

def accept( self ):
vLayer = ftools_utils.getVectorLayerByName( self.cmbInputLayer.currentText() )
Expand Down Expand Up @@ -301,7 +301,7 @@ def runSimplify( self ):
else:
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
f = QgsFeature()
fit = vProvider.getFeatures()
fit = vProvider.getFeatures()
while fit.nextFeature( f ):
featGeometry = QgsGeometry( f.geometry() )
attrMap = f.attributes()
Expand All @@ -326,7 +326,7 @@ def runSimplify( self ):
else: # modify existing shapefile
if not self.inputLayer.isEditable():
self.inputLayer.startEditing()
self.inputLayer.beginEditCommand( QString( "Simplify line(s)" ) )
self.inputLayer.beginEditCommand( "Simplify line(s)" )
if self.useSelection:
selection = self.inputLayer.selectedFeatures()
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), len( selection ) )
Expand All @@ -351,7 +351,7 @@ def runSimplify( self ):
vProvider = self.inputLayer.dataProvider()
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
f = QgsFeature()
fit = vProvider.getFeatures()
fit = vProvider.getFeatures()
while fit.nextFeature( f ):
featureId = f.id()
featGeometry = QgsGeometry( f.geometry() )
Expand Down Expand Up @@ -428,7 +428,7 @@ def runDensify( self ):
else:
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
f = QgsFeature()
fit = vProvider.getFeatures()
fit = vProvider.getFeatures()
while fit.nextFeature( f ):
featGeometry = QgsGeometry( f.geometry() )
attrMap = f.attributes()
Expand All @@ -451,7 +451,7 @@ def runDensify( self ):
if not self.inputLayer.isEditable():
self.inputLayer.startEditing()

self.inputLayer.beginEditCommand( QString( "Densify line(s)" ) )
self.inputLayer.beginEditCommand( "Densify line(s)" )

if self.useSelection:
selection = self.inputLayer.selectedFeatures()
Expand All @@ -474,7 +474,7 @@ def runDensify( self ):
vProvider = self.inputLayer.dataProvider()
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
f = QgsFeature()
fit = vProvider.getFeatures()
fit = vProvider.getFeatures()
while fit.nextFeature( f ):
featureId = f.id()
featGeometry = QgsGeometry( f.geometry() )
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doSpatialIndex.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def processFinished( self, errors ):
self.restoreGui()

if not errors.isEmpty():
msg = QString( "Processing of the following layers/files ended with error:<br><br>" ).append( errors.join( "<br>" ) )
msg = self.tr( "Processing of the following layers/files ended with error:<br><br>" ) + "<br>".join(errors)
QErrorMessage( self ).showMessage( msg )

QMessageBox.information( self, self.tr( "Finished" ), self.tr( "Processing completed." ) )
Expand Down Expand Up @@ -162,7 +162,7 @@ def __init__( self, layers, isFiles ):
self.mutex = QMutex()
self.stopMe = 0

self.errors = QStringList()
self.errors = []

def run( self ):
self.mutex.lock()
Expand Down
14 changes: 7 additions & 7 deletions python/plugins/fTools/tools/doSpatialJoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def outFile(self):
( 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 ) )
self.outShape.setText( self.shapefileName )

def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar):
layer1 = ftools_utils.getVectorLayerByName(inName)
Expand Down Expand Up @@ -225,13 +225,13 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
atMap = atMap1
for j in numFields.keys():
for k in sumList:
if k == "SUM": atMap.append(QVariant(sum(numFields[j])))
elif k == "MEAN": atMap.append(QVariant(sum(numFields[j]) / count))
elif k == "MIN": atMap.append(QVariant(min(numFields[j])))
elif k == "MED": atMap.append(QVariant(myself(numFields[j])))
else: atMap.append(QVariant(max(numFields[j])))
if k == "SUM": atMap.append(sum(numFields[j]))
elif k == "MEAN": atMap.append(sum(numFields[j]) / count)
elif k == "MIN": atMap.append(min(numFields[j]))
elif k == "MED": atMap.append(myself(numFields[j]))
else: atMap.append(max(numFields[j]))
numFields[j] = []
atMap.append(QVariant(count))
atMap.append(count)
atMap = dict(zip(seq, atMap))
if none:
outFeat.setAttributes(atMap1)
Expand Down
4 changes: 1 addition & 3 deletions python/plugins/fTools/tools/doSubsetSelect.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ def compute(self, inVect, inField, value, perc, progressBar):
vlayer = ftools_utils.getVectorLayerByName(inVect)
vprovider = vlayer.dataProvider()
index = vprovider.fieldNameIndex(inField)
#unique = []
#vprovider.uniqueValues(index, unique)
unique = ftools_utils.getUniqueValues(vprovider, int(index))
inFeat = QgsFeature()
selran = []
Expand All @@ -101,7 +99,7 @@ def compute(self, inVect, inField, value, perc, progressBar):
FIDs= []
while fit.nextFeature(inFeat):
atMap = inFeat.attributes()
if atMap[index] == QVariant(i):
if atMap[index] == i:
FID = inFeat.id()
FIDs.append(FID)
nElement += 1
Expand Down
5 changes: 2 additions & 3 deletions python/plugins/fTools/tools/doSumLines.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def outFile(self):
( 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 ) )
self.outShape.setText( self.shapefileName )

def compute(self, inPoly, inLns, inField, outPath, progressBar):
polyLayer = ftools_utils.getVectorLayerByName(inPoly)
Expand Down Expand Up @@ -137,9 +137,8 @@ def compute(self, inPoly, inLns, inField, outPath, progressBar):
outGeom = inGeom.intersection(tmpGeom)
length = length + distArea.measure(outGeom)
outFeat.setGeometry(inGeom)
atMap.append(QVariant(length))
atMap.append(length)
outFeat.setAttributes(atMap)
#outFeat.setAttribute(index, QVariant(length))
writer.addFeature(outFeat)
start = start + 1
progressBar.setValue(start)
Expand Down
11 changes: 5 additions & 6 deletions python/plugins/fTools/tools/doValidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,15 @@ def __init__(self, iface):

def closeEvent(self, e):
settings = QSettings()
settings.setValue( "/fTools/ValidateDialog/geometry", QVariant(self.saveGeometry()) )
settings.setValue( "/fTools/ValidateDialog/geometry", self.saveGeometry())
QDialog.closeEvent(self, e)
del self.marker

def keyPressEvent( self, e ):
if ( e.modifiers() == Qt.ControlModifier or \
e.modifiers() == Qt.MetaModifier ) and \
e.key() == Qt.Key_C:
#selection = self.tblUnique.selectedItems()
items = QString()
items = ""
for row in range( self.tblUnique.rowCount() ):
items.append( self.tblUnique.item( row, 0 ).text()
+ "," + self.tblUnique.item( row, 1 ).text() + "\n" )
Expand Down Expand Up @@ -156,7 +155,7 @@ def outFile( self ):
(self.shapefileName, self.encoding) = ftools_utils.saveDialog( self )
if self.shapefileName is None or self.encoding is None:
return
self.lineEditShpError.setText( QString( self.shapefileName ) )
self.lineEditShpError.setText( self.shapefileName )

def zoomToError(self, curr, prev):
if curr is None:
Expand Down Expand Up @@ -250,7 +249,7 @@ def runFinishedFromThread( self, success ):
message = err.what()
errItem = QTableWidgetItem( message )
if err.hasWhere(): # if there is a location associated with the error
errItem.setData(Qt.UserRole, QVariant(err.where()))
errItem.setData(Qt.UserRole, err.where())
self.tblUnique.setItem( count, 1, errItem )
count += 1
self.tblUnique.setHorizontalHeaderLabels( [ self.tr("Feature"), self.tr("Error(s)") ] )
Expand Down Expand Up @@ -336,7 +335,7 @@ def check_geometry( self, vlayer ):
geometry = QgsGeometry().fromPoint( myPoint )
ft = QgsFeature()
ft.setGeometry( geometry )
ft.setAttributes( [ QVariant( fidItem ), QVariant( message ) ] )
ft.setAttributes( [ fidItem, message ] )
writer.addFeature( ft )
del writer
return "writeShape"
Expand Down
20 changes: 10 additions & 10 deletions python/plugins/fTools/tools/doVectorGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ def compute( self, bound, xOffset, yOffset, polygon ):
pt2 = QgsPoint(bound.xMaximum(), y)
line = [pt1, pt2]
outFeat.setGeometry(outGeom.fromPolyline(line))
outFeat.setAttribute(0, QVariant(idVar))
outFeat.setAttribute(1, QVariant(y))
outFeat.setAttribute(0, idVar)
outFeat.setAttribute(1, y)
writer.addFeature(outFeat)
y = y - yOffset
idVar = idVar + 1
Expand All @@ -223,8 +223,8 @@ def compute( self, bound, xOffset, yOffset, polygon ):
pt2 = QgsPoint(x, bound.yMinimum())
line = [pt1, pt2]
outFeat.setGeometry(outGeom.fromPolyline(line))
outFeat.setAttribute(0, QVariant(idVar))
outFeat.setAttribute(1, QVariant(x))
outFeat.setAttribute(0, idVar)
outFeat.setAttribute(1, x)
writer.addFeature(outFeat)
x = x + xOffset
idVar = idVar + 1
Expand All @@ -248,11 +248,11 @@ def compute( self, bound, xOffset, yOffset, polygon ):
pt5 = QgsPoint(x, y)
polygon = [[pt1, pt2, pt3, pt4, pt5]]
outFeat.setGeometry(outGeom.fromPolygon(polygon))
outFeat.setAttribute(0, QVariant(idVar))
outFeat.setAttribute(1, QVariant(x))
outFeat.setAttribute(2, QVariant(x + xOffset))
outFeat.setAttribute(3, QVariant(y - yOffset))
outFeat.setAttribute(4, QVariant(y))
outFeat.setAttribute(0, idVar)
outFeat.setAttribute(1, x)
outFeat.setAttribute(2, x + xOffset)
outFeat.setAttribute(3, y - yOffset)
outFeat.setAttribute(4, y)
writer.addFeature(outFeat)
idVar = idVar + 1
x = x + xOffset
Expand All @@ -269,7 +269,7 @@ def outFile(self):
( 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 ) )
self.outShape.setText( self.shapefileName )

def chkAlignToggled(self):
if self.chkAlign.isChecked():
Expand Down
14 changes: 7 additions & 7 deletions python/plugins/fTools/tools/doVectorSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def outFile(self):
( self.folderName, self.encoding ) = ftools_utils.dirDialog( self )
if self.folderName is None or self.encoding is None:
return
self.outShape.setText( QString( self.folderName ) )
self.outShape.setText( self.folderName )

def accept(self):
inShape = self.inShape.currentText()
Expand Down Expand Up @@ -124,7 +124,7 @@ def processFinished(self, errors):
self.restoreGui()

if not errors.isEmpty():
msg = QString( "Processing of the following layers/files ended with error:<br><br>" ).append( errors.join( "<br>" ) )
msg = self.tr( "Processing of the following layers/files ended with error:<br><br>" ) + "<br>".join(errors)
QErrorMessage( self ).showMessage( msg )

QMessageBox.information(self, self.tr("Vector Split"),
Expand All @@ -141,7 +141,7 @@ def __init__(self, layer, splitField, encoding, outDir):
self.mutex = QMutex()
self.stopMe = 0

self.errors = QStringList()
self.errors = []

def run(self):
self.mutex.lock()
Expand All @@ -150,12 +150,12 @@ def run(self):

interrupted = False

outPath = QString(self.outDir)
outPath = self.outDir

if outPath.contains("\\"):
if outPath.find("\\") != -1:
outPath.replace("\\", "/")

if not outPath.endsWith("/"):
if not outPath.endswith("/"):
outPath = outPath + "/"

provider = self.layer.dataProvider()
Expand All @@ -172,7 +172,7 @@ def run(self):


for i in unique:
check = QFile(baseName + "_" + unicode(i.toString().trimmed()) + ".shp")
check = QFile(baseName + "_" + unicode(i.strip()) + ".shp")
fName = check.fileName()
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(fName):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doVisual.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def keyPressEvent( self, e ):
'''
if ( e.modifiers() == Qt.ControlModifier or e.modifiers() == Qt.MetaModifier ) and e.key() == Qt.Key_C:
#selection = self.tblUnique.selectedItems()
items = QString()
items = ""
if self.myFunction in ( 1, 2 ):
for rec in range( self.tblUnique.rowCount() ):
items.append( self.tblUnique.item( rec, 0 ).text() + "\n" )
Expand Down Expand Up @@ -245,7 +245,7 @@ def list_unique_values( self, vlayer, myField ):
for item in unique:
nElement += 1
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
lstUnique.append(item.toString().trimmed())
lstUnique.append(item.strip())
lstCount = len( unique )
return ( lstUnique, lstCount )

Expand Down
14 changes: 7 additions & 7 deletions python/plugins/fTools/tools/ftools_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def checkCRSCompatibility( crsA, crsB ):

# Convenience function to write vector layer to shapefile
def writeVectorLayerToShape( vlayer, outputPath, encoding ):
mCodec = QTextCodec.codecForName( QString(encoding).toLocal8Bit().data() )
mCodec = QTextCodec.codecForName( encoding )
if not mCodec:
return False
#Here we should check that the output path is valid
Expand Down Expand Up @@ -289,8 +289,8 @@ def saveDialog( parent, filtering="Shapefiles (*.shp *.SHP)"):
if not fileDialog.exec_() == QDialog.Accepted:
return None, None
files = fileDialog.selectedFiles()
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( files.first() ) ).absolutePath() ) )
return ( unicode( files.first() ), unicode( fileDialog.encoding() ) )
settings.setValue("/UI/lastShapefileDir", QFileInfo( unicode( files[0] ) ).absolutePath() )
return ( unicode( files[0] ), unicode( fileDialog.encoding() ) )

# Generate a save file dialog with a dropdown box for choosing encoding style
# with mode="SingleFile" will allow to select only one file, in other cases - several files
Expand All @@ -304,9 +304,9 @@ def openDialog( parent, filtering="Shapefiles (*.shp *.SHP)", dialogMode="Single
if not fileDialog.exec_() == QDialog.Accepted:
return None, None
files = fileDialog.selectedFiles()
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( files.first() ) ).absolutePath() ) )
settings.setValue("/UI/lastShapefileDir", QFileInfo( unicode( files[0] ) ).absolutePath() )
if dialogMode == "SingleFile":
return ( unicode( files.first() ), unicode( fileDialog.encoding() ) )
return ( unicode( files[0] ), unicode( fileDialog.encoding() ) )
else:
return ( files, unicode( fileDialog.encoding() ) )

Expand All @@ -322,8 +322,8 @@ def dirDialog( parent ):
if not fileDialog.exec_() == QDialog.Accepted:
return None, None
folders = fileDialog.selectedFiles()
settings.setValue("/UI/lastShapefileDir", QVariant( QFileInfo( unicode( folders.first() ) ).absolutePath() ) )
return ( unicode( folders.first() ), unicode( fileDialog.encoding() ) )
settings.setValue("/UI/lastShapefileDir", QFileInfo( unicode( folders[0] ) ).absolutePath() )
return ( unicode( folders[0] ), unicode( fileDialog.encoding() ) )

# Return field type from it's name
def getFieldType(vlayer, fieldName):
Expand Down