Skip to content

Commit 2d9e1b6

Browse files
committedMay 30, 2013
start update fTools to new SIP api
1 parent e4edb1b commit 2d9e1b6

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed
 

‎python/plugins/fTools/fTools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def __init__(self,iface):
5555

5656
def getThemeIcon(self, icon):
5757
settings = QSettings()
58-
pluginPath = QString(os.path.dirname(__file__))
59-
themePath = QString("icons") + QDir.separator() + QString(settings.value("/Themes").toString()) + QDir.separator() + QString(icon)
60-
defaultPath = QString("icons") + QDir.separator() + QString("default") + QDir.separator() + QString(icon)
58+
pluginPath = os.path.dirname(__file__)
59+
themePath = "icons" + QDir.separator() + settings.value("/Themes") + QDir.separator() + icon
60+
defaultPath = "icons" + QDir.separator() + "default" + QDir.separator() + icon
6161
if QFile.exists(pluginPath + QDir.separator() + themePath):
6262
return QIcon(":" + themePath)
6363
elif QFile.exists(pluginPath + QDir.separator() + defaultPath):

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ def __init__(self, iface):
5050
self.setWindowTitle(self.tr("Define current projection"))
5151
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
5252
QObject.connect(self.btnProjection, SIGNAL("clicked()"), self.outProjFile)
53-
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1)
54-
QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2)
53+
#QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1)
54+
#QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2)
5555
# populate layer list
5656
self.progressBar.setValue(0)
5757
mapCanvas = self.iface.mapCanvas()
5858
layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
59-
self.inShape.addItems(layers)
60-
self.cmbLayer.addItems(layers)
59+
#self.inShape.addItems(layers)
60+
#self.cmbLayer.addItems(layers)
6161

6262
self.crs = None
6363

@@ -147,8 +147,8 @@ def accept(self):
147147
self.buttonOk.setEnabled( True )
148148

149149
def outProjFile(self):
150-
format = QString( "<h2>%1</h2>%2 <br/> %3" )
151-
header = QString( "Define layer CRS:" )
150+
format = "<h2>%1</h2>%2 <br/> %3"
151+
header = "Define layer CRS:"
152152
sentence1 = self.tr( "Please select the projection system that defines the current layer." )
153153
sentence2 = self.tr( "Layer CRS information will be updated to the selected CRS." )
154154
projSelector = QgsGenericProjectionSelector(self)

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ def createUniqueFieldName( field ):
183183

184184
# Return list of field names with more than 10 characters length
185185
def checkFieldNameLength( fieldList ):
186-
longNames = QStringList()
186+
longNames = []
187187
for field in fieldList:
188188
if field.name().size() > 10:
189-
longNames << unicode( field.name() )
189+
longNames.append(unicode( field.name() ))
190190
return longNames
191191

192192
# Return list of names of all layers in QgsMapLayerRegistry
@@ -279,10 +279,10 @@ def getUniqueValues( provider, index ):
279279
# Generate a save file dialog with a dropdown box for choosing encoding style
280280
def saveDialog( parent, filtering="Shapefiles (*.shp *.SHP)"):
281281
settings = QSettings()
282-
dirName = settings.value( "/UI/lastShapefileDir" ).toString()
283-
encode = settings.value( "/UI/encoding" ).toString()
284-
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, QString(filtering), encode )
285-
fileDialog.setDefaultSuffix( QString( "shp" ) )
282+
dirName = settings.value( "/UI/lastShapefileDir" )
283+
encode = settings.value( "/UI/encoding" )
284+
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, filtering, encode )
285+
fileDialog.setDefaultSuffix( "shp" )
286286
fileDialog.setFileMode( QFileDialog.AnyFile )
287287
fileDialog.setAcceptMode( QFileDialog.AcceptSave )
288288
fileDialog.setConfirmOverwrite( True )
@@ -296,9 +296,9 @@ def saveDialog( parent, filtering="Shapefiles (*.shp *.SHP)"):
296296
# with mode="SingleFile" will allow to select only one file, in other cases - several files
297297
def openDialog( parent, filtering="Shapefiles (*.shp *.SHP)", dialogMode="SingleFile"):
298298
settings = QSettings()
299-
dirName = settings.value( "/UI/lastShapefileDir" ).toString()
300-
encode = settings.value( "/UI/encoding" ).toString()
301-
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, QString(filtering), encode )
299+
dirName = settings.value( "/UI/lastShapefileDir" )
300+
encode = settings.value( "/UI/encoding" )
301+
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, filtering, encode )
302302
fileDialog.setFileMode( QFileDialog.ExistingFiles )
303303
fileDialog.setAcceptMode( QFileDialog.AcceptOpen )
304304
if not fileDialog.exec_() == QDialog.Accepted:
@@ -313,8 +313,8 @@ def openDialog( parent, filtering="Shapefiles (*.shp *.SHP)", dialogMode="Single
313313
# Generate a select directory dialog with a dropdown box for choosing encoding style
314314
def dirDialog( parent ):
315315
settings = QSettings()
316-
dirName = settings.value( "/UI/lastShapefileDir" ).toString()
317-
encode = settings.value( "/UI/encoding" ).toString()
316+
dirName = settings.value( "/UI/lastShapefileDir" )
317+
encode = settings.value( "/UI/encoding" )
318318
fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, encode )
319319
fileDialog.setFileMode( QFileDialog.DirectoryOnly )
320320
fileDialog.setAcceptMode( QFileDialog.AcceptSave )
@@ -338,15 +338,15 @@ def getUniqueValuesCount( vlayer, fieldIndex, useSelection ):
338338
if useSelection:
339339
selection = vlayer.selectedFeatures()
340340
for f in selection:
341-
v = f.attributes()[ fieldIndex ].toString()
341+
v = f.attributes()[ fieldIndex ]
342342
if v not in values:
343343
values.append( v )
344344
count += 1
345345
else:
346346
feat = QgsFeature()
347347
fit = vlayer.dataProvider().getFeatures()
348348
while fit.nextFeature( feat ):
349-
v = feat.attributes()[ fieldIndex ].toString()
349+
v = feat.attributes()[ fieldIndex ]
350350
if v not in values:
351351
values.append( v )
352352
count += 1
@@ -364,21 +364,21 @@ def getGeomType(gT):
364364
return gTypeListPoint
365365

366366
def getShapesByGeometryType( baseDir, inShapes, geomType ):
367-
outShapes = QStringList()
367+
outShapes = []
368368
for fileName in inShapes:
369369
layerPath = QFileInfo( baseDir + "/" + fileName ).absoluteFilePath()
370370
vLayer = QgsVectorLayer( layerPath, QFileInfo( layerPath ).baseName(), "ogr" )
371371
if not vLayer.isValid():
372372
continue
373373
layerGeometry = vLayer.geometryType()
374374
if layerGeometry == QGis.Polygon and geomType == 0:
375-
outShapes << fileName
375+
outShapes.append(fileName)
376376
elif layerGeometry == QGis.Line and geomType == 1:
377-
outShapes << fileName
377+
outShapes.append(fileName)
378378
elif layerGeometry == QGis.Point and geomType == 2:
379-
outShapes << fileName
379+
outShapes.append(fileName)
380380

381-
if outShapes.count() == 0:
381+
if len(outShapes) == 0:
382382
return None
383383

384384
return outShapes

0 commit comments

Comments
 (0)