[QGIS Commit] r14670 - trunk/qgis/python/plugins/fTools/tools

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Nov 14 17:49:46 EST 2010


Author: cfarmer
Date: 2010-11-14 14:49:46 -0800 (Sun, 14 Nov 2010)
New Revision: 14670

Modified:
   trunk/qgis/python/plugins/fTools/tools/doJoinAttributes.py
   trunk/qgis/python/plugins/fTools/tools/frmJoinAttributes.ui
Log:
adds option to specify encoding for input tables. addresses #2628

Modified: trunk/qgis/python/plugins/fTools/tools/doJoinAttributes.py
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/doJoinAttributes.py	2010-11-14 22:49:08 UTC (rev 14669)
+++ trunk/qgis/python/plugins/fTools/tools/doJoinAttributes.py	2010-11-14 22:49:46 UTC (rev 14670)
@@ -52,12 +52,20 @@
     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 @@
         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 @@
       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 @@
       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 @@
       joinPath = joinInfo.absoluteFilePath()
       joinName = joinInfo.completeBaseName()
       layer2 = QgsVectorLayer(joinPath, joinName, 'ogr')
+      layer2.setProviderEncoding(encoding)
       useTable = False
     else:
       layer2 = ftools_utils.getVectorLayerByName(joinName)

Modified: trunk/qgis/python/plugins/fTools/tools/frmJoinAttributes.ui
===================================================================
--- trunk/qgis/python/plugins/fTools/tools/frmJoinAttributes.ui	2010-11-14 22:49:08 UTC (rev 14669)
+++ trunk/qgis/python/plugins/fTools/tools/frmJoinAttributes.ui	2010-11-14 22:49:46 UTC (rev 14670)
@@ -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>



More information about the QGIS-commit mailing list