From 2d9e1b61949fb7bd65ab44f002fe81f94e6601d5 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Thu, 30 May 2013 16:15:08 +0400 Subject: [PATCH] start update fTools to new SIP api --- python/plugins/fTools/fTools.py | 6 ++-- python/plugins/fTools/tools/doDefineProj.py | 12 +++---- python/plugins/fTools/tools/ftools_utils.py | 36 ++++++++++----------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/python/plugins/fTools/fTools.py b/python/plugins/fTools/fTools.py index 71a61b11b80..565e23c8e93 100644 --- a/python/plugins/fTools/fTools.py +++ b/python/plugins/fTools/fTools.py @@ -55,9 +55,9 @@ class fToolsPlugin: def getThemeIcon(self, icon): settings = QSettings() - pluginPath = QString(os.path.dirname(__file__)) - themePath = QString("icons") + QDir.separator() + QString(settings.value("/Themes").toString()) + QDir.separator() + QString(icon) - defaultPath = QString("icons") + QDir.separator() + QString("default") + QDir.separator() + QString(icon) + pluginPath = os.path.dirname(__file__) + themePath = "icons" + QDir.separator() + settings.value("/Themes") + QDir.separator() + icon + defaultPath = "icons" + QDir.separator() + "default" + QDir.separator() + icon if QFile.exists(pluginPath + QDir.separator() + themePath): return QIcon(":" + themePath) elif QFile.exists(pluginPath + QDir.separator() + defaultPath): diff --git a/python/plugins/fTools/tools/doDefineProj.py b/python/plugins/fTools/tools/doDefineProj.py index 1ab1658b7bf..e8729cd3150 100644 --- a/python/plugins/fTools/tools/doDefineProj.py +++ b/python/plugins/fTools/tools/doDefineProj.py @@ -50,14 +50,14 @@ class Dialog(QDialog, Ui_Dialog): self.setWindowTitle(self.tr("Define current projection")) self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok ) 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) + #QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateProj1) + #QObject.connect(self.cmbLayer, SIGNAL("currentIndexChanged(QString)"), self.updateProj2) # 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) - self.cmbLayer.addItems(layers) + #self.inShape.addItems(layers) + #self.cmbLayer.addItems(layers) self.crs = None @@ -147,8 +147,8 @@ class Dialog(QDialog, Ui_Dialog): self.buttonOk.setEnabled( True ) def outProjFile(self): - format = QString( "

%1

%2
%3" ) - header = QString( "Define layer CRS:" ) + format = "

%1

%2
%3" + header = "Define layer CRS:" sentence1 = self.tr( "Please select the projection system that defines the current layer." ) sentence2 = self.tr( "Layer CRS information will be updated to the selected CRS." ) projSelector = QgsGenericProjectionSelector(self) diff --git a/python/plugins/fTools/tools/ftools_utils.py b/python/plugins/fTools/tools/ftools_utils.py index 1dd587e29ad..46908bbf5ac 100644 --- a/python/plugins/fTools/tools/ftools_utils.py +++ b/python/plugins/fTools/tools/ftools_utils.py @@ -183,10 +183,10 @@ def createUniqueFieldName( field ): # Return list of field names with more than 10 characters length def checkFieldNameLength( fieldList ): - longNames = QStringList() + longNames = [] for field in fieldList: if field.name().size() > 10: - longNames << unicode( field.name() ) + longNames.append(unicode( field.name() )) return longNames # Return list of names of all layers in QgsMapLayerRegistry @@ -279,10 +279,10 @@ def getUniqueValues( provider, index ): # Generate a save file dialog with a dropdown box for choosing encoding style def saveDialog( parent, filtering="Shapefiles (*.shp *.SHP)"): settings = QSettings() - dirName = settings.value( "/UI/lastShapefileDir" ).toString() - encode = settings.value( "/UI/encoding" ).toString() - fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, QString(filtering), encode ) - fileDialog.setDefaultSuffix( QString( "shp" ) ) + dirName = settings.value( "/UI/lastShapefileDir" ) + encode = settings.value( "/UI/encoding" ) + fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, filtering, encode ) + fileDialog.setDefaultSuffix( "shp" ) fileDialog.setFileMode( QFileDialog.AnyFile ) fileDialog.setAcceptMode( QFileDialog.AcceptSave ) fileDialog.setConfirmOverwrite( True ) @@ -296,9 +296,9 @@ def saveDialog( parent, filtering="Shapefiles (*.shp *.SHP)"): # with mode="SingleFile" will allow to select only one file, in other cases - several files def openDialog( parent, filtering="Shapefiles (*.shp *.SHP)", dialogMode="SingleFile"): settings = QSettings() - dirName = settings.value( "/UI/lastShapefileDir" ).toString() - encode = settings.value( "/UI/encoding" ).toString() - fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, QString(filtering), encode ) + dirName = settings.value( "/UI/lastShapefileDir" ) + encode = settings.value( "/UI/encoding" ) + fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, filtering, encode ) fileDialog.setFileMode( QFileDialog.ExistingFiles ) fileDialog.setAcceptMode( QFileDialog.AcceptOpen ) if not fileDialog.exec_() == QDialog.Accepted: @@ -313,8 +313,8 @@ def openDialog( parent, filtering="Shapefiles (*.shp *.SHP)", dialogMode="Single # Generate a select directory dialog with a dropdown box for choosing encoding style def dirDialog( parent ): settings = QSettings() - dirName = settings.value( "/UI/lastShapefileDir" ).toString() - encode = settings.value( "/UI/encoding" ).toString() + dirName = settings.value( "/UI/lastShapefileDir" ) + encode = settings.value( "/UI/encoding" ) fileDialog = QgsEncodingFileDialog( parent, "Save output shapefile", dirName, encode ) fileDialog.setFileMode( QFileDialog.DirectoryOnly ) fileDialog.setAcceptMode( QFileDialog.AcceptSave ) @@ -338,7 +338,7 @@ def getUniqueValuesCount( vlayer, fieldIndex, useSelection ): if useSelection: selection = vlayer.selectedFeatures() for f in selection: - v = f.attributes()[ fieldIndex ].toString() + v = f.attributes()[ fieldIndex ] if v not in values: values.append( v ) count += 1 @@ -346,7 +346,7 @@ def getUniqueValuesCount( vlayer, fieldIndex, useSelection ): feat = QgsFeature() fit = vlayer.dataProvider().getFeatures() while fit.nextFeature( feat ): - v = feat.attributes()[ fieldIndex ].toString() + v = feat.attributes()[ fieldIndex ] if v not in values: values.append( v ) count += 1 @@ -364,7 +364,7 @@ def getGeomType(gT): return gTypeListPoint def getShapesByGeometryType( baseDir, inShapes, geomType ): - outShapes = QStringList() + outShapes = [] for fileName in inShapes: layerPath = QFileInfo( baseDir + "/" + fileName ).absoluteFilePath() vLayer = QgsVectorLayer( layerPath, QFileInfo( layerPath ).baseName(), "ogr" ) @@ -372,13 +372,13 @@ def getShapesByGeometryType( baseDir, inShapes, geomType ): continue layerGeometry = vLayer.geometryType() if layerGeometry == QGis.Polygon and geomType == 0: - outShapes << fileName + outShapes.append(fileName) elif layerGeometry == QGis.Line and geomType == 1: - outShapes << fileName + outShapes.append(fileName) elif layerGeometry == QGis.Point and geomType == 2: - outShapes << fileName + outShapes.append(fileName) - if outShapes.count() == 0: + if len(outShapes) == 0: return None return outShapes