Skip to content

Commit a75563f

Browse files
committedJun 3, 2013
more SIP updates for fTools
1 parent d3d5182 commit a75563f

19 files changed

+132
-136
lines changed
 

‎python/plugins/fTools/tools/doGeometry.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def outFile( self ):
8989
(self.shapefileName, self.encoding) = ftools_utils.saveDialog( self )
9090
if self.shapefileName is None or self.encoding is None:
9191
return
92-
self.outShape.setText( QString( self.shapefileName ) )
92+
self.outShape.setText( self.shapefileName )
9393

9494
def manageGui( self ):
9595
self.lblField.setVisible( False )
@@ -365,12 +365,12 @@ def single_to_multi( self ):
365365
if not index == -1:
366366
unique = ftools_utils.getUniqueValues( vprovider, int( index ) )
367367
else:
368-
unique = [ QVariant( QString() ) ]
368+
unique = [ "" ]
369369
nFeat = vprovider.featureCount() * len( unique )
370370
nElement = 0
371371
self.emit( SIGNAL( "runStatus( PyQt_PyObject )" ), 0 )
372372
self.emit( SIGNAL( "runRange( PyQt_PyObject )" ), ( 0, nFeat ) )
373-
merge_all = self.myField == QString( "--- " + self.tr( "Merge all" ) + " ---" )
373+
merge_all = self.myField == "--- " + self.tr( "Merge all" ) + " ---"
374374
if not len( unique ) == self.vlayer.featureCount() or merge_all:
375375
for i in unique:
376376
multi_feature= []
@@ -381,8 +381,8 @@ def single_to_multi( self ):
381381
if not merge_all:
382382
idVar = atMap[ index ]
383383
else:
384-
idVar = QVariant( QString() )
385-
if idVar.toString().trimmed() == i.toString().trimmed() or merge_all:
384+
idVar = ""
385+
if idVar.strip() == i.strip() or merge_all:
386386
if first:
387387
atts = atMap
388388
first = False
@@ -530,7 +530,7 @@ def export_geometry_info( self ):
530530
# 2 - ellipsoidal
531531
if self.myCalcType == 2:
532532
settings = QSettings()
533-
ellips = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString()
533+
ellips = settings.value( "/qgis/measure/ellipsoid", "WGS84" )
534534
crs = self.vlayer.crs().srsid()
535535
elif self.myCalcType == 1:
536536
mapCRS = self.parent.iface.mapCanvas().mapRenderer().destinationCrs()
@@ -568,7 +568,7 @@ def export_geometry_info( self ):
568568
atMap = inFeat.attributes()
569569
maxIndex = index1 if index1>index2 else index2
570570
if maxIndex>len(atMap):
571-
atMap += [ QVariant() ] * ( index2+1 - len(atMap) )
571+
atMap += [ "" ] * ( index2+1 - len(atMap) )
572572
atMap[ index1 ] = attr1
573573
if index1!=index2:
574574
atMap[ index2 ] = attr2
@@ -577,9 +577,9 @@ def export_geometry_info( self ):
577577
else:
578578
changeMap = {}
579579
changeMap[ inFeat.id() ] = {}
580-
changeMap[ inFeat.id() ][ index1 ] = QVariant( attr1 )
580+
changeMap[ inFeat.id() ][ index1 ] = attr1
581581
if index1!=index2:
582-
changeMap[ inFeat.id() ][ index2 ] = QVariant( attr2 )
582+
changeMap[ inFeat.id() ][ index2 ] = attr2
583583
vprovider.changeAttributeValues( changeMap )
584584

585585
if self.writeShape:
@@ -663,7 +663,7 @@ def delaunay_triangulation( self ):
663663
point = QgsPoint( geom.asPoint() )
664664
polygon.append( point )
665665
if step <= 3:
666-
attrs.append(QVariant( ids[ index ] ) )
666+
attrs.append(ids[ index ] )
667667
step += 1
668668
feat.setAttributes(attrs)
669669
geometry = QgsGeometry().fromPolygon( [ polygon ] )
@@ -853,16 +853,16 @@ def layer_extent( self ):
853853
geometry = QgsGeometry().fromPolygon( [ rect ] )
854854
feat = QgsFeature()
855855
feat.setGeometry( geometry )
856-
feat.setAttributes( [ QVariant( minx ),
857-
QVariant( miny ),
858-
QVariant( maxx ),
859-
QVariant( maxy ),
860-
QVariant( cntx ),
861-
QVariant( cnty ),
862-
QVariant( area ),
863-
QVariant( perim ),
864-
QVariant( height ),
865-
QVariant( width ) ] )
856+
feat.setAttributes( [ minx,
857+
miny,
858+
maxx,
859+
maxy,
860+
cntx,
861+
cnty,
862+
area,
863+
perim,
864+
height,
865+
width ] )
866866
writer.addFeature( feat )
867867
self.emit( SIGNAL( "runRange( PyQt_PyObject )" ), ( 0, 100 ) )
868868
self.emit( SIGNAL( "runStatus( PyQt_PyObject )" ), 0 )
@@ -916,16 +916,16 @@ def feature_extent( self, ):
916916
geometry = QgsGeometry().fromPolygon( [ rect ] )
917917

