+ self.setWindowTitle ("BiaCV - untitled")
+
+ # on window closing
+ def closeEvent (self, event):
+ if self.ismodified is True:
+ ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, lang.CONFIRM_DISCARD_SAVE,
+ PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
+ # ignore event if not confirmed
+ if ans <> PyQt4.QtGui.QMessageBox.Yes:
+ event.ignore ()
+
+ # on help about dialog box
+ def on_help_about (self):
+ PyQt4.QtGui.QMessageBox.about (self, lang.ABOUT_TITLE, lang.ABOUT_TEXT)
+
+ # on file exit
+ def on_exit (self):
+ # call the close event
+ self.close()
+
+ # on file export - export current document to any external format based on
+ # a template
+ def on_file_export (self):
+ # get the template directory
+ templatedir = PyQt4.QtGui.QFileDialog.getExistingDirectory (self,
+ lang.OPEN_TEMPLATE_TITLE)
+ if templatedir == "":
+ return
+
+ # get the output file path
+ outputfile = PyQt4.QtGui.QFileDialog.getSaveFileName (self,
+ lang.EXPORT_TITLE)
+
+ if outputfile == "":
+ return
+
+ # create a new exporter object
+ exp = exporter.BiaCVExporter ()
+
+ # set the document data
+ exp.set_data (self.get_document_data ().data)
+
+ # set the template directory
+ exp.set_template_directory (unicode (templatedir.toUtf8(), "utf-8"))
+
+ # set the output file
+ exp.set_output (unicode (outputfile.toUtf8(), "utf-8"))
+
+ # carry out the export function
+ exp.export ()
+
+ # function to open a file
+ def on_file_open (self):
+ # if modified, confirm
+ if self.ismodified is True:
+ ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, lang.CONFIRM_DISCARD_SAVE,
+ PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
+ # if no, then don't open the file
+ if ans <> PyQt4.QtGui.QMessageBox.Yes:
+ return
+
+ # open file dialog
+ openfilename = PyQt4.QtGui.QFileDialog.getOpenFileName (self, lang.OPEN_TITLE)
+ # if no open file name then return
+ if openfilename == "":
+ return
+
+ # load the document data from open file name
+ docdata = data.BiaCVData ()
+ docdata.load_data (openfilename)
+
+ # set the title
+ self.title.setText (docdata.data["title"])
+
+ # set the personal information fields from document data
+ self.set_personal_info (docdata)
+
+ # set the educational qualifications
+ self.set_educational_qualifications (docdata)
+
+ # set the professional history
+ self.set_professional_history (docdata)
+
+ # set the career objectives
+ self.set_career_objectives (docdata)
+
+ # set the skills list
+ self.set_skillsets_info (docdata)
+
+ # set the additional information
+ self.set_additional_info (docdata)
+
+ # set the current document
+ self.currentfile = openfilename
+ self.ismodified = False
+
+ # set the window title
+ self.setWindowTitle ("BiaCV - " + self.currentfile)
+
+ # function to save a file as a new document
+ def on_file_save_as (self):
+ savefilename = PyQt4.QtGui.QFileDialog.getSaveFileName (self,
+ lang.SAVE_TITLE)
+
+ # if save file name is not none
+ if savefilename <> "":
+ mydata = self.get_document_data ()
+ mydata.save_data (savefilename)
+ self.ismodified = False
+ self.currentfile = savefilename
+ self.setWindowTitle ("BiaCV - " + self.currentfile)
+
+ # function to save a file
+ def on_file_save (self):
+ # only save modified file
+ if self.ismodified is False:
+ return
+
+ # if no current file get file name from file save dialog
+ if self.currentfile is None:
+ savefilename = PyQt4.QtGui.QFileDialog.getSaveFileName (self,
+ lang.SAVE_TITLE)
+
+ if savefilename <> "":
+ mydata = self.get_document_data ()
+ mydata.save_data (savefilename)
+ self.ismodified = False
+ self.currentfile = savefilename
+ self.setWindowTitle ("BiaCV - " + self.currentfile)
+ else:
+ mydata = self.get_document_data ()
+ mydata.save_data (self.currentfile)
+ self.ismodified = False
+
+ # function to set document data from the GUI
+ def get_document_data (self):
+ docdata = data.BiaCVData ()
+
+ # set the document title
+ docdata.set_document_title (unicode (self.title.text ().toUtf8 (), "utf-8"))
+
+ # get the marital status string from check box
+ if self.married.isChecked ():
+ maritalstatus = True
+ elif self.single.isChecked ():
+ maritalstatus = False
+ else:
+ maritalstatus = None
+
+ docdata.set_personal_info (
+ 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 ().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.country.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
+ education = []
+ i = 0
+ while i < self.educationlist.topLevelItemCount ():
+ curitem = self.educationlist.topLevelItem (i)
+ curdict = {}
+ 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
+
+ # set the educational qualifications
+ docdata.set_educational_qualifications (education)
+
+ # get the list of professional history from the treewidget
+ professional = []
+ i = 0
+ while i < self.professionlist.topLevelItemCount ():
+ curitem = self.professionlist.topLevelItem (i)
+ curdict = {}
+ 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).toUtf8 (), "utf-8")
+ curdict["additionalinfo"] = unicode (curitem.text (4).toUtf8 (), "utf-8")
+ professional.append (curdict)
+ i += 1
+
+ # set the professional qualifications
+ docdata.set_professional_history (professional)
+
+ # set the career objectives
+ shorttermobjectives = unicode (self.shorttermcareer.toPlainText ().toUtf8 (), "utf-8").splitlines ()
+ longtermgoals = unicode (self.longtermgoals.toPlainText ().toUtf8 (), "utf-8").splitlines ()
+
+ docdata.set_career_objectives (shorttermobjectives, longtermgoals)
+
+ # set the skill sets
+ skills = []
+ i = 0
+ while i < self.skillslist.topLevelItemCount ():
+ curitem = self.skillslist.topLevelItem (i)
+ curdict = {}
+ 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
+ docdata.set_skillsets (skills)
+
+ # get the list of languages
+ langsknown = []
+ i = 0
+ while i < self.languageslist.topLevelItemCount ():
+ curitem = self.languageslist.topLevelItem (i)
+ curdict = {}
+ 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 ().toUtf8 (), "utf-8")
+
+ docdata.set_additional_information (langsknown, additionalinformation)
+
+ return docdata