Skip to content
Permalink
Browse files

start update fTools to new SIP api

  • Loading branch information
alexbruy committed May 30, 2013
1 parent e4edb1b commit 2d9e1b61949fb7bd65ab44f002fe81f94e6601d5
@@ -55,9 +55,9 @@ def __init__(self,iface):

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):
@@ -50,14 +50,14 @@ def __init__(self, iface):
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 @@ def accept(self):
self.buttonOk.setEnabled( True )

def outProjFile(self):
format = QString( "<h2>%1</h2>%2 <br/> %3" )
header = QString( "Define layer CRS:" )
format = "<h2>%1</h2>%2 <br/> %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)
@@ -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,15 +338,15 @@ 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
else:
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,21 +364,21 @@ 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" )
if not vLayer.isValid():
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

0 comments on commit 2d9e1b6

Please sign in to comment.
You can’t perform that action at this time.