Skip to content

Commit

Permalink
now supports fields containing Cyrillics. Fixes #2566. Patch from ale…
Browse files Browse the repository at this point in the history
…xbruy

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13477 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer committed May 13, 2010
1 parent caba437 commit dc8874e
Showing 1 changed file with 9 additions and 62 deletions.
71 changes: 9 additions & 62 deletions python/plugins/fTools/tools/doVectorSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, iface):
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
self.setWindowTitle(self.tr("Split vector layer"))
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
Expand All @@ -59,6 +60,7 @@ def update(self, inputLayer):
self.inField.addItem(unicode(changedField[i].name()))

def accept(self):
self.buttonOk.setEnabled( False )
if self.inShape.currentText() == "":
QMessageBox.information(self, self.tr("Vector Split"), self.tr("No input shapefile specified"))
elif self.outShape.text() == "":
Expand All @@ -77,78 +79,23 @@ def accept(self):
self.progressBar.setValue(100)
self.outShape.clear()
QMessageBox.information(self, self.tr("Vector Split"), self.tr("Created output shapefiles in folder:\n%1").arg( outPath))
self.progressBar.setValue(0)
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

def outFile(self):
fileDialog = QFileDialog()
settings = QSettings()
dirName = settings.value("/UI/lastShapefileDir").toString()
fileDialog.setDirectory(dirName)
encodingBox = QComboBox()
l = QLabel("Encoding:",fileDialog)
fileDialog.layout().addWidget(l)
fileDialog.layout().addWidget(encodingBox)
encodingBox.addItem("BIG5")
encodingBox.addItem("BIG5-HKSCS")
encodingBox.addItem("EUCJP")
encodingBox.addItem("EUCKR")
encodingBox.addItem("GB2312")
encodingBox.addItem("GBK")
encodingBox.addItem("GB18030")
encodingBox.addItem("JIS7")
encodingBox.addItem("SHIFT-JIS")
encodingBox.addItem("TSCII")
encodingBox.addItem("UTF-8")
encodingBox.addItem("UTF-16")
encodingBox.addItem("KOI8-R")
encodingBox.addItem("KOI8-U")
encodingBox.addItem("ISO8859-1")
encodingBox.addItem("ISO8859-2")
encodingBox.addItem("ISO8859-3")
encodingBox.addItem("ISO8859-4")
encodingBox.addItem("ISO8859-5")
encodingBox.addItem("ISO8859-6")
encodingBox.addItem("ISO8859-7")
encodingBox.addItem("ISO8859-8")
encodingBox.addItem("ISO8859-8-I")
encodingBox.addItem("ISO8859-9")
encodingBox.addItem("ISO8859-10")
encodingBox.addItem("ISO8859-13")
encodingBox.addItem("ISO8859-14")
encodingBox.addItem("ISO8859-15")
encodingBox.addItem("IBM 850")
encodingBox.addItem("IBM 866")
encodingBox.addItem("CP874")
encodingBox.addItem("CP1250")
encodingBox.addItem("CP1251")
encodingBox.addItem("CP1252")
encodingBox.addItem("CP1253")
encodingBox.addItem("CP1254")
encodingBox.addItem("CP1255")
encodingBox.addItem("CP1256")
encodingBox.addItem("CP1257")
encodingBox.addItem("CP1258")
encodingBox.addItem("Apple Roman")
encodingBox.addItem("TIS-620")
encodingBox.setItemText(encodingBox.currentIndex(), QString(QTextCodec.codecForLocale().name()))
fileDialog.setAcceptMode(QFileDialog.AcceptSave)
fileDialog.setFileMode(QFileDialog.DirectoryOnly)
fileDialog.setConfirmOverwrite(False)
if not fileDialog.exec_() == 1:
return
folders = fileDialog.selectedFiles()
self.folderName = unicode(folders.first())
self.encoding = unicode(encodingBox.currentText())
self.outShape.clear()
self.outShape.insert(self.folderName)
( 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 ) )

def split(self, vlayer, outPath, inField, progressBar):
provider = vlayer.dataProvider()
#unique = []
index = provider.fieldNameIndex(inField)
#provider.uniqueValues(index, unique)
unique = ftools_utils.getUniqueValues(vlayer.dataProvider(), int(index))
baseName = outPath + vlayer.name() + "_" + inField + "_"
baseName = unicode( outPath + vlayer.name() + "_" + inField + "_" )
allAttrs = provider.attributeIndexes()
provider.select(allAttrs)
fieldList = ftools_utils.getFieldList(vlayer)
Expand Down

0 comments on commit dc8874e

Please sign in to comment.