918918
outFeat.setGeometry( geometry )
919-
outFeat.setAttributes( [ QVariant( minx ),
920-
QVariant( miny ),
921-
QVariant( maxx ),
922-
QVariant( maxy ),
923-
QVariant( cntx ),
924-
QVariant( cnty ),
925-
QVariant( area ),
926-
QVariant( perim ),
927-
QVariant( height ),
928-
QVariant( width ) ] )
919+
outFeat.setAttributes( [ minx,
920+
miny,
921+
maxx,
922+
maxy,
923+
cntx,
924+
cnty,
925+
area,
926+
perim,
927+
height,
928+
width ] )
929929
writer.addFeature( outFeat )
930930
else:
931931
self.emit( SIGNAL( "runRange( PyQt_PyObject )" ), ( 0, vprovider.featureCount() ) )
@@ -953,16 +953,16 @@ def feature_extent( self, ):
953953
geometry = QgsGeometry().fromPolygon( [ rect ] )
954954

955955
outFeat.setGeometry( geometry )
956-
outFeat.setAttributes( [ QVariant( minx ),
957-
QVariant( miny ),
958-
QVariant( maxx ),
959-
QVariant( maxy ),
960-
QVariant( cntx ),
961-
QVariant( cnty ),
962-
QVariant( area ),
963-
QVariant( perim ),
964-
QVariant( height ),
965-
QVariant( width ) ] )
956+
outFeat.setAttributes( [ minx,
957+
miny,
958+
maxx,
959+
maxy,
960+
cntx,
961+
cnty,
962+
area,
963+
perim,
964+
height,
965+
width ] )
966966
writer.addFeature( outFeat )
967967

968968
del writer

‎python/plugins/fTools/tools/doGeoprocessing.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def outFile( self ):
124124
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
125125
if self.shapefileName is None or self.encoding is None:
126126
return
127-
self.outShape.setText( QString( self.shapefileName ) )
127+
self.outShape.setText( self.shapefileName )
128128

