2 # class for main window
7 import biacv_mainwindow_ui
as bui
8 import biacv_lang
as lang
9 import biacv_data
as data
10 import biacv_exporter
as exporter
12 class Biacv_mainwindow (PyQt4
.QtGui
.QMainWindow
, bui
.Ui_biacv_mainwindow
):
14 PyQt4
.QtGui
.QMainWindow
.__init
__ (self
)
17 self
.currentfile
= None
18 self
.ismodified
= False
19 self
.setWindowTitle ("BiaCV - untitled")
22 def closeEvent (self
, event
):
23 if self
.ismodified
is True:
24 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DISCARD_SAVE
,
25 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
26 # ignore event if not confirmed
27 if ans
<> PyQt4
.QtGui
.QMessageBox
.Yes
:
30 # on help about dialog box
31 def on_help_about (self
):
32 PyQt4
.QtGui
.QMessageBox
.about (self
, lang
.ABOUT_TITLE
, lang
.ABOUT_TEXT
)
36 # call the close event
39 # on file export - export current document to any external format based on
41 def on_file_export (self
):
42 # get the template directory
43 templatedir
= PyQt4
.QtGui
.QFileDialog
.getExistingDirectory (self
,
44 lang
.OPEN_TEMPLATE_TITLE
)
48 # create a new exporter object
49 exp
= exporter
.BiaCVExporter ()
51 # set the document data
52 exp
.set_data (self
.get_document_data ().data
)
54 # set the template directory
55 exp
.set_template_directory (unicode (templatedir
.toUtf8(), "utf-8"))
57 # get the output file path
58 outputfile
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
59 exp
.exporter_name
, filter=exp
.export_filter
)
66 exp
.set_output (unicode (outputfile
.toUtf8(), "utf-8"))
68 # carry out the export function
71 # function to open a file
72 def on_file_open (self
):
73 # if modified, confirm
74 if self
.ismodified
is True:
75 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DISCARD_SAVE
,
76 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
77 # if no, then don't open the file
78 if ans
<> PyQt4
.QtGui
.QMessageBox
.Yes
:
82 openfilename
= PyQt4
.QtGui
.QFileDialog
.getOpenFileName (self
, lang
.OPEN_TITLE
,
83 filter = lang
.BIACV_FILE_FILTER
)
84 # if no open file name then return
85 if openfilename
== "":
88 # load the document data from open file name
89 docdata
= data
.BiaCVData ()
90 docdata
.load_data (openfilename
)
93 self
.title
.setText (docdata
.data
["title"])
95 # set the personal information fields from document data
96 self
.set_personal_info (docdata
)
98 # set the profile highlights
99 self
.set_profile_highlights (docdata
)
101 # set the educational qualifications
102 self
.set_educational_qualifications (docdata
)
104 # set the professional history
105 self
.set_professional_history (docdata
)
107 # set the career objectives
108 self
.set_career_objectives (docdata
)
110 # set the skills list
111 self
.set_skillsets_info (docdata
)
113 # set the additional information
114 self
.set_additional_info (docdata
)
116 # set the current document
117 self
.currentfile
= openfilename
118 self
.ismodified
= False
120 # set the window title
121 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
123 # function to save a file as a new document
124 def on_file_save_as (self
):
125 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
126 lang
.SAVE_TITLE
, filter=lang
.BIACV_FILE_FILTER
)
128 # if save file name is not none
129 if savefilename
<> "":
130 mydata
= self
.get_document_data ()
131 mydata
.save_data (savefilename
)
132 self
.ismodified
= False
133 self
.currentfile
= savefilename
134 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
136 # function to save a file
137 def on_file_save (self
):
138 # only save modified file
139 if self
.ismodified
is False:
142 # if no current file get file name from file save dialog
143 if self
.currentfile
is None:
144 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
145 lang
.SAVE_TITLE
, filter=lang
.BIACV_FILE_FILTER
)
147 if savefilename
<> "":
148 mydata
= self
.get_document_data ()
149 mydata
.save_data (savefilename
)
150 self
.ismodified
= False
151 self
.currentfile
= savefilename
152 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
154 mydata
= self
.get_document_data ()
155 mydata
.save_data (self
.currentfile
)
156 self
.ismodified
= False
158 # function to set document data from the GUI
159 def get_document_data (self
):
160 docdata
= data
.BiaCVData ()
162 # set the document title
163 docdata
.set_document_title (unicode (self
.title
.text ().toUtf8 (), "utf-8"))
165 # get the marital status string from check box
166 if self
.married
.isChecked ():
168 elif self
.single
.isChecked ():
169 maritalstatus
= False
173 docdata
.set_personal_info (
174 unicode (self
.nametitle
.lineEdit ().text ().toUtf8 (), "utf-8"),
175 unicode (self
.firstname
.text ().toUtf8 (), "utf-8"),
176 unicode (self
.lastname
.text ().toUtf8 (), "utf-8"),
177 unicode (self
.dateofbirth
.date().toString ("dd MMM, yyyy"), "utf-8"),
178 unicode (self
.street
.text ().toUtf8 (), "utf-8"),
179 unicode (self
.area
.text ().toUtf8 (), "utf-8"),
180 unicode (self
.city
.text ().toUtf8 (), "utf-8"),
181 unicode (self
.areacode
.text ().toUtf8 (), "utf-8"),
182 unicode (self
.country
.text ().toUtf8 (), "utf-8"),
183 unicode (self
.countrycode_landline
.text ().toUtf8 (), "utf-8"),
184 unicode (self
.telephone
.text ().toUtf8 (), "utf-8"),
185 unicode (self
.countrycode_mobile
.text ().toUtf8 (), "utf-8"),
186 unicode (self
.mobilenumber
.text ().toUtf8 (), "utf-8"),
187 unicode (self
.email
.text ().toUtf8 (), "utf-8"),
191 # set the profile highlights
192 profile_highlights
= unicode (self
.profile
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
193 docdata
.set_profile (profile_highlights
)
195 # get the list of educational qualifications from the treewidget
198 while i
< self
.educationlist
.topLevelItemCount ():
199 curitem
= self
.educationlist
.topLevelItem (i
)
201 curdict
["degree"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
202 curdict
["graduation"] = unicode (curitem
.text (1).toUtf8 (), "utf-8")
203 curdict
["institution"] = unicode (curitem
.text (2).toUtf8 (), "utf-8")
204 curdict
["university"] = unicode (curitem
.text (3).toUtf8 (), "utf-8")
205 curdict
["grade"] = unicode (curitem
.text (4).toUtf8 (), "utf-8")
206 curdict
["percentage"] = float (curitem
.text (5))
207 education
.append (curdict
)
210 # set the educational qualifications
211 docdata
.set_educational_qualifications (education
)
213 # get the list of professional history from the treewidget
216 while i
< self
.professionlist
.topLevelItemCount ():
217 curitem
= self
.professionlist
.topLevelItem (i
)
219 curdict
["jobtitle"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
220 curdict
["joindate"] = unicode (curitem
.text (1), "utf-8")
221 curdict
["leavedate"] = unicode (curitem
.text (2), "utf-8")
222 curdict
["organization"] = unicode (curitem
.text (3).toUtf8 (), "utf-8")
223 curdict
["additionalinfo"] = unicode (curitem
.text (4).toUtf8 (), "utf-8")
224 professional
.append (curdict
)
227 # set the professional qualifications
228 docdata
.set_professional_history (professional
)
230 # set the career objectives
231 shorttermobjectives
= unicode (self
.shorttermcareer
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
232 longtermgoals
= unicode (self
.longtermgoals
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
234 docdata
.set_career_objectives (shorttermobjectives
, longtermgoals
)
239 while i
< self
.skillslist
.topLevelItemCount ():
240 curitem
= self
.skillslist
.topLevelItem (i
)
242 curdict
["skilltitle"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
243 curdict
["skilldesc"] = unicode (curitem
.text (1).toUtf8 (), "utf-8")
244 skills
.append (curdict
)
246 # set the list of skills
247 docdata
.set_skillsets (skills
)
249 # get the list of languages
252 while i
< self
.languageslist
.topLevelItemCount ():
253 curitem
= self
.languageslist
.topLevelItem (i
)
255 curdict
["language"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
256 curdict
["canspeak" ] = (curitem
.text (1) == "True")
257 curdict
["canreadwrite"] = (curitem
.text (2) == "True")
258 curdict
["isproficient"] = (curitem
.text (3) == "True")
259 langsknown
.append (curdict
)
262 additionalinformation
= unicode (self
.additionalinformation
.toPlainText ().toUtf8 (), "utf-8")
264 docdata
.set_additional_information (langsknown
, additionalinformation
)
268 # function to reset personal information data in the GUI
269 def reset_personal_info (self
):
270 self
.nametitle
.setEditText ("")
271 self
.firstname
.setText ("")
272 self
.lastname
.setText ("")
273 self
.dateofbirth
.setDate (PyQt4
.QtCore
.QDate (1970, 1, 1))
274 self
.street
.setText ("")
275 self
.area
.setText ("")
276 self
.city
.setText ("")
277 self
.countrycode_landline
.setText ("")
278 self
.telephone
.setText ("")
279 self
.countrycode_mobile
.setText ("")
280 self
.mobilenumber
.setText ("")
281 self
.email
.setText ("")
282 self
.areacode
.setText ("")
283 self
.unspecified
.setChecked (True)
284 self
.country
.setText ("")
286 # function to set the profile highlights in the GUI from document data
287 def set_profile_highlights (self
, docdata
):
288 self
.profile
.setPlainText (u
'\n'.join (docdata
.data
["profile"]))
290 # function to reset profile highlights data in GUI
291 def reset_profile_highlights (self
):
292 self
.profile
.setPlainText ("")
294 # function to set personal information data in the GUI from document data
295 def set_personal_info (self
, docdata
):
296 self
.nametitle
.setEditText (docdata
.data
["nametitle"])
297 self
.firstname
.setText (docdata
.data
["firstname"])
298 self
.lastname
.setText (docdata
.data
["lastname"])
299 self
.dateofbirth
.setDate (PyQt4
.QtCore
.QDate
.fromString (docdata
.data
["dateofbirth"], "dd MMM, yyyy"))
300 self
.street
.setText (docdata
.data
["street"])
301 self
.area
.setText (docdata
.data
["area"])
302 self
.city
.setText (docdata
.data
["city"])
303 self
.countrycode_landline
.setText (docdata
.data
["countrycode_landline"])
304 self
.telephone
.setText (docdata
.data
["landline"])
305 self
.countrycode_mobile
.setText (docdata
.data
["countrycode_mobile"])
306 self
.mobilenumber
.setText (docdata
.data
["mobile"])
307 self
.email
.setText (docdata
.data
["email"])
308 self
.areacode
.setText (docdata
.data
["areacode"])
309 self
.country
.setText (docdata
.data
["country"])
311 if docdata
.data
["maritalstatus"] is True:
312 self
.married
.setChecked (True)
313 elif docdata
.data
["maritalstatus"] is False:
314 self
.single
.setChecked (True)
316 self
.unspecified
.setChecked (True)
318 # function to clear professional history in the GUI
319 def reset_professional_history (self
):
320 self
.reset_profession_fields ()
321 self
.professionlist
.clear ()
323 # function to set the professional history in the GUI from the document data
324 def set_professional_history (self
, docdata
):
325 # reset the professional history
326 self
.reset_professional_history ()
328 # add the professional history items to list
329 for item
in docdata
.data
["professionalhistory"]:
330 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
335 item
["organization"],
336 item
["additionalinfo"]
339 self
.professionlist
.addTopLevelItem (professionitem
)
341 # function to clear educational qualifications in the GUI
342 def reset_educational_qualifications (self
):
343 self
.reset_education_fields ()
344 self
.educationlist
.clear ()
346 # function to set education qualifications in the GUI from document data
347 def set_educational_qualifications (self
, docdata
):
348 # reset the educational qualifications
349 self
.reset_educational_qualifications ()
351 # add education items to list
352 for item
in docdata
.data
["educationalqualifications"]:
353 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem (
360 str (item
["percentage"])
363 self
.educationlist
.addTopLevelItem (educationitem
)
365 # function to clear career objectives data in the GUI
366 def reset_career_objectives (self
):
367 self
.shorttermcareer
.setPlainText ("")
368 self
.longtermgoals
.setPlainText ("")
370 # function to set career objectives data in the GUI from document data
371 def set_career_objectives (self
, docdata
):
372 self
.shorttermcareer
.setPlainText (u
'\n'.join (docdata
.data
["shorttermobjectives"]))
373 self
.longtermgoals
.setPlainText (u
'\n'.join (docdata
.data
["longtermgoals"]))
375 # function to clear skill sets data in the GUI
376 def reset_skillsets_info (self
):
377 self
.reset_skillset_fields ()
378 self
.skillslist
.clear ()
380 # function to set the skill sets data in the GUI from document data
381 def set_skillsets_info (self
, docdata
):
382 # clear the skill sets information
383 self
.reset_skillsets_info ()
385 for item
in docdata
.data
["skillsets"]:
386 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
392 self
.skillslist
.addTopLevelItem (skillitem
)
395 # function to clear additional information data in the GUI
396 def reset_additional_info (self
):
397 self
.reset_language_fields ()
398 self
.languageslist
.clear ()
399 self
.additionalinformation
.setPlainText ("")
401 # function to set additional information data in the GUI from the document data
402 def set_additional_info (self
, docdata
):
403 # clear the additional information
404 self
.reset_additional_info ()
406 # set the languages list
407 for item
in docdata
.data
["languagesknown"]:
408 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
411 str (item
["canspeak"]),
412 str (item
["canreadwrite"]),
413 str (item
["isproficient"])
416 self
.languageslist
.addTopLevelItem (langitem
)
418 self
.additionalinformation
.setPlainText (docdata
.data
["additionalinformation"])
420 # function to clear all the fields and reset them to defaults
421 def new_document (self
):
422 # first clear the individual record fields in the tabs
423 self
.reset_language_fields ()
424 self
.reset_skillset_fields ()
426 # clear document data
427 self
.title
.setText ("")
429 self
.reset_personal_info ()
430 self
.reset_profile_highlights ()
431 self
.reset_professional_history ()
432 self
.reset_educational_qualifications ()
433 self
.reset_career_objectives ()
434 self
.reset_skillsets_info ()
435 self
.reset_additional_info ()
437 # set the page to first page
438 self
.pages
.setCurrentIndex (0)
440 # set current file to none and modified to false
441 self
.currentfile
= None
442 self
.ismodified
= False
444 # set the window title
445 self
.setWindowTitle ("BiaCV - untitled")
447 # file new action is triggered
448 def on_file_new (self
):
449 # if the previous document is modified
450 # as if it should be discarded
451 if self
.ismodified
is True:
452 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
,
453 lang
.CONFIRM_DISCARD_SAVE
,
454 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
455 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
457 # if not modified then simply create a new document
461 # when the document is modified
462 def on_document_modified (self
):
463 # set the document modified flag
464 self
.ismodified
= True
466 # update a language in the list of languages
467 def on_update_lang (self
):
468 # get the selected language
469 selitems
= self
.languageslist
.selectedItems ()
471 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
473 # check if the language string is not empty
474 if self
.language
.text () == "":
475 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
477 selitem
= selitems
[0]
478 selitem
.setText (0, self
.language
.text ())
479 selitem
.setText (1, str (self
.canspeak
.isChecked ()))
480 selitem
.setText (2, str (self
.canreadwrite
.isChecked ()))
481 selitem
.setText (3, str (self
.isproficient
.isChecked ()))
483 # modified the document
484 self
.ismodified
= True
486 # selecting a language from the list of languages
487 def on_select_lang (self
):
488 # set the language fields from the selected item
489 self
.set_language_fields ()
491 # delete a language from the list of languages known
492 def on_delete_lang (self
):
493 # get selected language
494 selitems
= self
.languageslist
.selectedItems ()
496 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_REQ_MISSING
)
499 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
500 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
501 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
502 for item
in selitems
:
503 self
.languageslist
.takeTopLevelItem (self
.languageslist
.indexOfTopLevelItem (item
))
505 self
.reset_language_fields ()
506 # set the modified flag
507 self
.ismodified
= True
509 # add a language to the list of languages known
510 def on_add_lang (self
):
511 # check if the language is set
512 if self
.language
.text () == "":
513 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
515 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
517 self
.language
.text (),
518 str (self
.canspeak
.isChecked ()),
519 str (self
.canreadwrite
.isChecked ()),
520 str (self
.isproficient
.isChecked ())
523 self
.languageslist
.addTopLevelItem (langitem
)
524 self
.reset_language_fields ()
526 # set the modified flag
527 self
.ismodified
= True
529 # set the language fields from the selected item
530 def set_language_fields (self
):
531 selitems
= self
.languageslist
.selectedItems ()
534 selitem
= selitems
[0]
535 self
.language
.setText (selitem
.text (0))
536 self
.canspeak
.setChecked (selitem
.text (1) == "True")
537 self
.canreadwrite
.setChecked (selitem
.text(2) == "True")
538 self
.isproficient
.setChecked (selitem
.text(3) == "True")
540 # reset the language fields
541 def reset_language_fields (self
):
542 self
.language
.setText ("")
543 self
.canspeak
.setChecked (True)
544 self
.canreadwrite
.setChecked (False)
545 self
.isproficient
.setChecked (False)
547 # update the skill set button event
548 def on_update_skill (self
):
549 # get the selected item
550 selitems
= self
.skillslist
.selectedItems ()
552 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
554 if self
.skillsettitle
.text () == "":
555 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
557 selitem
= selitems
[0]
559 selitem
.setText (0, self
.skillsettitle
.text ())
560 selitem
.setText (1, self
.skilldescription
.toPlainText ())
561 # set the modified flag
562 self
.ismodified
= True
564 # selecting a skill from the list event
565 def on_select_skill (self
):
566 self
.set_skill_fields ()
568 # set the skill fields from the selected skill from the list
569 def set_skill_fields (self
):
570 # get the selected items
571 selitems
= self
.skillslist
.selectedItems ()
574 selitem
= selitems
[0]
575 self
.skillsettitle
.setText (selitem
.text (0))
576 self
.skilldescription
.setPlainText (selitem
.text (1))
578 # delete skill set button is clicked
579 def on_delete_skill (self
):
580 # get the selected items
581 selitems
= self
.skillslist
.selectedItems ()
583 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
586 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
587 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
589 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
590 for item
in selitems
:
591 self
.skillslist
.takeTopLevelItem (self
.skillslist
.indexOfTopLevelItem (item
))
593 self
.reset_skillset_fields ()
594 # set the modified flag
595 self
.ismodified
= True
597 # add skill set button is clicked
598 def on_add_skill (self
):
599 # if the skill title is blank
600 if self
.skillsettitle
.text () == "":
601 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
603 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
605 self
.skillsettitle
.text (),
606 self
.skilldescription
.toPlainText ()
609 self
.skillslist
.addTopLevelItem (skillitem
)
610 self
.reset_skillset_fields ()
611 # set the modified flag
612 self
.ismodified
= True
614 # clear the skill set fields
615 def reset_skillset_fields (self
):
616 self
.skillsettitle
.setText ("")
617 self
.skilldescription
.setPlainText ("")
619 # update professional history button is clicked
620 def on_update_profession (self
):
621 # get the selected item
622 selitems
= self
.professionlist
.selectedItems ()
624 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
626 selitem
= selitems
[0]
627 # if designation is not set
628 if self
.designation
.text () == "":
629 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
631 # if currently employed in that position, leaving date is to be disabled
633 if self
.currentemployment
.isChecked ():
636 # if the leaving date is < join date
637 if self
.leavedate
.date () < self
.joindate
.date ():
638 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_DATE
)
640 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
642 selitem
.setText (0, self
.designation
.text ())
643 selitem
.setText (1, self
.joindate
.date ().toString ("dd MMM, yyyy"))
644 selitem
.setText (2, leavedatestr
)
645 selitem
.setText (3, self
.organization
.text ())
646 selitem
.setText (4, self
.additionalinfo
.text ())
647 # set the modified flag
648 self
.ismodified
= True
650 # delete professional history button is clicked
651 def on_delete_profession (self
):
652 # get the selected items
653 selitems
= self
.professionlist
.selectedItems ()
655 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
658 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
659 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
661 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
662 for item
in selitems
:
663 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
664 self
.reset_profession_fields ()
665 # set the modified flag
666 self
.ismodified
= True
668 # add professional history button is clicked
669 def on_add_profession (self
):
670 if self
.designation
.text () == "":
671 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
673 # if currently employed in that position, leaving date is to be disabled
675 if self
.currentemployment
.isChecked ():
678 # if the leaving date is < join date
679 if self
.leavedate
.date () < self
.joindate
.date ():
680 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_DATE
)
682 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
684 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
686 self
.designation
.text (),
687 self
.joindate
.date ().toString ("dd MMM, yyyy"),
689 self
.organization
.text (),
690 self
.additionalinfo
.text ()
694 self
.professionlist
.addTopLevelItem (professionitem
)
696 self
.reset_profession_fields ()
697 # set the modified flag
698 self
.ismodified
= True
700 # when selection of profession list is changed
701 def on_select_profession (self
):
702 self
.set_profession_fields ()
704 # set the profession fields from the selected item in profession list
705 def set_profession_fields (self
):
706 selitems
= self
.professionlist
.selectedItems ()
709 selitem
= selitems
[0]
710 self
.designation
.setText (selitem
.text (0))
711 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
712 if selitem
.text (2) == "":
713 self
.leavedate
.setEnabled (False)
714 self
.currentemployment
.setChecked (True)
716 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
717 self
.leavedate
.setEnabled (True)
718 self
.currentemployment
.setChecked (False)
720 self
.organization
.setText (selitem
.text (3))
721 self
.additionalinfo
.setText (selitem
.text (4))
723 def reset_profession_fields (self
):
724 self
.designation
.setText ("")
725 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
726 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
727 self
.currentemployment
.setChecked (False)
728 self
.organization
.setText ("")
729 self
.additionalinfo
.setText ("")
731 # current employment check box is changed
732 def on_change_currentemployment (self
, val
):
734 self
.leavedate
.setEnabled (False)
736 self
.leavedate
.setEnabled (True)
738 # delete educational qualification
739 def on_delete_education (self
):
740 # get the selected items in the education list
741 selitems
= self
.educationlist
.selectedItems ()
742 # if no items are selected
744 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
745 # delete the items after confirmation
747 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
748 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
749 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
750 # remove the item selected
751 for item
in selitems
:
752 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
753 self
.reset_education_fields ()
754 # set the modified flag
755 self
.ismodified
= True
757 # selection is changed
758 def on_select_education (self
):
759 self
.set_education_fields ()
761 # update educational qualification button
762 def on_update_education (self
):
763 selitems
= self
.educationlist
.selectedItems ()
764 # if no item is selected
766 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
768 # if the qualification title is not set
769 if self
.degree_name
.text () == "":
770 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
772 selitem
= selitems
[0]
774 selitem
.setText (0, self
.degree_name
.text ())
775 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
776 selitem
.setText (2, self
.institution
.text ())
777 selitem
.setText (3, self
.university
.text ())
778 selitem
.setText (4, self
.grade
.text ())
779 selitem
.setText (5, str (self
.percentage
.value ()))
780 # set the modified flag
781 self
.ismodified
= True
783 # add educational qualification button
784 def on_add_education (self
):
785 # check if the qualification title is set
786 if self
.degree_name
.text () == "":
787 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
789 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
790 self
.degree_name
.text (),
791 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
792 self
.institution
.text (),
793 self
.university
.text (),
795 str (self
.percentage
.value ())
797 self
.educationlist
.addTopLevelItem (educationitem
)
799 self
.reset_education_fields ()
800 # set the modified flag
801 self
.ismodified
= True
803 # set fields in the education tab from current selected item
804 def set_education_fields (self
):
805 selitems
= self
.educationlist
.selectedItems ()
808 selitem
= selitems
[0]
809 # set the fields to the data in the selected item in the list
810 self
.degree_name
.setText (selitem
.text (0))
811 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
812 self
.institution
.setText (selitem
.text (2))
813 self
.university
.setText (selitem
.text (3))
814 self
.grade
.setText (selitem
.text(4))
815 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
817 # reset fields in the education tab
818 def reset_education_fields (self
):
819 self
.degree_name
.setText ("")
820 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
821 self
.institution
.setText ("")
822 self
.university
.setText ("")
823 self
.grade
.setText ("")
824 self
.percentage
.setValue (50.0)