0ceebde6c327263447e164553d32f2d8e161993b
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
)
16 self
.currentfile
= None
17 self
.ismodified
= False
18 self
.setWindowTitle ("BiaCV - untitled")
21 def closeEvent (self
, event
):
22 if self
.ismodified
is True:
23 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DISCARD_SAVE
,
24 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
25 # ignore event if not confirmed
26 if ans
<> PyQt4
.QtGui
.QMessageBox
.Yes
:
29 # on help about dialog box
30 def on_help_about (self
):
31 PyQt4
.QtGui
.QMessageBox
.about (self
, lang
.ABOUT_TITLE
, lang
.ABOUT_TEXT
)
35 # call the close event
38 # on file export - export current document to any external format based on
40 def on_file_export (self
):
41 # get the template directory
42 templatedir
= PyQt4
.QtGui
.QFileDialog
.getExistingDirectory (self
,
43 lang
.OPEN_TEMPLATE_TITLE
)
47 # get the output file path
48 outputfile
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
54 # create a new exporter object
55 exp
= exporter
.BiaCVExporter ()
57 # set the document data
58 exp
.set_data (self
.get_document_data ().data
)
60 # set the template directory
61 exp
.set_template_directory (unicode (templatedir
.toUtf8(), "utf-8"))
64 exp
.set_output (unicode (outputfile
.toUtf8(), "utf-8"))
66 # carry out the export function
69 # function to open a file
70 def on_file_open (self
):
71 # if modified, confirm
72 if self
.ismodified
is True:
73 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DISCARD_SAVE
,
74 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
75 # if no, then don't open the file
76 if ans
<> PyQt4
.QtGui
.QMessageBox
.Yes
:
80 openfilename
= PyQt4
.QtGui
.QFileDialog
.getOpenFileName (self
, lang
.OPEN_TITLE
)
81 # if no open file name then return
82 if openfilename
== "":
85 # load the document data from open file name
86 docdata
= data
.BiaCVData ()
87 docdata
.load_data (openfilename
)
90 self
.title
.setText (docdata
.data
["title"])
92 # set the personal information fields from document data
93 self
.set_personal_info (docdata
)
95 # set the educational qualifications
96 self
.set_educational_qualifications (docdata
)
98 # set the professional history
99 self
.set_professional_history (docdata
)
101 # set the career objectives
102 self
.set_career_objectives (docdata
)
104 # set the skills list
105 self
.set_skillsets_info (docdata
)
107 # set the additional information
108 self
.set_additional_info (docdata
)
110 # set the current document
111 self
.currentfile
= openfilename
112 self
.ismodified
= False
114 # set the window title
115 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
117 # function to save a file as a new document
118 def on_file_save_as (self
):
119 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
122 # if save file name is not none
123 if savefilename
<> "":
124 mydata
= self
.get_document_data ()
125 mydata
.save_data (savefilename
)
126 self
.ismodified
= False
127 self
.currentfile
= savefilename
128 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
130 # function to save a file
131 def on_file_save (self
):
132 # only save modified file
133 if self
.ismodified
is False:
136 # if no current file get file name from file save dialog
137 if self
.currentfile
is None:
138 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
141 if savefilename
<> "":
142 mydata
= self
.get_document_data ()
143 mydata
.save_data (savefilename
)
144 self
.ismodified
= False
145 self
.currentfile
= savefilename
146 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
148 mydata
= self
.get_document_data ()
149 mydata
.save_data (self
.currentfile
)
150 self
.ismodified
= False
152 # function to set document data from the GUI
153 def get_document_data (self
):
154 docdata
= data
.BiaCVData ()
156 # set the document title
157 docdata
.set_document_title (unicode (self
.title
.text ().toUtf8 (), "utf-8"))
159 # get the marital status string from check box
160 if self
.married
.isChecked ():
162 elif self
.single
.isChecked ():
163 maritalstatus
= False
167 docdata
.set_personal_info (
168 unicode (self
.nametitle
.lineEdit ().text ().toUtf8 (), "utf-8"),
169 unicode (self
.firstname
.text ().toUtf8 (), "utf-8"),
170 unicode (self
.lastname
.text ().toUtf8 (), "utf-8"),
171 unicode (self
.dateofbirth
.date().toString ("dd MMM, yyyy"), "utf-8"),
172 unicode (self
.street
.text ().toUtf8 (), "utf-8"),
173 unicode (self
.area
.text ().toUtf8 (), "utf-8"),
174 unicode (self
.city
.text ().toUtf8 (), "utf-8"),
175 unicode (self
.areacode
.text ().toUtf8 (), "utf-8"),
176 unicode (self
.countrycode_landline
.text ().toUtf8 (), "utf-8"),
177 unicode (self
.telephone
.text ().toUtf8 (), "utf-8"),
178 unicode (self
.countrycode_mobile
.text ().toUtf8 (), "utf-8"),
179 unicode (self
.mobilenumber
.text ().toUtf8 (), "utf-8"),
180 unicode (self
.email
.text ().toUtf8 (), "utf-8"),
183 # get the list of educational qualifications from the treewidget
186 while i
< self
.educationlist
.topLevelItemCount ():
187 curitem
= self
.educationlist
.topLevelItem (i
)
189 curdict
["degree"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
190 curdict
["graduation"] = unicode (curitem
.text (1).toUtf8 (), "utf-8")
191 curdict
["institution"] = unicode (curitem
.text (2).toUtf8 (), "utf-8")
192 curdict
["university"] = unicode (curitem
.text (3).toUtf8 (), "utf-8")
193 curdict
["grade"] = unicode (curitem
.text (4).toUtf8 (), "utf-8")
194 curdict
["percentage"] = float (curitem
.text (5))
195 education
.append (curdict
)
198 # set the educational qualifications
199 docdata
.set_educational_qualifications (education
)
201 # get the list of professional history from the treewidget
204 while i
< self
.professionlist
.topLevelItemCount ():
205 curitem
= self
.professionlist
.topLevelItem (i
)
207 curdict
["jobtitle"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
208 curdict
["joindate"] = unicode (curitem
.text (1), "utf-8")
209 curdict
["leavedate"] = unicode (curitem
.text (2), "utf-8")
210 curdict
["organization"] = unicode (curitem
.text (3).toUtf8 (), "utf-8")
211 curdict
["additionalinfo"] = unicode (curitem
.text (4).toUtf8 (), "utf-8")
212 professional
.append (curdict
)
215 # set the professional qualifications
216 docdata
.set_professional_history (professional
)
218 # set the career objectives
219 shorttermobjectives
= unicode (self
.shorttermcareer
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
220 longtermgoals
= unicode (self
.longtermgoals
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
222 docdata
.set_career_objectives (shorttermobjectives
, longtermgoals
)
227 while i
< self
.skillslist
.topLevelItemCount ():
228 curitem
= self
.skillslist
.topLevelItem (i
)
230 curdict
["skilltitle"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
231 curdict
["skilldesc"] = unicode (curitem
.text (1).toUtf8 (), "utf-8")
232 skills
.append (curdict
)
234 # set the list of skills
235 docdata
.set_skillsets (skills
)
237 # get the list of languages
240 while i
< self
.languageslist
.topLevelItemCount ():
241 curitem
= self
.languageslist
.topLevelItem (i
)
243 curdict
["language"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
244 curdict
["canspeak" ] = (curitem
.text (1) == "True")
245 curdict
["canreadwrite"] = (curitem
.text (2) == "True")
246 curdict
["isproficient"] = (curitem
.text (3) == "True")
247 langsknown
.append (curdict
)
250 additionalinformation
= unicode (self
.additionalinformation
.toPlainText ().toUtf8 (), "utf-8")
252 docdata
.set_additional_information (langsknown
, additionalinformation
)
256 # function to reset personal information data in the GUI
257 def reset_personal_info (self
):
258 self
.nametitle
.setEditText ("")
259 self
.firstname
.setText ("")
260 self
.lastname
.setText ("")
261 self
.dateofbirth
.setDate (PyQt4
.QtCore
.QDate (1970, 1, 1))
262 self
.street
.setText ("")
263 self
.area
.setText ("")
264 self
.city
.setText ("")
265 self
.countrycode_landline
.setText ("")
266 self
.telephone
.setText ("")
267 self
.countrycode_mobile
.setText ("")
268 self
.mobilenumber
.setText ("")
269 self
.email
.setText ("")
270 self
.areacode
.setText ("")
271 self
.unspecified
.setChecked (True)
273 # function to set personal information data in the GUI from document data
274 def set_personal_info (self
, docdata
):
275 self
.nametitle
.setEditText (docdata
.data
["nametitle"])
276 self
.firstname
.setText (docdata
.data
["firstname"])
277 self
.lastname
.setText (docdata
.data
["lastname"])
278 self
.dateofbirth
.setDate (PyQt4
.QtCore
.QDate
.fromString (docdata
.data
["dateofbirth"], "dd MMM, yyyy"))
279 self
.street
.setText (docdata
.data
["street"])
280 self
.area
.setText (docdata
.data
["area"])
281 self
.city
.setText (docdata
.data
["city"])
282 self
.countrycode_landline
.setText (docdata
.data
["countrycode_landline"])
283 self
.telephone
.setText (docdata
.data
["landline"])
284 self
.countrycode_mobile
.setText (docdata
.data
["countrycode_mobile"])
285 self
.mobilenumber
.setText (docdata
.data
["mobile"])
286 self
.email
.setText (docdata
.data
["email"])
287 self
.areacode
.setText (docdata
.data
["areacode"])
288 if docdata
.data
["maritalstatus"] is True:
289 self
.married
.setChecked (True)
290 elif docdata
.data
["maritalstatus"] is False:
291 self
.single
.setChecked (True)
293 self
.unspecified
.setChecked (True)
295 # function to clear professional history in the GUI
296 def reset_professional_history (self
):
297 self
.reset_profession_fields ()
298 self
.professionlist
.clear ()
300 # function to set the professional history in the GUI from the document data
301 def set_professional_history (self
, docdata
):
302 # reset the professional history
303 self
.reset_professional_history ()
305 # add the professional history items to list
306 for item
in docdata
.data
["professionalhistory"]:
307 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
312 item
["organization"],
313 item
["additionalinfo"]
316 self
.professionlist
.addTopLevelItem (professionitem
)
318 # function to clear educational qualifications in the GUI
319 def reset_educational_qualifications (self
):
320 self
.reset_education_fields ()
321 self
.educationlist
.clear ()
323 # function to set education qualifications in the GUI from document data
324 def set_educational_qualifications (self
, docdata
):
325 # reset the educational qualifications
326 self
.reset_educational_qualifications ()
328 # add education items to list
329 for item
in docdata
.data
["educationalqualifications"]:
330 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem (
337 str (item
["percentage"])
340 self
.educationlist
.addTopLevelItem (educationitem
)
342 # function to clear career objectives data in the GUI
343 def reset_career_objectives (self
):
344 self
.shorttermcareer
.setPlainText ("")
345 self
.longtermgoals
.setPlainText ("")
347 # function to set career objectives data in the GUI from document data
348 def set_career_objectives (self
, docdata
):
349 self
.shorttermcareer
.setPlainText (u
'\n'.join (docdata
.data
["shorttermobjectives"]))
350 self
.longtermgoals
.setPlainText (u
'\n'.join (docdata
.data
["longtermgoals"]))
352 # function to clear skill sets data in the GUI
353 def reset_skillsets_info (self
):
354 self
.reset_skillset_fields ()
355 self
.skillslist
.clear ()
357 # function to set the skill sets data in the GUI from document data
358 def set_skillsets_info (self
, docdata
):
359 # clear the skill sets information
360 self
.reset_skillsets_info ()
362 for item
in docdata
.data
["skillsets"]:
363 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
369 self
.skillslist
.addTopLevelItem (skillitem
)
372 # function to clear additional information data in the GUI
373 def reset_additional_info (self
):
374 self
.reset_language_fields ()
375 self
.languageslist
.clear ()
376 self
.additionalinformation
.setPlainText ("")
378 # function to set additional information data in the GUI from the document data
379 def set_additional_info (self
, docdata
):
380 # clear the additional information
381 self
.reset_additional_info ()
383 # set the languages list
384 for item
in docdata
.data
["languagesknown"]:
385 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
388 str (item
["canspeak"]),
389 str (item
["canreadwrite"]),
390 str (item
["isproficient"])
393 self
.languageslist
.addTopLevelItem (langitem
)
395 self
.additionalinformation
.setPlainText (docdata
.data
["additionalinformation"])
397 # function to clear all the fields and reset them to defaults
398 def new_document (self
):
399 # first clear the individual record fields in the tabs
400 self
.reset_language_fields ()
401 self
.reset_skillset_fields ()
403 # clear document data
404 self
.title
.setText ("")
406 self
.reset_personal_info ()
407 self
.reset_professional_history ()
408 self
.reset_educational_qualifications ()
409 self
.reset_career_objectives ()
410 self
.reset_skillsets_info ()
411 self
.reset_additional_info ()
413 # set the page to first page
414 self
.pages
.setCurrentIndex (0)
416 # set current file to none and modified to false
417 self
.currentfile
= None
418 self
.ismodified
= False
420 # set the window title
421 self
.setWindowTitle ("BiaCV - untitled")
423 # file new action is triggered
424 def on_file_new (self
):
425 # if the previous document is modified
426 # as if it should be discarded
427 if self
.ismodified
is True:
428 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
,
429 lang
.CONFIRM_DISCARD_SAVE
,
430 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
431 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
433 # if not modified then simply create a new document
437 # when the document is modified
438 def on_document_modified (self
):
439 # set the document modified flag
440 self
.ismodified
= True
442 # update a language in the list of languages
443 def on_update_lang (self
):
444 # get the selected language
445 selitems
= self
.languageslist
.selectedItems ()
447 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
449 # check if the language string is not empty
450 if self
.language
.text () == "":
451 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
453 selitem
= selitems
[0]
454 selitem
.setText (0, self
.language
.text ())
455 selitem
.setText (1, str (self
.canspeak
.isChecked ()))
456 selitem
.setText (2, str (self
.canreadwrite
.isChecked ()))
457 selitem
.setText (3, str (self
.isproficient
.isChecked ()))
459 # modified the document
460 self
.ismodified
= True
462 # selecting a language from the list of languages
463 def on_select_lang (self
):
464 # set the language fields from the selected item
465 self
.set_language_fields ()
467 # delete a language from the list of languages known
468 def on_delete_lang (self
):
469 # get selected language
470 selitems
= self
.languageslist
.selectedItems ()
472 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_REQ_MISSING
)
475 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
476 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
477 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
478 for item
in selitems
:
479 self
.languageslist
.takeTopLevelItem (self
.languageslist
.indexOfTopLevelItem (item
))
481 self
.reset_language_fields ()
482 # set the modified flag
483 self
.ismodified
= True
485 # add a language to the list of languages known
486 def on_add_lang (self
):
487 # check if the language is set
488 if self
.language
.text () == "":
489 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
491 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
493 self
.language
.text (),
494 str (self
.canspeak
.isChecked ()),
495 str (self
.canreadwrite
.isChecked ()),
496 str (self
.isproficient
.isChecked ())
499 self
.languageslist
.addTopLevelItem (langitem
)
500 self
.reset_language_fields ()
502 # set the modified flag
503 self
.ismodified
= True
505 # set the language fields from the selected item
506 def set_language_fields (self
):
507 selitems
= self
.languageslist
.selectedItems ()
510 selitem
= selitems
[0]
511 self
.language
.setText (selitem
.text (0))
512 self
.canspeak
.setChecked (selitem
.text (1) == "True")
513 self
.canreadwrite
.setChecked (selitem
.text(2) == "True")
514 self
.isproficient
.setChecked (selitem
.text(3) == "True")
516 # reset the language fields
517 def reset_language_fields (self
):
518 self
.language
.setText ("")
519 self
.canspeak
.setChecked (True)
520 self
.canreadwrite
.setChecked (False)
521 self
.isproficient
.setChecked (False)
523 # update the skill set button event
524 def on_update_skill (self
):
525 # get the selected item
526 selitems
= self
.skillslist
.selectedItems ()
528 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
530 if self
.skillsettitle
.text () == "":
531 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
533 selitem
= selitems
[0]
535 selitem
.setText (0, self
.skillsettitle
.text ())
536 selitem
.setText (1, self
.skilldescription
.toPlainText ())
537 # set the modified flag
538 self
.ismodified
= True
540 # selecting a skill from the list event
541 def on_select_skill (self
):
542 self
.set_skill_fields ()
544 # set the skill fields from the selected skill from the list
545 def set_skill_fields (self
):
546 # get the selected items
547 selitems
= self
.skillslist
.selectedItems ()
550 selitem
= selitems
[0]
551 self
.skillsettitle
.setText (selitem
.text (0))
552 self
.skilldescription
.setPlainText (selitem
.text (1))
554 # delete skill set button is clicked
555 def on_delete_skill (self
):
556 # get the selected items
557 selitems
= self
.skillslist
.selectedItems ()
559 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
562 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
563 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
565 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
566 for item
in selitems
:
567 self
.skillslist
.takeTopLevelItem (self
.skillslist
.indexOfTopLevelItem (item
))
569 self
.reset_skillset_fields ()
570 # set the modified flag
571 self
.ismodified
= True
573 # add skill set button is clicked
574 def on_add_skill (self
):
575 # if the skill title is blank
576 if self
.skillsettitle
.text () == "":
577 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
579 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
581 self
.skillsettitle
.text (),
582 self
.skilldescription
.toPlainText ()
585 self
.skillslist
.addTopLevelItem (skillitem
)
586 self
.reset_skillset_fields ()
587 # set the modified flag
588 self
.ismodified
= True
590 # clear the skill set fields
591 def reset_skillset_fields (self
):
592 self
.skillsettitle
.setText ("")
593 self
.skilldescription
.setPlainText ("")
595 # update professional history button is clicked
596 def on_update_profession (self
):
597 # get the selected item
598 selitems
= self
.professionlist
.selectedItems ()
600 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
602 selitem
= selitems
[0]
603 # if designation is not set
604 if self
.designation
.text () == "":
605 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
607 # if currently employed in that position, leaving date is to be disabled
608 # and set to "current"
609 if self
.currentemployment
.isChecked ():
610 leavedatestr
= "current"
612 # if the leaving date is < join date
613 if self
.leavedate
.date () < self
.joindate
.date ():
614 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_DATE
)
616 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
618 selitem
.setText (0, self
.designation
.text ())
619 selitem
.setText (1, self
.joindate
.date ().toString ("dd MMM, yyyy"))
620 selitem
.setText (2, leavedatestr
)
621 selitem
.setText (3, self
.organization
.text ())
622 selitem
.setText (4, self
.additionalinfo
.text ())
623 # set the modified flag
624 self
.ismodified
= True
626 # delete professional history button is clicked
627 def on_delete_profession (self
):
628 # get the selected items
629 selitems
= self
.professionlist
.selectedItems ()
631 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
634 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
635 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
637 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
638 for item
in selitems
:
639 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
640 self
.reset_profession_fields ()
641 # set the modified flag
642 self
.ismodified
= True
644 # add professional history button is clicked
645 def on_add_profession (self
):
646 if self
.designation
.text () == "":
647 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
649 # if currently employed in that position, leaving date is to be disabled
650 # and set to "current"
651 if self
.currentemployment
.isChecked ():
652 leavedatestr
= "current"
654 # if the leaving date is < join date
655 if self
.leavedate
.date () < self
.joindate
.date ():
656 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_DATE
)
658 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
660 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
662 self
.designation
.text (),
663 self
.joindate
.date ().toString ("dd MMM, yyyy"),
665 self
.organization
.text (),
666 self
.additionalinfo
.text ()
670 self
.professionlist
.addTopLevelItem (professionitem
)
672 self
.reset_profession_fields ()
673 # set the modified flag
674 self
.ismodified
= True
676 # when selection of profession list is changed
677 def on_select_profession (self
):
678 self
.set_profession_fields ()
680 # set the profession fields from the selected item in profession list
681 def set_profession_fields (self
):
682 selitems
= self
.professionlist
.selectedItems ()
685 selitem
= selitems
[0]
686 self
.designation
.setText (selitem
.text (0))
687 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
688 if selitem
.text (2) == "current":
689 self
.leavedate
.setEnabled (False)
690 self
.currentemployment
.setChecked (True)
692 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
693 self
.leavedate
.setEnabled (True)
694 self
.currentemployment
.setChecked (False)
696 self
.organization
.setText (selitem
.text (3))
697 self
.additionalinfo
.setText (selitem
.text (4))
699 def reset_profession_fields (self
):
700 self
.designation
.setText ("")
701 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
702 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
703 self
.currentemployment
.setChecked (False)
704 self
.organization
.setText ("")
705 self
.additionalinfo
.setText ("")
707 # current employment check box is changed
708 def on_change_currentemployment (self
, val
):
710 self
.leavedate
.setEnabled (False)
712 self
.leavedate
.setEnabled (True)
714 # delete educational qualification
715 def on_delete_education (self
):
716 # get the selected items in the education list
717 selitems
= self
.educationlist
.selectedItems ()
718 # if no items are selected
720 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
721 # delete the items after confirmation
723 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
724 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
725 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
726 # remove the item selected
727 for item
in selitems
:
728 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
729 self
.reset_education_fields ()
730 # set the modified flag
731 self
.ismodified
= True
733 # selection is changed
734 def on_select_education (self
):
735 self
.set_education_fields ()
737 # update educational qualification button
738 def on_update_education (self
):
739 selitems
= self
.educationlist
.selectedItems ()
740 # if no item is selected
742 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
744 # if the qualification title is not set
745 if self
.degree_name
.text () == "":
746 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
748 selitem
= selitems
[0]
750 selitem
.setText (0, self
.degree_name
.text ())
751 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
752 selitem
.setText (2, self
.institution
.text ())
753 selitem
.setText (3, self
.university
.text ())
754 selitem
.setText (4, self
.grade
.text ())
755 selitem
.setText (5, str (self
.percentage
.value ()))
756 # set the modified flag
757 self
.ismodified
= True
759 # add educational qualification button
760 def on_add_education (self
):
761 # check if the qualification title is set
762 if self
.degree_name
.text () == "":
763 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
765 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
766 self
.degree_name
.text (),
767 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
768 self
.institution
.text (),
769 self
.university
.text (),
771 str (self
.percentage
.value ())
773 self
.educationlist
.addTopLevelItem (educationitem
)
775 self
.reset_education_fields ()
776 # set the modified flag
777 self
.ismodified
= True
779 # set fields in the education tab from current selected item
780 def set_education_fields (self
):
781 selitems
= self
.educationlist
.selectedItems ()
784 selitem
= selitems
[0]
785 # set the fields to the data in the selected item in the list
786 self
.degree_name
.setText (selitem
.text (0))
787 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
788 self
.institution
.setText (selitem
.text (2))
789 self
.university
.setText (selitem
.text (3))
790 self
.grade
.setText (selitem
.text(4))
791 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
793 # reset fields in the education tab
794 def reset_education_fields (self
):
795 self
.degree_name
.setText ("")
796 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
797 self
.institution
.setText ("")
798 self
.university
.setText ("")
799 self
.grade
.setText ("")
800 self
.percentage
.setValue (50.0)