Skip to content
Permalink
Browse files

adds option to specify encoding for input tables. addresses #2628

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14670 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer
cfarmer committed Nov 14, 2010
1 parent 7c4b7e8 commit 8e5a782c819605f9cd962ff59b6e1d5b692882bc
Showing with 33 additions and 4 deletions.
  1. +17 −2 python/plugins/fTools/tools/doJoinAttributes.py
  2. +16 −2 python/plugins/fTools/tools/frmJoinAttributes.ui
@@ -52,12 +52,20 @@ def __init__(self, iface):
QObject.connect(self.toolTable, SIGNAL("clicked()"), self.inFile)
QObject.connect(self.rdoTable, SIGNAL("clicked()"), self.updateTableFields)
QObject.connect(self.rdoVector, SIGNAL("clicked()"), self.jupdate)
QObject.connect(self.cmbEncoding, SIGNAL("currentIndexChanged(QString)"),
self.updateTableFields)
self.setWindowTitle( self.tr("Join attributes") )
self.buttonOk = self.buttonBox_2.button( QDialogButtonBox.Ok )
# populate layer list
self.progressBar.setValue(0)
mapCanvas = self.iface.mapCanvas()
layers = ftools_utils.getLayerNames([QGis.Point, QGis.Line, QGis.Polygon])
encodings = QgsVectorDataProvider.availableEncodings()
self.cmbEncoding.addItems(encodings)
id = encodings.indexOf(QSettings().value( "/UI/encoding", "System").toString())
if id < 0:
id = len(encodings)-1
self.cmbEncoding.setCurrentIndex(id)
self.inShape.addItems(layers)
self.joinShape.addItems(layers)

@@ -103,7 +111,10 @@ def accept(self):
useTable = True
joinField = self.joinField.currentText()
outPath = self.outShape.text()
res = self.compute(inName, inField, joinName, joinField, outPath, keep, useTable, self.progressBar)
encoding = self.cmbEncoding.currentText()
QSettings().setValue( "/UI/encoding", encoding)
res = self.compute(inName, inField, joinName, joinField,
outPath, keep, useTable, encoding, self.progressBar)
self.outShape.clear()
if res:
addToTOC = QMessageBox.question(self, self.tr("Join Attributes"),
@@ -146,6 +157,8 @@ def updateTableFields(self):
joinName = joinInfo.completeBaseName()
self.joinField.clear()
changedLayer = QgsVectorLayer(joinPath, joinName, 'ogr')
encoding = self.cmbEncoding.currentText()
changedLayer.setProviderEncoding(encoding)
try:
changedField = ftools_utils.getFieldList(changedLayer)
except:
@@ -154,7 +167,8 @@ def updateTableFields(self):
for i in changedField:
self.joinField.addItem(unicode(changedField[i].name()))

def compute(self, inName, inField, joinName, joinField, outName, keep, useTable, progressBar):
def compute(self, inName, inField, joinName, joinField, outName,
keep, useTable, encoding, progressBar):
layer1 = ftools_utils.getVectorLayerByName(inName)
provider1 = layer1.dataProvider()
allAttrs = provider1.attributeIndexes()
@@ -166,6 +180,7 @@ def compute(self, inName, inField, joinName, joinField, outName, keep, useTable,
joinPath = joinInfo.absoluteFilePath()
joinName = joinInfo.completeBaseName()
layer2 = QgsVectorLayer(joinPath, joinName, 'ogr')
layer2.setProviderEncoding(encoding)
useTable = False
else:
layer2 = ftools_utils.getVectorLayerByName(joinName)
@@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>417</width>
<width>431</width>
<height>562</height>
</rect>
</property>
@@ -53,7 +53,7 @@
<property name="title">
<string>Join data</string>
</property>
<layout class="QGridLayout">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QVBoxLayout">
<item>
@@ -120,6 +120,20 @@
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labEncoding">
<property name="text">
<string>Encoding</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cmbEncoding"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>

0 comments on commit 8e5a782

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