Save UTF-8 support added
authorHarishankar <v.harishankar@gmail.com>
Mon, 5 Dec 2011 13:44:47 +0000 (19:14 +0530)
committerHarishankar <v.harishankar@gmail.com>
Mon, 5 Dec 2011 13:44:47 +0000 (19:14 +0530)
Added support for UTF-8 to saved file so that it is possible
to save resume/CV in other languages

biacv_mainwindow.py

index 192ef4c..cdb1305 100644 (file)
@@ -24,10 +24,12 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                        self.currentfile = PyQt4.QtGui.QFileDialog.getSaveFileName (self,
                                lang.SAVE_TITLE)
 
-                       if self.currentfile is not None:
+                       if self.currentfile <> "":
                                mydata = self.get_document_data ()
                                mydata.save_data (self.currentfile)
                                self.ismodified = False
+                       else:
+                               self.currentfile = None
                else:
                        mydata = self.get_document_data ()
                        mydata.save_data (self.currentfile)
@@ -38,7 +40,7 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                docdata = data.BiaCVData ()
 
                # set the document title
-               docdata.set_document_title (unicode (self.title.text (), "utf-8"))
+               docdata.set_document_title (unicode (self.title.text ().toUtf8 (), "utf-8"))
 
                # get the marital status string from check box
                if self.married.isChecked ():
@@ -49,19 +51,19 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                        maritalstatus = None
 
                docdata.set_personal_info (
-                               unicode (self.nametitle.lineEdit ().text (), "utf-8"),
-                               unicode (self.firstname.text (), "utf-8"),
-                               unicode (self.lastname.text (), "utf-8"),
+                               unicode (self.nametitle.lineEdit ().text ().toUtf8 (), "utf-8"),
+                               unicode (self.firstname.text ().toUtf8 (), "utf-8"),
+                               unicode (self.lastname.text ().toUtf8 (), "utf-8"),
                                unicode (self.dateofbirth.date().toString ("dd MMM, yyyy"), "utf-8"),
-                               unicode (self.street.text (), "utf-8"),
-                               unicode (self.area.text (), "utf-8"),
-                               unicode (self.city.text (), "utf-8"),
-                               unicode (self.areacode.text (), "utf-8"),
-                               unicode (self.countrycode_landline.text (), "utf-8"),
-                               unicode (self.telephone.text (), "utf-8"),
-                               unicode (self.countrycode_mobile.text (), "utf-8"),
-                               unicode (self.mobilenumber.text (), "utf-8"),
-                               unicode (self.email.text (), "utf-8"),
+                               unicode (self.street.text ().toUtf8 (), "utf-8"),
+                               unicode (self.area.text ().toUtf8 (), "utf-8"),
+                               unicode (self.city.text ().toUtf8 (), "utf-8"),
+                               unicode (self.areacode.text ().toUtf8 (), "utf-8"),
+                               unicode (self.countrycode_landline.text ().toUtf8 (), "utf-8"),
+                               unicode (self.telephone.text ().toUtf8 (), "utf-8"),
+                               unicode (self.countrycode_mobile.text ().toUtf8 (), "utf-8"),
+                               unicode (self.mobilenumber.text ().toUtf8 (), "utf-8"),
+                               unicode (self.email.text ().toUtf8 (), "utf-8"),
                                maritalstatus
                        )
                # get the list of educational qualifications from the treewidget
@@ -70,11 +72,11 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                while i < self.educationlist.topLevelItemCount ():
                        curitem = self.educationlist.topLevelItem (i)
                        curdict = {}
-                       curdict["degree"] = unicode (curitem.text (0), "utf-8")
-                       curdict["graduation"] = unicode (curitem.text (1), "utf-8")
-                       curdict["institution"] = unicode (curitem.text (2), "utf-8")
-                       curdict["university"] = unicode (curitem.text (3), "utf-8")
-                       curdict["grade"] = unicode (curitem.text (4), "utf-8")
+                       curdict["degree"] = unicode (curitem.text (0).toUtf8 (), "utf-8")
+                       curdict["graduation"] = unicode (curitem.text (1).toUtf8 (), "utf-8")
+                       curdict["institution"] = unicode (curitem.text (2).toUtf8 (), "utf-8")
+                       curdict["university"] = unicode (curitem.text (3).toUtf8 (), "utf-8")
+                       curdict["grade"] = unicode (curitem.text (4).toUtf8 (), "utf-8")
                        curdict["percentage"] = float (curitem.text (5))
                        education.append (curdict)
                        i += 1
@@ -88,11 +90,11 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                while i < self.professionlist.topLevelItemCount ():
                        curitem = self.professionlist.topLevelItem (i)
                        curdict = {}
-                       curdict["jobtitle"] = unicode (curitem.text (0), "utf-8")
+                       curdict["jobtitle"] = unicode (curitem.text (0).toUtf8 (), "utf-8")
                        curdict["joindate"] = unicode (curitem.text (1), "utf-8")
                        curdict["leavedate"] = unicode (curitem.text (2), "utf-8")
-                       curdict["organization"] = unicode (curitem.text (3), "utf-8")
-                       curdict["additionalinfo"] = unicode (curitem.text (4), "utf-8")
+                       curdict["organization"] = unicode (curitem.text (3).toUtf8 (), "utf-8")
+                       curdict["additionalinfo"] = unicode (curitem.text (4).toUtf8 (), "utf-8")
                        professional.append (curdict)
                        i += 1
 
@@ -100,8 +102,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                docdata.set_professional_history (professional)
 
                # set the career objectives
-               shorttermobjectives = unicode (self.shorttermcareer.toPlainText (), "utf-8").splitlines ()
-               longtermgoals = unicode (self.longtermgoals.toPlainText (), "utf-8").splitlines ()
+               shorttermobjectives = unicode (self.shorttermcareer.toPlainText ().toUtf8 (), "utf-8").splitlines ()
+               longtermgoals = unicode (self.longtermgoals.toPlainText ().toUtf8 (), "utf-8").splitlines ()
 
                docdata.set_career_objectives (shorttermobjectives, longtermgoals)
 
@@ -111,8 +113,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                while i < self.skillslist.topLevelItemCount ():
                        curitem = self.skillslist.topLevelItem (i)
                        curdict = {}
-                       curdict["skilltitle"] = unicode (curitem.text (0), "utf-8")
-                       curdict["skilldesc"] = unicode (curitem.text (1), "utf-8")
+                       curdict["skilltitle"] = unicode (curitem.text (0).toUtf8 (), "utf-8")
+                       curdict["skilldesc"] = unicode (curitem.text (1).toUtf8 (), "utf-8")
                        skills.append (curdict)
                        i += 1
                # set the list of skills
@@ -124,14 +126,14 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                while i < self.languageslist.topLevelItemCount ():
                        curitem = self.languageslist.topLevelItem (i)
                        curdict = {}
-                       curdict["language"] = unicode (curitem.text (0), "utf-8")
+                       curdict["language"] = unicode (curitem.text (0).toUtf8 (), "utf-8")
                        curdict["canspeak" ] = (curitem.text (1) == "True")
                        curdict["canreadwrite"] = (curitem.text (2) == "True")
                        curdict["isproficient"] = (curitem.text (3) == "True")
                        langsknown.append (curdict)
                        i += 1
 
-               additionalinformation = unicode (self.additionalinformation.toPlainText (), "utf-8")
+               additionalinformation = unicode (self.additionalinformation.toPlainText ().toUtf8 (), "utf-8")
 
                docdata.set_additional_information (langsknown, additionalinformation)