129129
def manageGui( self ):
130130
if self.myFunction == 1: # Buffer
@@ -403,7 +403,7 @@ def buffering( self, useField ):
403403
# with dissolve
404404
if self.myMerge:
405405
first = True
406-
fit = vproviderA.getFeatures()
406+
fit = vproviderA.getFeatures()
407407
while fit.nextFeature( inFeat ):
408408
atMap = inFeat.attributes()
409409
if useField:
@@ -434,7 +434,7 @@ def buffering( self, useField ):
434434
FEATURE_EXCEPT = False
435435
# without dissolve
436436
else:
437-
fit = vproviderA.getFeatures()
437+
fit = vproviderA.getFeatures()
438438
while fit.nextFeature( inFeat ):
439439
atMap = inFeat.attributes()
440440
if useField:
@@ -491,7 +491,7 @@ def convex_hull(self, useField ):
491491
for inFeat in selectionA:
492492
atMap = inFeat.attributes()
493493
idVar = atMap[ self.myParam ]
494-
if idVar.toString().trimmed() == i.toString().trimmed():
494+
if idVar.strip() == i.strip():
495495
if first:
496496
outID = idVar
497497
first = False
@@ -506,9 +506,9 @@ def convex_hull(self, useField ):
506506
outGeom = tmpGeom.convexHull()
507507
outFeat.setGeometry( outGeom )
508508
(area, perim) = self.simpleMeasure( outGeom )
509-
outFeat.setAttribute( 0, QVariant( outID ) )
510-
outFeat.setAttribute( 1, QVariant( area ) )
511-
outFeat.setAttribute( 2, QVariant( perim ) )
509+
outFeat.setAttribute( 0, outID )
510+
outFeat.setAttribute( 1, area )
511+
outFeat.setAttribute( 2, perim )
512512
writer.addFeature( outFeat )
513513
except:
514514
GEOS_EXCEPT = False
@@ -547,7 +547,7 @@ def convex_hull(self, useField ):
547547
while fitA.nextFeature( inFeat ):
548548
atMap = inFeat.attributes()
549549
idVar = atMap[ self.myParam ]
550-
if idVar.toString().trimmed() == i.toString().trimmed():
550+
if idVar.strip() == i.strip():
551551
if first:
552552
outID = idVar
553553
first = False
@@ -562,9 +562,9 @@ def convex_hull(self, useField ):
562562
outGeom = tmpGeom.convexHull()
563563
outFeat.setGeometry( outGeom )
564564
(area, perim) = self.simpleMeasure( outGeom )
565-
outFeat.setAttribute( 0, QVariant( outID ) )
566-
outFeat.setAttribute( 1, QVariant( area ) )
567-
outFeat.setAttribute( 2, QVariant( perim ) )
565+
outFeat.setAttribute( 0, outID )
566+
outFeat.setAttribute( 1, area )
567+
outFeat.setAttribute( 2, perim )
568568
writer.addFeature( outFeat )
569569
except:
570570
GEOS_EXCEPT = False
@@ -573,7 +573,7 @@ def convex_hull(self, useField ):
573573
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
574574
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
575575
hull = []
576-
fitA = vproviderA.getFeatures()
576+
fitA = vproviderA.getFeatures()
577577
while fitA.nextFeature( inFeat ):
578578
inGeom = QgsGeometry( inFeat.geometry() )
579579
points = ftools_utils.extractPoints( inGeom )
@@ -816,7 +816,7 @@ def difference( self ):
816816
# we have selection in overlay layer
817817
if self.mySelectionB:
818818
selectionB = self.vlayerB.selectedFeaturesIds()
819-
fitA = vproviderA.getFeatures()
819+
fitA = vproviderA.getFeatures()
820820
while fitA.nextFeature( inFeatA ):
821821
nElement += 1
822822
add = True
@@ -893,7 +893,7 @@ def intersect( self ):
893893
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
894894
longNames = ftools_utils.checkFieldNameLength( fields )
895895
if not longNames.isEmpty():
896-
message = QString( 'Following field names are longer than 10 characters:\n%s' ) % ( '\n'.join(longNames) )
896+
message = self.tr('Following field names are longer than 10 characters:\n%s') % ( '\n'.join(longNames) )
897897
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
898898

