f9e79b3d963d0e80828e780396f93bb1633188df
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 # get the output file path
49 outputfile
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
55 # create a new exporter object
56 exp
= exporter
.BiaCVExporter ()
58 # set the document data
59 exp
.set_data (self
.get_document_data ().data
)
61 # set the template directory
62 exp
.set_template_directory (unicode (templatedir
.toUtf8(), "utf-8"))
65 exp
.set_output (unicode (outputfile
.toUtf8(), "utf-8"))
67 # carry out the export function
70 # function to open a file
71 def on_file_open (self
):
72 # if modified, confirm
73 if self
.ismodified
is True:
74 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DISCARD_SAVE
,
75 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
76 # if no, then don't open the file
77 if ans
<> PyQt4
.QtGui
.QMessageBox
.Yes
:
81 openfilename
= PyQt4
.QtGui
.QFileDialog
.getOpenFileName (self
, lang
.OPEN_TITLE
)
82 # if no open file name then return
83 if openfilename
== "":
86 # load the document data from open file name
87 docdata
= data
.BiaCVData ()
88 docdata
.load_data (openfilename
)
91 self
.title
.setText (docdata
.data
["title"])
93 # set the personal information fields from document data
94 self
.set_personal_info (docdata
)
96 # set the profile highlights
97 self
.set_profile_highlights (docdata
)
99 # set the educational qualifications
100 self
.set_educational_qualifications (docdata
)
102 # set the professional history
103 self
.set_professional_history (docdata
)
105 # set the career objectives
106 self
.set_career_objectives (docdata
)
108 # set the skills list
109 self
.set_skillsets_info (docdata
)
111 # set the additional information
112 self
.set_additional_info (docdata
)
114 # set the current document
115 self
.currentfile
= openfilename
116 self
.ismodified
= False
118 # set the window title
119 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
121 # function to save a file as a new document
122 def on_file_save_as (self
):
123 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
126 # if save file name is not none
127 if savefilename
<> "":
128 mydata
= self
.get_document_data ()
129 mydata
.save_data (savefilename
)
130 self
.ismodified
= False
131 self
.currentfile
= savefilename
132 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
134 # function to save a file
135 def on_file_save (self
):
136 # only save modified file
137 if self
.ismodified
is False:
140 # if no current file get file name from file save dialog
141 if self
.currentfile
is None:
142 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
145 if savefilename
<> "":
146 mydata
= self
.get_document_data ()
147 mydata
.save_data (savefilename
)
148 self
.ismodified
= False
149 self
.currentfile
= savefilename
150 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
152 mydata
= self
.get_document_data ()
153 mydata
.save_data (self
.currentfile
)
154 self
.ismodified
= False
156 # function to set document data from the GUI
157 def get_document_data (self
):
158 docdata
= data
.BiaCVData ()
160 # set the document title
161 docdata
.set_document_title (unicode (self
.title
.text ().toUtf8 (), "utf-8"))
163 # get the marital status string from check box
164 if self
.married
.isChecked ():
166 elif self
.single
.isChecked ():
167 maritalstatus
= False
171 docdata
.set_personal_info (
172 unicode (self
.nametitle
.lineEdit ().text ().toUtf8 (), "utf-8"),
173 unicode (self
.firstname
.text ().toUtf8 (), "utf-8"),
174 unicode (self
.lastname
.text ().toUtf8 (), "utf-8"),
175 unicode (self
.dateofbirth
.date().toString ("dd MMM, yyyy"), "utf-8"),
176 unicode (self
.street
.text ().toUtf8 (), "utf-8"),
177 unicode (self
.area
.text ().toUtf8 (), "utf-8"),
178 unicode (self
.city
.text ().toUtf8 (), "utf-8"),
179 unicode (self
.areacode
.text ().toUtf8 (), "utf-8"),
180 unicode (self
.country
.text ().toUtf8 (), "utf-8"),
181 unicode (self
.countrycode_landline
.text ().toUtf8 (), "utf-8"),
182 unicode (self
.telephone
.text ().toUtf8 (), "utf-8"),
183 unicode (self
.countrycode_mobile
.text ().toUtf8 (), "utf-8"),
184 unicode (self
.mobilenumber
.text ().toUtf8 (), "utf-8"),
185 unicode (self
.email
.text ().toUtf8 (), "utf-8"),
189 # set the profile highlights
190 profile_highlights
= unicode (self
.profile
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
191 docdata
.set_profile (profile_highlights
)
193 # get the list of educational qualifications from the treewidget
196 while i
< self
.educationlist
.topLevelItemCount ():
197 curitem
= self
.educationlist
.topLevelItem (i
)
199 curdict
["degree"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
200 curdict
["graduation"] = unicode (curitem
.text (1).toUtf8 (), "utf-8")
201 curdict
["institution"] = unicode (curitem
.text (2).toUtf8 (), "utf-8")
202 curdict
["university"] = unicode (curitem
.text (3).toUtf8 (), "utf-8")
203 curdict
["grade"] = unicode (curitem
.text (4).toUtf8 (), "utf-8")
204 curdict
["percentage"] = float (curitem
.text (5))
205 education
.append (curdict
)
208 # set the educational qualifications
209 docdata
.set_educational_qualifications (education
)
211 # get the list of professional history from the treewidget
214 while i
< self
.professionlist
.topLevelItemCount ():
215 curitem
= self
.professionlist
.topLevelItem (i
)
217 curdict
["jobtitle"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
218 curdict
["joindate"] = unicode (curitem
.text (1), "utf-8")
219 curdict
["leavedate"] = unicode (curitem
.text (2), "utf-8")
220 curdict
["organization"] = unicode (curitem
.text (3).toUtf8 (), "utf-8")
221 curdict
["additionalinfo"] = unicode (curitem
.text (4).toUtf8 (), "utf-8")
222 professional
.append (curdict
)
225 # set the professional qualifications
226 docdata
.set_professional_history (professional
)
228 # set the career objectives
229 shorttermobjectives
= unicode (self
.shorttermcareer
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
230 longtermgoals
= unicode (self
.longtermgoals
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
232 docdata
.set_career_objectives (shorttermobjectives
, longtermgoals
)
237 while i
< self
.skillslist
.topLevelItemCount ():
238 curitem
= self
.skillslist
.topLevelItem (i
)
240 curdict
["skilltitle"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
241 curdict
["skilldesc"] = unicode (curitem
.text (1).toUtf8 (), "utf-8")
242 skills
.append (curdict
)
244 # set the list of skills
245 docdata
.set_skillsets (skills
)
247 # get the list of languages
250 while i
< self
.languageslist
.topLevelItemCount ():
251 curitem
= self
.languageslist
.topLevelItem (i
)
253 curdict
["language"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
254 curdict
["canspeak" ] = (curitem
.text (1) == "True")
255 curdict
["canreadwrite"] = (curitem
.text (2) == "True")
256 curdict
["isproficient"] = (curitem
.text (3) == "True")
257 langsknown
.append (curdict
)
260 additionalinformation
= unicode (self
.additionalinformation
.toPlainText ().toUtf8 (), "utf-8")
262 docdata
.set_additional_information (langsknown
, additionalinformation
)
266 # function to reset personal information data in the GUI
267 def reset_personal_info (self
):
268 self
.nametitle
.setEditText ("")
269 self
.firstname
.setText ("")
270 self
.lastname
.setText ("")
271 self
.dateofbirth
.setDate (PyQt4
.QtCore
.QDate (1970, 1, 1))
272 self
.street
.setText ("")
273 self
.area
.setText ("")
274 self
.city
.setText ("")
275 self
.countrycode_landline
.setText ("")
276 self
.telephone
.setText ("")
277 self
.countrycode_mobile
.setText ("")
278 self
.mobilenumber
.setText ("")
279 self
.email
.setText ("")
280 self
.areacode
.setText ("")
281 self
.unspecified
.setChecked (True)
282 self
.country
.setText ("")
284 # function to set the profile highlights in the GUI from document data
285 def set_profile_highlights (self
, docdata
):
286 self
.profile
.setPlainText (u
'\n'.join (docdata
.data
["profile"]))
288 # function to reset profile highlights data in GUI
289 def reset_profile_highlights (self
):
290 self
.profile
.setPlainText ("")
292 # function to set personal information data in the GUI from document data
293 def set_personal_info (self
, docdata
):
294 self
.nametitle
.setEditText (docdata
.data
["nametitle"])
295 self
.firstname
.setText (docdata
.data
["firstname"])
296 self
.lastname
.setText (docdata
.data
["lastname"])
297 self
.dateofbirth
.setDate (PyQt4
.QtCore
.QDate
.fromString (docdata
.data
["dateofbirth"], "dd MMM, yyyy"))
298 self
.street
.setText (docdata
.data
["street"])
299 self
.area
.setText (docdata
.data
["area"])
300 self
.city
.setText (docdata
.data
["city"])
301 self
.countrycode_landline
.setText (docdata
.data
["countrycode_landline"])
302 self
.telephone
.setText (docdata
.data
["landline"])
303 self
.countrycode_mobile
.setText (docdata
.data
["countrycode_mobile"])
304 self
.mobilenumber
.setText (docdata
.data
["mobile"])
305 self
.email
.setText (docdata
.data
["email"])
306 self
.areacode
.setText (docdata
.data
["areacode"])
307 self
.country
.setText (docdata
.data
["country"])
309 if docdata
.data
["maritalstatus"] is True:
310 self
.married
.setChecked (True)
311 elif docdata
.data
["maritalstatus"] is False:
312 self
.single
.setChecked (True)
314 self
.unspecified
.setChecked (True)
316 # function to clear professional history in the GUI
317 def reset_professional_history (self
):
318 self
.reset_profession_fields ()
319 self
.professionlist
.clear ()
321 # function to set the professional history in the GUI from the document data
322 def set_professional_history (self
, docdata
):
323 # reset the professional history
324 self
.reset_professional_history ()
326 # add the professional history items to list
327 for item
in docdata
.data
["professionalhistory"]:
328 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
333 item
["organization"],
334 item
["additionalinfo"]
337 self
.professionlist
.addTopLevelItem (professionitem
)
339 # function to clear educational qualifications in the GUI
340 def reset_educational_qualifications (self
):
341 self
.reset_education_fields ()
342 self
.educationlist
.clear ()
344 # function to set education qualifications in the GUI from document data
345 def set_educational_qualifications (self
, docdata
):
346 # reset the educational qualifications
347 self
.reset_educational_qualifications ()
349 # add education items to list
350 for item
in docdata
.data
["educationalqualifications"]:
351 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem (
358 str (item
["percentage"])
361 self
.educationlist
.addTopLevelItem (educationitem
)
363 # function to clear career objectives data in the GUI
364 def reset_career_objectives (self
):
365 self
.shorttermcareer
.setPlainText ("")
366 self
.longtermgoals
.setPlainText ("")
368 # function to set career objectives data in the GUI from document data
369 def set_career_objectives (self
, docdata
):
370 self
.shorttermcareer
.setPlainText (u
'\n'.join (docdata
.data
["shorttermobjectives"]))
371 self
.longtermgoals
.setPlainText (u
'\n'.join (docdata
.data
["longtermgoals"]))
373 # function to clear skill sets data in the GUI
374 def reset_skillsets_info (self
):
375 self
.reset_skillset_fields ()
376 self
.skillslist
.clear ()
378 # function to set the skill sets data in the GUI from document data
379 def set_skillsets_info (self
, docdata
):
380 # clear the skill sets information
381 self
.reset_skillsets_info ()
383 for item
in docdata
.data
["skillsets"]:
384 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
390 self
.skillslist
.addTopLevelItem (skillitem
)
393 # function to clear additional information data in the GUI
394 def reset_additional_info (self
):
395 self
.reset_language_fields ()
396 self
.languageslist
.clear ()
397 self
.additionalinformation
.setPlainText ("")
399 # function to set additional information data in the GUI from the document data
400 def set_additional_info (self
, docdata
):
401 # clear the additional information
402 self
.reset_additional_info ()
404 # set the languages list
405 for item
in docdata
.data
["languagesknown"]:
406 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
409 str (item
["canspeak"]),
410 str (item
["canreadwrite"]),
411 str (item
["isproficient"])
414 self
.languageslist
.addTopLevelItem (langitem
)
416 self
.additionalinformation
.setPlainText (docdata
.data
["additionalinformation"])
418 # function to clear all the fields and reset them to defaults
419 def new_document (self
):
420 # first clear the individual record fields in the tabs
421 self
.reset_language_fields ()
422 self
.reset_skillset_fields ()
424 # clear document data
425 self
.title
.setText ("")
427 self
.reset_personal_info ()
428 self
.reset_profile_highlights ()
429 self
.reset_professional_history ()
430 self
.reset_educational_qualifications ()
431 self
.reset_career_objectives ()
432 self
.reset_skillsets_info ()
433 self
.reset_additional_info ()
435 # set the page to first page
436 self
.pages
.setCurrentIndex (0)
438 # set current file to none and modified to false
439 self
.currentfile
= None
440 self
.ismodified
= False
442 # set the window title
443 self
.setWindowTitle ("BiaCV - untitled")
445 # file new action is triggered
446 def on_file_new (self
):
447 # if the previous document is modified
448 # as if it should be discarded
449 if self
.ismodified
is True:
450 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
,
451 lang
.CONFIRM_DISCARD_SAVE
,
452 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
453 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
455 # if not modified then simply create a new document
459 # when the document is modified
460 def on_document_modified (self
):
461 # set the document modified flag
462 self
.ismodified
= True
464 # update a language in the list of languages
465 def on_update_lang (self
):
466 # get the selected language
467 selitems
= self
.languageslist
.selectedItems ()
469 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
471 # check if the language string is not empty
472 if self
.language
.text () == "":
473 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
475 selitem
= selitems
[0]
476 selitem
.setText (0, self
.language
.text ())
477 selitem
.setText (1, str (self
.canspeak
.isChecked ()))
478 selitem
.setText (2, str (self
.canreadwrite
.isChecked ()))
479 selitem
.setText (3, str (self
.isproficient
.isChecked ()))
481 # modified the document
482 self
.ismodified
= True
484 # selecting a language from the list of languages
485 def on_select_lang (self
):
486 # set the language fields from the selected item
487 self
.set_language_fields ()
489 # delete a language from the list of languages known
490 def on_delete_lang (self
):
491 # get selected language
492 selitems
= self
.languageslist
.selectedItems ()
494 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_REQ_MISSING
)
497 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
498 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
499 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
500 for item
in selitems
:
501 self
.languageslist
.takeTopLevelItem (self
.languageslist
.indexOfTopLevelItem (item
))
503 self
.reset_language_fields ()
504 # set the modified flag
505 self
.ismodified
= True
507 # add a language to the list of languages known
508 def on_add_lang (self
):
509 # check if the language is set
510 if self
.language
.text () == "":
511 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
513 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
515 self
.language
.text (),
516 str (self
.canspeak
.isChecked ()),
517 str (self
.canreadwrite
.isChecked ()),
518 str (self
.isproficient
.isChecked ())
521 self
.languageslist
.addTopLevelItem (langitem
)
522 self
.reset_language_fields ()
524 # set the modified flag
525 self
.ismodified
= True
527 # set the language fields from the selected item
528 def set_language_fields (self
):
529 selitems
= self
.languageslist
.selectedItems ()
532 selitem
= selitems
[0]
533 self
.language
.setText (selitem
.text (0))
534 self
.canspeak
.setChecked (selitem
.text (1) == "True")
535 self
.canreadwrite
.setChecked (selitem
.text(2) == "True")
536 self
.isproficient
.setChecked (selitem
.text(3) == "True")
538 # reset the language fields
539 def reset_language_fields (self
):
540 self
.language
.setText ("")
541 self
.canspeak
.setChecked (True)
542 self
.canreadwrite
.setChecked (False)
543 self
.isproficient
.setChecked (False)
545 # update the skill set button event
546 def on_update_skill (self
):
547 # get the selected item
548 selitems
= self
.skillslist
.selectedItems ()
550 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
552 if self
.skillsettitle
.text () == "":
553 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
555 selitem
= selitems
[0]
557 selitem
.setText (0, self
.skillsettitle
.text ())
558 selitem
.setText (1, self
.skilldescription
.toPlainText ())
559 # set the modified flag
560 self
.ismodified
= True
562 # selecting a skill from the list event
563 def on_select_skill (self
):
564 self
.set_skill_fields ()
566 # set the skill fields from the selected skill from the list
567 def set_skill_fields (self
):
568 # get the selected items
569 selitems
= self
.skillslist
.selectedItems ()
572 selitem
= selitems
[0]
573 self
.skillsettitle
.setText (selitem
.text (0))
574 self
.skilldescription
.setPlainText (selitem
.text (1))
576 # delete skill set button is clicked
577 def on_delete_skill (self
):
578 # get the selected items
579 selitems
= self
.skillslist
.selectedItems ()
581 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
584 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
585 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
587 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
588 for item
in selitems
:
589 self
.skillslist
.takeTopLevelItem (self
.skillslist
.indexOfTopLevelItem (item
))
591 self
.reset_skillset_fields ()
592 # set the modified flag
593 self
.ismodified
= True
595 # add skill set button is clicked
596 def on_add_skill (self
):
597 # if the skill title is blank
598 if self
.skillsettitle
.text () == "":
599 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
601 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
603 self
.skillsettitle
.text (),
604 self
.skilldescription
.toPlainText ()
607 self
.skillslist
.addTopLevelItem (skillitem
)
608 self
.reset_skillset_fields ()
609 # set the modified flag
610 self
.ismodified
= True
612 # clear the skill set fields
613 def reset_skillset_fields (self
):
614 self
.skillsettitle
.setText ("")
615 self
.skilldescription
.setPlainText ("")
617 # update professional history button is clicked
618 def on_update_profession (self
):
619 # get the selected item
620 selitems
= self
.professionlist
.selectedItems ()
622 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
624 selitem
= selitems
[0]
625 # if designation is not set
626 if self
.designation
.text () == "":
627 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
629 # if currently employed in that position, leaving date is to be disabled
631 if self
.currentemployment
.isChecked ():
634 # if the leaving date is < join date
635 if self
.leavedate
.date () < self
.joindate
.date ():
636 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_DATE
)
638 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
640 selitem
.setText (0, self
.designation
.text ())
641 selitem
.setText (1, self
.joindate
.date ().toString ("dd MMM, yyyy"))
642 selitem
.setText (2, leavedatestr
)
643 selitem
.setText (3, self
.organization
.text ())
644 selitem
.setText (4, self
.additionalinfo
.text ())
645 # set the modified flag
646 self
.ismodified
= True
648 # delete professional history button is clicked
649 def on_delete_profession (self
):
650 # get the selected items
651 selitems
= self
.professionlist
.selectedItems ()
653 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
656 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
657 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
659 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
660 for item
in selitems
:
661 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
662 self
.reset_profession_fields ()
663 # set the modified flag
664 self
.ismodified
= True
666 # add professional history button is clicked
667 def on_add_profession (self
):
668 if self
.designation
.text () == "":
669 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
671 # if currently employed in that position, leaving date is to be disabled
673 if self
.currentemployment
.isChecked ():
676 # if the leaving date is < join date
677 if self
.leavedate
.date () < self
.joindate
.date ():
678 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_DATE
)
680 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
682 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
684 self
.designation
.text (),
685 self
.joindate
.date ().toString ("dd MMM, yyyy"),
687 self
.organization
.text (),
688 self
.additionalinfo
.text ()
692 self
.professionlist
.addTopLevelItem (professionitem
)
694 self
.reset_profession_fields ()
695 # set the modified flag
696 self
.ismodified
= True
698 # when selection of profession list is changed
699 def on_select_profession (self
):
700 self
.set_profession_fields ()
702 # set the profession fields from the selected item in profession list
703 def set_profession_fields (self
):
704 selitems
= self
.professionlist
.selectedItems ()
707 selitem
= selitems
[0]
708 self
.designation
.setText (selitem
.text (0))
709 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
710 if selitem
.text (2) == "":
711 self
.leavedate
.setEnabled (False)
712 self
.currentemployment
.setChecked (True)
714 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
715 self
.leavedate
.setEnabled (True)
716 self
.currentemployment
.setChecked (False)
718 self
.organization
.setText (selitem
.text (3))
719 self
.additionalinfo
.setText (selitem
.text (4))
721 def reset_profession_fields (self
):
722 self
.designation
.setText ("")
723 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
724 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
725 self
.currentemployment
.setChecked (False)
726 self
.organization
.setText ("")
727 self
.additionalinfo
.setText ("")
729 # current employment check box is changed
730 def on_change_currentemployment (self
, val
):
732 self
.leavedate
.setEnabled (False)
734 self
.leavedate
.setEnabled (True)
736 # delete educational qualification
737 def on_delete_education (self
):
738 # get the selected items in the education list
739 selitems
= self
.educationlist
.selectedItems ()
740 # if no items are selected
742 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
743 # delete the items after confirmation
745 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
746 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
747 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
748 # remove the item selected
749 for item
in selitems
:
750 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
751 self
.reset_education_fields ()
752 # set the modified flag
753 self
.ismodified
= True
755 # selection is changed
756 def on_select_education (self
):
757 self
.set_education_fields ()
759 # update educational qualification button
760 def on_update_education (self
):
761 selitems
= self
.educationlist
.selectedItems ()
762 # if no item is selected
764 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
766 # if the qualification title is not set
767 if self
.degree_name
.text () == "":
768 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
770 selitem
= selitems
[0]
772 selitem
.setText (0, self
.degree_name
.text ())
773 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
774 selitem
.setText (2, self
.institution
.text ())
775 selitem
.setText (3, self
.university
.text ())
776 selitem
.setText (4, self
.grade
.text ())
777 selitem
.setText (5, str (self
.percentage
.value ()))
778 # set the modified flag
779 self
.ismodified
= True
781 # add educational qualification button
782 def on_add_education (self
):
783 # check if the qualification title is set
784 if self
.degree_name
.text () == "":
785 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
787 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
788 self
.degree_name
.text (),
789 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
790 self
.institution
.text (),
791 self
.university
.text (),
793 str (self
.percentage
.value ())
795 self
.educationlist
.addTopLevelItem (educationitem
)
797 self
.reset_education_fields ()
798 # set the modified flag
799 self
.ismodified
= True
801 # set fields in the education tab from current selected item
802 def set_education_fields (self
):
803 selitems
= self
.educationlist
.selectedItems ()
806 selitem
= selitems
[0]
807 # set the fields to the data in the selected item in the list
808 self
.degree_name
.setText (selitem
.text (0))
809 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
810 self
.institution
.setText (selitem
.text (2))
811 self
.university
.setText (selitem
.text (3))
812 self
.grade
.setText (selitem
.text(4))
813 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
815 # reset fields in the education tab
816 def reset_education_fields (self
):
817 self
.degree_name
.setText ("")
818 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
819 self
.institution
.setText ("")
820 self
.university
.setText ("")
821 self
.grade
.setText ("")
822 self
.percentage
.setValue (50.0)