Skip to content

Commit dc8874e

Browse files
author
cfarmer
committedMay 13, 2010
now supports fields containing Cyrillics. Fixes #2566. Patch from alexbruy
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13477 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+9
-62
lines changed

1 file changed

+9
-62
lines changed
 

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

Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def __init__(self, iface):
4545
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
4646
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
4747
self.setWindowTitle(self.tr("Split vector layer"))
48+
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
4849
# populate layer list
4950
self.progressBar.setValue(0)
5051
mapCanvas = self.iface.mapCanvas()
@@ -59,6 +60,7 @@ def update(self, inputLayer):
5960
self.inField.addItem(unicode(changedField[i].name()))
6061

6162
def accept(self):
63+
self.buttonOk.setEnabled( False )
6264
if self.inShape.currentText() == "":
6365
QMessageBox.information(self, self.tr("Vector Split"), self.tr("No input shapefile specified"))
6466
elif self.outShape.text() == "":
@@ -77,78 +79,23 @@ def accept(self):
7779
self.progressBar.setValue(100)
7880
self.outShape.clear()
7981
QMessageBox.information(self, self.tr("Vector Split"), self.tr("Created output shapefiles in folder:\n%1").arg( outPath))
80-
self.progressBar.setValue(0)
82+
self.progressBar.setValue(0)
83+
self.buttonOk.setEnabled( True )
8184

8285
def outFile(self):
83-
fileDialog = QFileDialog()
84-
settings = QSettings()
85-
dirName = settings.value("/UI/lastShapefileDir").toString()
86-
fileDialog.setDirectory(dirName)
87-
encodingBox = QComboBox()
88-
l = QLabel("Encoding:",fileDialog)
89-
fileDialog.layout().addWidget(l)
90-
fileDialog.layout().addWidget(encodingBox)
91-
encodingBox.addItem("BIG5")
92-
encodingBox.addItem("BIG5-HKSCS")
93-
encodingBox.addItem("EUCJP")
94-
encodingBox.addItem("EUCKR")
95-
encodingBox.addItem("GB2312")
96-
encodingBox.addItem("GBK")
97-
encodingBox.addItem("GB18030")
98-
encodingBox.addItem("JIS7")
99-
encodingBox.addItem("SHIFT-JIS")
100-
encodingBox.addItem("TSCII")
101-
encodingBox.addItem("UTF-8")
102-
encodingBox.addItem("UTF-16")
103-
encodingBox.addItem("KOI8-R")
104-
encodingBox.addItem("KOI8-U")
105-
encodingBox.addItem("ISO8859-1")
106-
encodingBox.addItem("ISO8859-2")
107-
encodingBox.addItem("ISO8859-3")
108-
encodingBox.addItem("ISO8859-4")
109-
encodingBox.addItem("ISO8859-5")
110-
encodingBox.addItem("ISO8859-6")
111-
encodingBox.addItem("ISO8859-7")
112-
encodingBox.addItem("ISO8859-8")
113-
encodingBox.addItem("ISO8859-8-I")
114-
encodingBox.addItem("ISO8859-9")
115-
encodingBox.addItem("ISO8859-10")
116-
encodingBox.addItem("ISO8859-13")
117-
encodingBox.addItem("ISO8859-14")
118-
encodingBox.addItem("ISO8859-15")
119-
encodingBox.addItem("IBM 850")
120-
encodingBox.addItem("IBM 866")
121-
encodingBox.addItem("CP874")
122-
encodingBox.addItem("CP1250")
123-
encodingBox.addItem("CP1251")
124-
encodingBox.addItem("CP1252")
125-
encodingBox.addItem("CP1253")
126-
encodingBox.addItem("CP1254")
127-
encodingBox.addItem("CP1255")
128-
encodingBox.addItem("CP1256")
129-
encodingBox.addItem("CP1257")
130-
encodingBox.addItem("CP1258")
131-
encodingBox.addItem("Apple Roman")
132-
encodingBox.addItem("TIS-620")
133-
encodingBox.setItemText(encodingBox.currentIndex(), QString(QTextCodec.codecForLocale().name()))
134-
fileDialog.setAcceptMode(QFileDialog.AcceptSave)
135-
fileDialog.setFileMode(QFileDialog.DirectoryOnly)
136-
fileDialog.setConfirmOverwrite(False)
137-
if not fileDialog.exec_() == 1:
138-
return
139-
folders = fileDialog.selectedFiles()
140-
self.folderName = unicode(folders.first())
141-
self.encoding = unicode(encodingBox.currentText())
14286
self.outShape.clear()
143-
self.outShape.insert(self.folderName)
87+
( self.shapefileName, self.encoding ) = ftools_utils.saveDialog( self )
88+
if self.shapefileName is None or self.encoding is None:
89+
return
90+
self.outShape.setText( QString( self.shapefileName ) )
14491

14592
def split(self, vlayer, outPath, inField, progressBar):
14693
provider = vlayer.dataProvider()
14794
#unique = []
14895
index = provider.fieldNameIndex(inField)
14996
#provider.uniqueValues(index, unique)
15097
unique = ftools_utils.getUniqueValues(vlayer.dataProvider(), int(index))
151-
baseName = outPath + vlayer.name() + "_" + inField + "_"
98+
baseName = unicode( outPath + vlayer.name() + "_" + inField + "_" )
15299
allAttrs = provider.attributeIndexes()
153100
provider.select(allAttrs)
154101
fieldList = ftools_utils.getFieldList(vlayer)

0 commit comments

Comments
 (0)
Please sign in to comment.