899899
writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields,
@@ -992,7 +992,7 @@ def intersect( self ):
992992
# we have selection in overlay layer
993993
if self.mySelectionB:
994994
selectionB = self.vlayerB.selectedFeaturesIds()
995-
fitA = vproviderA.getFeatures()
995+
fitA = vproviderA.getFeatures()
996996
while fitA.nextFeature( inFeatA ):
997997
nElement += 1
998998
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
@@ -1078,7 +1078,7 @@ def union( self ):
10781078
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
10791079
longNames = ftools_utils.checkFieldNameLength( fields )
10801080
if not longNames.isEmpty():
1081-
message = QString( 'Following field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) )
1081+
message = self.tr( 'Following field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) )
10821082
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
10831083

10841084
writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields,
@@ -1264,7 +1264,7 @@ def symetrical_difference( self ):
12641264
fields = ftools_utils.combineVectorFields( self.vlayerA, self.vlayerB )
12651265
longNames = ftools_utils.checkFieldNameLength( fields )
12661266
if not longNames.isEmpty():
1267-
message = QString( 'Following field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) )
1267+
message = self.tr( 'Following field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) )
12681268
return GEOS_EXCEPT, FEATURE_EXCEPT, crs_match, message
12691269

12701270
writer = QgsVectorFileWriter( self.myName, self.myEncoding, fields,

‎python/plugins/fTools/tools/doIntersectLines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def outFile(self):
108108
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
109109
if self.shapefileName is None or self.encoding is None:
110110
return
111-
self.outShape.setText( QString( self.shapefileName ) )
111+
self.outShape.setText( self.shapefileName )
112112

113113
def compute(self, line1, line2, field1, field2, outPath, progressBar):
114114

@@ -144,7 +144,7 @@ def compute(self, line1, line2, field1, field2, outPath, progressBar):
144144

145145
index = ftools_utils.createIndex( provider2 )
146146

147-
fit1 = vprovider.getFeatures( QgsFeatureRequest().setSubsetOfAttributes([index1]) )
147+
fit1 = vprovider.getFeatures( QgsFeatureRequest().setSubsetOfAttributes([index1]) )
148148
while fit1.nextFeature(inFeat):
149149
inGeom = inFeat.geometry()
150150
v1 = inFeat.attributes()[index1]

‎python/plugins/fTools/tools/doMeanCoords.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def outFile(self):
108108
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
109109
if self.shapefileName is None or self.encoding is None:
110110
return
111-
self.outShape.setText( QString( self.shapefileName ) )
111+
self.outShape.setText( self.shapefileName )
112112

113113
def compute(self, inName, outName, weightField="", times=1, uniqueField=""):
114114
vlayer = ftools_utils.getVectorLayerByName(inName)
@@ -125,7 +125,7 @@ def compute(self, inName, outName, weightField="", times=1, uniqueField=""):
125125
uniqueValues = ftools_utils.getUniqueValues(provider, int( uniqueIndex ) )
126126
single = False
127127
else:
128-
uniqueValues = [QVariant(1)]
128+
uniqueValues = [1]
129129
single = True
130130
if self.function == 2:
131131
fieldList = QgsFields()
@@ -157,14 +157,14 @@ def compute(self, inName, outName, weightField="", times=1, uniqueField=""):
157157
if single:
158158
check = j.strip()
159159
else:
160-
check = feat.attributes()[uniqueIndex].toString().trimmed()
161-
if check == j.toString().trimmed():
160+
check = feat.attributes()[uniqueIndex].strip()
161+
if check == j.strip():
162162
cx = 0.00
163163
cy = 0.00
164164
if weightIndex == -1:
165165
weight = 1.00
166166
else:
167-
weight = float(feat.attributes()[weightIndex]
167+
weight = float(feat.attributes()[weightIndex])
168168
geom = QgsGeometry(feat.geometry())
169169
geom = ftools_utils.extractPoints(geom)
170170
for i in geom:
@@ -198,13 +198,13 @@ def compute(self, inName, outName, weightField="", times=1, uniqueField=""):
198198
sd += (i-md)*(i-md)
199199
sd = sqrt(sd/item)
200200
outfeat.setGeometry(QgsGeometry.fromPoint(meanPoint).buffer(sd * times, 10))
201-
outfeat.setAttribute(0, QVariant(sd))
202-
outfeat.setAttribute(1, QVariant(j))
201+
outfeat.setAttribute(0, sd)
202+
outfeat.setAttribute(1, j)
203203
else:
204204
outfeat.setGeometry(QgsGeometry.fromPoint(meanPoint))
205-
outfeat.setAttribute(0, QVariant(cx))
206-
outfeat.setAttribute(1, QVariant(cy))
207-
outfeat.setAttribute(2, QVariant(j))
205+
outfeat.setAttribute(0, cx)
206+
outfeat.setAttribute(1, cy)
207+
outfeat.setAttribute(2, j)
208208
writer.addFeature(outfeat)
209209
if single:
210210
break

‎python/plugins/fTools/tools/doMergeShapes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def inputDir( self ):
5858

5959
workDir = QDir( inDir )
6060
workDir.setFilter( QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot )
61-
nameFilter = QStringList() << "*.shp" << "*.SHP"
61+
nameFilter = [ "*.shp", "*.SHP" ]
6262
workDir.setNameFilters( nameFilter )
6363
self.inputFiles = workDir.entryList()
6464
if self.inputFiles.count() == 0:
@@ -84,7 +84,7 @@ def inputFile( self ):
8484
self.inputFiles = None
8585
return
8686

87-
self.inputFiles = QStringList()
87+
self.inputFiles = []
8888
for f in files:
8989
fileName = QFileInfo( f ).fileName()
9090
self.inputFiles.append( fileName )
@@ -118,7 +118,7 @@ def accept( self ):
118118
if self.inputFiles is None:
119119
workDir = QDir( self.leInputDir.text() )
120120
workDir.setFilter( QDir.Files | QDir.NoSymLinks | QDir.NoDotAndDotDot )
121-
nameFilter = QStringList() << "*.shp" << "*.SHP"
121+
nameFilter = [ "*.shp" << "*.SHP" ]
122122
workDir.setNameFilters( nameFilter )
123123
self.inputFiles = workDir.entryList()
124124
if self.inputFiles.count() == 0:
@@ -306,7 +306,7 @@ def run( self ):
306306
inGeom = QgsGeometry()
307307
fit = vprovider.getFeatures()
308308
while fit.nextFeature( inFeat ):
309-
mergedAttrs = [QVariant()] * len(mergedFields)
309+
mergedAttrs = [""] * len(mergedFields)
310310

311311
# fill available attributes with values
312312
fieldIndex = 0

‎python/plugins/fTools/tools/doPointDistance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def compute(self, line1, line2, field1, field2, outPath, matType, nearest, progr
158158
provider2 = layer2.dataProvider()
159159
sindex = QgsSpatialIndex()
160160
inFeat = QgsFeature()
161-
fit2 = provider2.getFeatures()
161+
fit2 = provider2.getFeatures()
162162
while fit2.nextFeature(inFeat):
163163
sindex.insertFeature(inFeat)
164164
if nearest < 1: nearest = layer2.featureCount()
@@ -190,7 +190,7 @@ def regularMatrix(self, writer, provider1, provider2, index1, index2, nearest, d
190190
first = True
191191
start = 15.00
192192
add = 85.00 / provider1.featureCount()
193-
fit1 = provider1.getFeatures()
193+
fit1 = provider1.getFeatures()
194194
while fit1.nextFeature(inFeat):
195195
inGeom = inFeat.geometry()
196196
inID = inFeat.attributes()[index1]

‎python/plugins/fTools/tools/doPointsInPolygon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def outFile(self):
6363
(self.shapefileName, self.encoding) = ftools_utils.saveDialog(self)
6464
if self.shapefileName is None or self.encoding is None:
6565
return
66-
self.outShape.setText(QString(self.shapefileName))
66+
self.outShape.setText(self.shapefileName)
6767

6868
def accept(self):
6969
if self.inPolygon.currentText() == "":
@@ -188,7 +188,7 @@ def run(self):
188188
pntFeat = QgsFeature()
189189
outFeat = QgsFeature()
190190
inGeom = QgsGeometry()
191-
polyFit = polyProvider.getFeatures()
191+
polyFit = polyProvider.getFeatures()
192192
while polyFit.nextFeature(polyFeat):
193193
inGeom = polyFeat.geometry()
194194
atMap = polyFeat.attributes()
@@ -218,7 +218,7 @@ def run(self):
218218
interrupted = True
219219
break
220220

221-
atMap.append(QVariant(count))
221+
atMap.append(count)
222222
outFeat.setAttributes(atMap)
223223
writer.addFeature(outFeat)
224224

‎python/plugins/fTools/tools/doRandPoints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def outFile(self):
138138
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
139139
if self.shapefileName is None or self.encoding is None:
140140
return
141-
self.outShape.setText( QString( self.shapefileName ) )
141+
self.outShape.setText( self.shapefileName )
142142

143143
# combine all polygons in layer to create single polygon (slow for complex polygons)
144144
def createSinglePolygon(self, vlayer):
@@ -225,7 +225,7 @@ def randomize(self, inLayer, outPath, minimum, design, value):
225225
add = ( 100.00 - 70.00 ) / len(points)
226226
for i in points:
227227
outFeat.setGeometry(i)
228-
outFeat.setAttribute(0, QVariant(idVar))
228+
outFeat.setAttribute(0, idVar)
229229
writer.addFeature(outFeat)
230230
idVar = idVar + 1
231231
count = count + add

‎python/plugins/fTools/tools/doRegPoints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def outFile(self):
102102
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
103103
if self.shapefileName is None or self.encoding is None:
104104
return
105-
self.outShape.setText( QString( self.shapefileName ) )
105+
self.outShape.setText( self.shapefileName )
106106

107107
# Generate list of random points
108108
def simpleRandom(self, n, bound, xmin, xmax, ymin, ymax):
@@ -149,7 +149,7 @@ def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
149149
pGeom = QgsGeometry().fromPoint(QgsPoint(x, y))
150150
if pGeom.intersects(bound):
151151
outFeat.setGeometry(pGeom)
152-
outFeat.setAttribute(0, QVariant(idVar))
152+
outFeat.setAttribute(0, idVar)
153153
writer.addFeature(outFeat)
154154
idVar = idVar + 1
155155
x = x + pointSpacing

‎python/plugins/fTools/tools/doSimplify.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def selectOutputFile( self ):
8585
( self.shapeFileName, self.encoding ) = ftools_utils.saveDialog( self )
8686
if self.shapeFileName is None or self.encoding is None:
8787
return
88-
self.edOutputFile.setText( QString( self.shapeFileName ) )
88+
self.edOutputFile.setText( self.shapeFileName )
8989

9090
def accept( self ):
9191
vLayer = ftools_utils.getVectorLayerByName( self.cmbInputLayer.currentText() )
@@ -301,7 +301,7 @@ def runSimplify( self ):
301301
else:
302302
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
303303
f = QgsFeature()
304-
fit = vProvider.getFeatures()
304+
fit = vProvider.getFeatures()
305305
while fit.nextFeature( f ):
306306
featGeometry = QgsGeometry( f.geometry() )
307307
attrMap = f.attributes()
@@ -326,7 +326,7 @@ def runSimplify( self ):
326326
else: # modify existing shapefile
327327
if not self.inputLayer.isEditable():
328328
self.inputLayer.startEditing()
329-
self.inputLayer.beginEditCommand( QString( "Simplify line(s)" ) )
329+
self.inputLayer.beginEditCommand( "Simplify line(s)" )
330330
if self.useSelection:
331331
selection = self.inputLayer.selectedFeatures()
332332
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), len( selection ) )
@@ -351,7 +351,7 @@ def runSimplify( self ):
351351
vProvider = self.inputLayer.dataProvider()
352352
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
353353
f = QgsFeature()
354-
fit = vProvider.getFeatures()
354+
fit = vProvider.getFeatures()
355355
while fit.nextFeature( f ):
356356
featureId = f.id()
357357
featGeometry = QgsGeometry( f.geometry() )
@@ -428,7 +428,7 @@ def runDensify( self ):
428428
else:
429429
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
430430
f = QgsFeature()
431-
fit = vProvider.getFeatures()
431+
fit = vProvider.getFeatures()
432432
while fit.nextFeature( f ):
433433
featGeometry = QgsGeometry( f.geometry() )
434434
attrMap = f.attributes()
@@ -451,7 +451,7 @@ def runDensify( self ):
451451
if not self.inputLayer.isEditable():
452452
self.inputLayer.startEditing()
453453

454-
self.inputLayer.beginEditCommand( QString( "Densify line(s)" ) )
454+
self.inputLayer.beginEditCommand( "Densify line(s)" )
455455

456456
if self.useSelection:
457457
selection = self.inputLayer.selectedFeatures()
@@ -474,7 +474,7 @@ def runDensify( self ):
474474
vProvider = self.inputLayer.dataProvider()
475475
self.emit( SIGNAL( "rangeCalculated( PyQt_PyObject )" ), vProvider.featureCount() )
476476
f = QgsFeature()
477-
fit = vProvider.getFeatures()
477+
fit = vProvider.getFeatures()
478478
while fit.nextFeature( f ):
479479
featureId = f.id()
480480
featGeometry = QgsGeometry( f.geometry() )

‎python/plugins/fTools/tools/doSpatialIndex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def processFinished( self, errors ):
134134
self.restoreGui()
135135

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

140140
QMessageBox.information( self, self.tr( "Finished" ), self.tr( "Processing completed." ) )
@@ -162,7 +162,7 @@ def __init__( self, layers, isFiles ):
162162
self.mutex = QMutex()
163163
self.stopMe = 0
164164

165-
self.errors = QStringList()
165+
self.errors = []
166166

167167
def run( self ):
168168
self.mutex.lock()

‎python/plugins/fTools/tools/doSpatialJoin.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def outFile(self):
117117
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
118118
if self.shapefileName is None or self.encoding is None:
119119
return
120-
self.outShape.setText( QString( self.shapefileName ) )
120+
self.outShape.setText( self.shapefileName )
121121

122122
def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar):
123123
layer1 = ftools_utils.getVectorLayerByName(inName)
@@ -225,13 +225,13 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
225225
atMap = atMap1
226226
for j in numFields.keys():
227227
for k in sumList:
228-
if k == "SUM": atMap.append(QVariant(sum(numFields[j])))
229-
elif k == "MEAN": atMap.append(QVariant(sum(numFields[j]) / count))
230-
elif k == "MIN": atMap.append(QVariant(min(numFields[j])))
231-
elif k == "MED": atMap.append(QVariant(myself(numFields[j])))
232-
else: atMap.append(QVariant(max(numFields[j])))
228+
if k == "SUM": atMap.append(sum(numFields[j]))
229+
elif k == "MEAN": atMap.append(sum(numFields[j]) / count)
230+
elif k == "MIN": atMap.append(min(numFields[j]))
231+
elif k == "MED": atMap.append(myself(numFields[j]))
232+
else: atMap.append(max(numFields[j]))
233233
numFields[j] = []
234-
atMap.append(QVariant(count))
234+
atMap.append(count)
235235
atMap = dict(zip(seq, atMap))
236236
if none:
237237
outFeat.setAttributes(atMap1)

‎python/plugins/fTools/tools/doSubsetSelect.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ def compute(self, inVect, inField, value, perc, progressBar):
8585
vlayer = ftools_utils.getVectorLayerByName(inVect)
8686
vprovider = vlayer.dataProvider()
8787
index = vprovider.fieldNameIndex(inField)
88-
#unique = []
89-
#vprovider.uniqueValues(index, unique)
9088
unique = ftools_utils.getUniqueValues(vprovider, int(index))
9189
inFeat = QgsFeature()
9290
selran = []
@@ -101,7 +99,7 @@ def compute(self, inVect, inField, value, perc, progressBar):
10199
FIDs= []
102100
while fit.nextFeature(inFeat):
103101
atMap = inFeat.attributes()
104-
if atMap[index] == QVariant(i):
102+
if atMap[index] == i:
105103
FID = inFeat.id()
106104
FIDs.append(FID)
107105
nElement += 1

‎python/plugins/fTools/tools/doSumLines.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def outFile(self):
9191
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
9292
if self.shapefileName is None or self.encoding is None:
9393
return
94-
self.outShape.setText( QString( self.shapefileName ) )
94+
self.outShape.setText( self.shapefileName )
9595

9696
def compute(self, inPoly, inLns, inField, outPath, progressBar):
9797
polyLayer = ftools_utils.getVectorLayerByName(inPoly)
@@ -137,9 +137,8 @@ def compute(self, inPoly, inLns, inField, outPath, progressBar):
137137
outGeom = inGeom.intersection(tmpGeom)
138138
length = length + distArea.measure(outGeom)
139139
outFeat.setGeometry(inGeom)
140-
atMap.append(QVariant(length))
140+
atMap.append(length)
141141
outFeat.setAttributes(atMap)
142-
#outFeat.setAttribute(index, QVariant(length))
143142
writer.addFeature(outFeat)
144143
start = start + 1
145144
progressBar.setValue(start)

‎python/plugins/fTools/tools/doValidate.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,15 @@ def __init__(self, iface):
103103

104104
def closeEvent(self, e):
105105
settings = QSettings()
106-
settings.setValue( "/fTools/ValidateDialog/geometry", QVariant(self.saveGeometry()) )
106+
settings.setValue( "/fTools/ValidateDialog/geometry", self.saveGeometry())
107107
QDialog.closeEvent(self, e)
108108
del self.marker
109109

110110
def keyPressEvent( self, e ):
111111
if ( e.modifiers() == Qt.ControlModifier or \
112112
e.modifiers() == Qt.MetaModifier ) and \
113113
e.key() == Qt.Key_C:
114-
#selection = self.tblUnique.selectedItems()
115-
items = QString()
114+
items = ""
116115
for row in range( self.tblUnique.rowCount() ):
117116
items.append( self.tblUnique.item( row, 0 ).text()
118117
+ "," + self.tblUnique.item( row, 1 ).text() + "\n" )
@@ -156,7 +155,7 @@ def outFile( self ):
156155
(self.shapefileName, self.encoding) = ftools_utils.saveDialog( self )
157156
if self.shapefileName is None or self.encoding is None:
158157
return
159-
self.lineEditShpError.setText( QString( self.shapefileName ) )
158+
self.lineEditShpError.setText( self.shapefileName )
160159

161160
def zoomToError(self, curr, prev):
162161
if curr is None:
@@ -250,7 +249,7 @@ def runFinishedFromThread( self, success ):
250249
message = err.what()
251250
errItem = QTableWidgetItem( message )
252251
if err.hasWhere(): # if there is a location associated with the error
253-
errItem.setData(Qt.UserRole, QVariant(err.where()))
252+
errItem.setData(Qt.UserRole, err.where())
254253
self.tblUnique.setItem( count, 1, errItem )
255254
count += 1
256255
self.tblUnique.setHorizontalHeaderLabels( [ self.tr("Feature"), self.tr("Error(s)") ] )
@@ -336,7 +335,7 @@ def check_geometry( self, vlayer ):
336335
geometry = QgsGeometry().fromPoint( myPoint )
337336
ft = QgsFeature()
338337
ft.setGeometry( geometry )
339-
ft.setAttributes( [ QVariant( fidItem ), QVariant( message ) ] )
338+
ft.setAttributes( [ fidItem, message ] )
340339
writer.addFeature( ft )
341340
del writer
342341
return "writeShape"

‎python/plugins/fTools/tools/doVectorGrid.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ def compute( self, bound, xOffset, yOffset, polygon ):
203203
pt2 = QgsPoint(bound.xMaximum(), y)
204204
line = [pt1, pt2]
205205
outFeat.setGeometry(outGeom.fromPolyline(line))
206-
outFeat.setAttribute(0, QVariant(idVar))
207-
outFeat.setAttribute(1, QVariant(y))
206+
outFeat.setAttribute(0, idVar)
207+
outFeat.setAttribute(1, y)
208208
writer.addFeature(outFeat)
209209
y = y - yOffset
210210
idVar = idVar + 1
@@ -223,8 +223,8 @@ def compute( self, bound, xOffset, yOffset, polygon ):
223223
pt2 = QgsPoint(x, bound.yMinimum())
224224
line = [pt1, pt2]
225225
outFeat.setGeometry(outGeom.fromPolyline(line))
226-
outFeat.setAttribute(0, QVariant(idVar))
227-
outFeat.setAttribute(1, QVariant(x))
226+
outFeat.setAttribute(0, idVar)
227+
outFeat.setAttribute(1, x)
228228
writer.addFeature(outFeat)
229229
x = x + xOffset
230230
idVar = idVar + 1
@@ -248,11 +248,11 @@ def compute( self, bound, xOffset, yOffset, polygon ):
248248
pt5 = QgsPoint(x, y)
249249
polygon = [[pt1, pt2, pt3, pt4, pt5]]
250250
outFeat.setGeometry(outGeom.fromPolygon(polygon))
251-
outFeat.setAttribute(0, QVariant(idVar))
252-
outFeat.setAttribute(1, QVariant(x))
253-
outFeat.setAttribute(2, QVariant(x + xOffset))
254-
outFeat.setAttribute(3, QVariant(y - yOffset))
255-
outFeat.setAttribute(4, QVariant(y))
251+
outFeat.setAttribute(0, idVar)
252+
outFeat.setAttribute(1, x)
253+
outFeat.setAttribute(2, x + xOffset)
254+
outFeat.setAttribute(3, y - yOffset)
255+
outFeat.setAttribute(4, y)
256256
writer.addFeature(outFeat)
257257
idVar = idVar + 1
258258
x = x + xOffset
@@ -269,7 +269,7 @@ def outFile(self):
269269
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
270270
if self.shapefileName is None or self.encoding is None:
271271
return
272-
self.outShape.setText( QString( self.shapefileName ) )
272+
self.outShape.setText( self.shapefileName )
273273

274274
def chkAlignToggled(self):
275275
if self.chkAlign.isChecked():

‎python/plugins/fTools/tools/doVectorSplit.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def outFile(self):
6767
( self.folderName, self.encoding ) = ftools_utils.dirDialog( self )
6868
if self.folderName is None or self.encoding is None:
6969
return
70-
self.outShape.setText( QString( self.folderName ) )
70+
self.outShape.setText( self.folderName )
7171

7272
def accept(self):
7373
inShape = self.inShape.currentText()
@@ -124,7 +124,7 @@ def processFinished(self, errors):
124124
self.restoreGui()
125125

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

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

144-
self.errors = QStringList()
144+
self.errors = []
145145

146146
def run(self):
147147
self.mutex.lock()
@@ -150,12 +150,12 @@ def run(self):
150150

151151
interrupted = False
152152

153-
outPath = QString(self.outDir)
153+
outPath = self.outDir
154154

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

158-
if not outPath.endsWith("/"):
158+
if not outPath.endswith("/"):
159159
outPath = outPath + "/"
160160

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

173173

174174
for i in unique:
175-
check = QFile(baseName + "_" + unicode(i.toString().trimmed()) + ".shp")
175+
check = QFile(baseName + "_" + unicode(i.strip()) + ".shp")
176176
fName = check.fileName()
177177
if check.exists():
178178
if not QgsVectorFileWriter.deleteShapeFile(fName):

‎python/plugins/fTools/tools/doVisual.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def keyPressEvent( self, e ):
6565
'''
6666
if ( e.modifiers() == Qt.ControlModifier or e.modifiers() == Qt.MetaModifier ) and e.key() == Qt.Key_C:
6767
#selection = self.tblUnique.selectedItems()
68-
items = QString()
68+
items = ""
6969
if self.myFunction in ( 1, 2 ):
7070
for rec in range( self.tblUnique.rowCount() ):
7171
items.append( self.tblUnique.item( rec, 0 ).text() + "\n" )
@@ -245,7 +245,7 @@ def list_unique_values( self, vlayer, myField ):
245245
for item in unique:
246246
nElement += 1
247247
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
248-
lstUnique.append(item.toString().trimmed())
248+
lstUnique.append(item.strip())
249249
lstCount = len( unique )
250250
return ( lstUnique, lstCount )
251251

‎python/plugins/fTools/tools/ftools_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def checkCRSCompatibility( crsA, crsB ):
8989

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

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

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.