a68652ce3ebf00fd2561d583484187cae2329eb4
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 filter = lang
.BIACV_FILE_FILTER
)
83 # if no open file name then return
84 if openfilename
== "":
87 # load the document data from open file name
88 docdata
= data
.BiaCVData ()
89 docdata
.load_data (openfilename
)
92 self
.title
.setText (docdata
.data
["title"])
94 # set the personal information fields from document data
95 self
.set_personal_info (docdata
)
97 # set the profile highlights
98 self
.set_profile_highlights (docdata
)
100 # set the educational qualifications
101 self
.set_educational_qualifications (docdata
)
103 # set the professional history
104 self
.set_professional_history (docdata
)
106 # set the career objectives
107 self
.set_career_objectives (docdata
)
109 # set the skills list
110 self
.set_skillsets_info (docdata
)
112 # set the additional information
113 self
.set_additional_info (docdata
)
115 # set the current document
116 self
.currentfile
= openfilename
117 self
.ismodified
= False
119 # set the window title
120 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
122 # function to save a file as a new document
123 def on_file_save_as (self
):
124 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
125 lang
.SAVE_TITLE
, filter=lang
.BIACV_FILE_FILTER
)
127 # if save file name is not none
128 if savefilename
<> "":
129 mydata
= self
.get_document_data ()
130 mydata
.save_data (savefilename
)
131 self
.ismodified
= False
132 self
.currentfile
= savefilename
133 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
135 # function to save a file
136 def on_file_save (self
):
137 # only save modified file
138 if self
.ismodified
is False:
141 # if no current file get file name from file save dialog
142 if self
.currentfile
is None:
143 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
144 lang
.SAVE_TITLE
, filter=lang
.BIACV_FILE_FILTER
)
146 if savefilename
<> "":
147 mydata
= self
.get_document_data ()
148 mydata
.save_data (savefilename
)
149 self
.ismodified
= False
150 self
.currentfile
= savefilename
151 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
153 mydata
= self
.get_document_data ()
154 mydata
.save_data (self
.currentfile
)
155 self
.ismodified
= False
157 # function to set document data from the GUI
158 def get_document_data (self
):
159 docdata
= data
.BiaCVData ()
161 # set the document title
162 docdata
.set_document_title (unicode (self
.title
.text ().toUtf8 (), "utf-8"))
164 # get the marital status string from check box
165 if self
.married
.isChecked ():
167 elif self
.single
.isChecked ():
168 maritalstatus
= False
172 docdata
.set_personal_info (
173 unicode (self
.nametitle
.lineEdit ().text ().toUtf8 (), "utf-8"),
174 unicode (self
.firstname
.text ().toUtf8 (), "utf-8"),
175 unicode (self
.lastname
.text ().toUtf8 (), "utf-8"),
176 unicode (self
.dateofbirth
.date().toString ("dd MMM, yyyy"), "utf-8"),
177 unicode (self
.street
.text ().toUtf8 (), "utf-8"),
178 unicode (self
.area
.text ().toUtf8 (), "utf-8"),
179 unicode (self
.city
.text ().toUtf8 (), "utf-8"),
180 unicode (self
.areacode
.text ().toUtf8 (), "utf-8"),
181 unicode (self
.country
.text ().toUtf8 (), "utf-8"),
182 unicode (self
.countrycode_landline
.text ().toUtf8 (), "utf-8"),
183 unicode (self
.telephone
.text ().toUtf8 (), "utf-8"),
184 unicode (self
.countrycode_mobile
.text ().toUtf8 (), "utf-8"),
185 unicode (self
.mobilenumber
.text ().toUtf8 (), "utf-8"),
186 unicode (self
.email
.text ().toUtf8 (), "utf-8"),
190 # set the profile highlights
191 profile_highlights
= unicode (self
.profile
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
192 docdata
.set_profile (profile_highlights
)
194 # get the list of educational qualifications from the treewidget
197 while i
< self
.educationlist
.topLevelItemCount ():
198 curitem
= self
.educationlist
.topLevelItem (i
)
200 curdict
["degree"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
201 curdict
["graduation"] = unicode (curitem
.text (1).toUtf8 (), "utf-8")
202 curdict
["institution"] = unicode (curitem
.text (2).toUtf8 (), "utf-8")
203 curdict
["university"] = unicode (curitem
.text (3).toUtf8 (), "utf-8")
204 curdict
["grade"] = unicode (curitem
.text (4).toUtf8 (), "utf-8")
205 curdict
["percentage"] = float (curitem
.text (5))
206 education
.append (curdict
)
209 # set the educational qualifications
210 docdata
.set_educational_qualifications (education
)
212 # get the list of professional history from the treewidget
215 while i
< self
.professionlist
.topLevelItemCount ():
216 curitem
= self
.professionlist
.topLevelItem (i
)
218 curdict
["jobtitle"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
219 curdict
["joindate"] = unicode (curitem
.text (1), "utf-8")
220 curdict
["leavedate"] = unicode (curitem
.text (2), "utf-8")
221 curdict
["organization"] = unicode (curitem
.text (3).toUtf8 (), "utf-8")
222 curdict
["additionalinfo"] = unicode (curitem
.text (4).toUtf8 (), "utf-8")
223 professional
.append (curdict
)
226 # set the professional qualifications
227 docdata
.set_professional_history (professional
)
229 # set the career objectives
230 shorttermobjectives
= unicode (self
.shorttermcareer
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
231 longtermgoals
= unicode (self
.longtermgoals
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
233 docdata
.set_career_objectives (shorttermobjectives
, longtermgoals
)
238 while i
< self
.skillslist
.topLevelItemCount ():
239 curitem
= self
.skillslist
.topLevelItem (i
)
241 curdict
["skilltitle"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
242 curdict
["skilldesc"] = unicode (curitem
.text (1).toUtf8 (), "utf-8")
243 skills
.append (curdict
)
245 # set the list of skills
246 docdata
.set_skillsets (skills
)
248 # get the list of languages
251 while i
< self
.languageslist
.topLevelItemCount ():
252 curitem
= self
.languageslist
.topLevelItem (i
)
254 curdict
["language"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
255 curdict
["canspeak" ] = (curitem
.text (1) == "True")
256 curdict
["canreadwrite"] = (curitem
.text (2) == "True")
257 curdict
["isproficient"] = (curitem
.text (3) == "True")
258 langsknown
.append (curdict
)
261 additionalinformation
= unicode (self
.additionalinformation
.toPlainText ().toUtf8 (), "utf-8")
263 docdata
.set_additional_information (langsknown
, additionalinformation
)
267 # function to reset personal information data in the GUI
268 def reset_personal_info (self
):
269 self
.nametitle
.setEditText ("")
270 self
.firstname
.setText ("")
271 self
.lastname
.setText ("")
272 self
.dateofbirth
.setDate (PyQt4
.QtCore
.QDate (1970, 1, 1))
273 self
.street
.setText ("")
274 self
.area
.setText ("")
275 self
.city
.setText ("")
276 self
.countrycode_landline
.setText ("")
277 self
.telephone
.setText ("")
278 self
.countrycode_mobile
.setText ("")
279 self
.mobilenumber
.setText ("")
280 self
.email
.setText ("")
281 self
.areacode
.setText ("")
282 self
.unspecified
.setChecked (True)
283 self
.country
.setText ("")
285 # function to set the profile highlights in the GUI from document data
286 def set_profile_highlights (self
, docdata
):
287 self
.profile
.setPlainText (u
'\n'.join (docdata
.data
["profile"]))
289 # function to reset profile highlights data in GUI
290 def reset_profile_highlights (self
):
291 self
.profile
.setPlainText ("")
293 # function to set personal information data in the GUI from document data
294 def set_personal_info (self
, docdata
):
295 self
.nametitle
.setEditText (docdata
.data
["nametitle"])
296 self
.firstname
.setText (docdata
.data
["firstname"])
297 self
.lastname
.setText (docdata
.data
["lastname"])
298 self
.dateofbirth
.setDate (PyQt4
.QtCore
.QDate
.fromString (docdata
.data
["dateofbirth"], "dd MMM, yyyy"))
299 self
.street
.setText (docdata
.data
["street"])
300 self
.area
.setText (docdata
.data
["area"])
301 self
.city
.setText (docdata
.data
["city"])
302 self
.countrycode_landline
.setText (docdata
.data
["countrycode_landline"])
303 self
.telephone
.setText (docdata
.data
["landline"])
304 self
.countrycode_mobile
.setText (docdata
.data
["countrycode_mobile"])
305 self
.mobilenumber
.setText (docdata
.data
["mobile"])
306 self
.email
.setText (docdata
.data
["email"])
307 self
.areacode
.setText (docdata
.data
["areacode"])
308 self
.country
.setText (docdata
.data
["country"])
310 if docdata
.data
["maritalstatus"] is True:
311 self
.married
.setChecked (True)
312 elif docdata
.data
["maritalstatus"] is False:
313 self
.single
.setChecked (True)
315 self
.unspecified
.setChecked (True)
317 # function to clear professional history in the GUI
318 def reset_professional_history (self
):
319 self
.reset_profession_fields ()
320 self
.professionlist
.clear ()
322 # function to set the professional history in the GUI from the document data
323 def set_professional_history (self
, docdata
):
324 # reset the professional history
325 self
.reset_professional_history ()
327 # add the professional history items to list
328 for item
in docdata
.data
["professionalhistory"]:
329 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
334 item
["organization"],
335 item
["additionalinfo"]
338 self
.professionlist
.addTopLevelItem (professionitem
)
340 # function to clear educational qualifications in the GUI
341 def reset_educational_qualifications (self
):
342 self
.reset_education_fields ()
343 self
.educationlist
.clear ()
345 # function to set education qualifications in the GUI from document data
346 def set_educational_qualifications (self
, docdata
):
347 # reset the educational qualifications
348 self
.reset_educational_qualifications ()
350 # add education items to list
351 for item
in docdata
.data
["educationalqualifications"]:
352 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem (
359 str (item
["percentage"])
362 self
.educationlist
.addTopLevelItem (educationitem
)
364 # function to clear career objectives data in the GUI
365 def reset_career_objectives (self
):
366 self
.shorttermcareer
.setPlainText ("")
367 self
.longtermgoals
.setPlainText ("")
369 # function to set career objectives data in the GUI from document data
370 def set_career_objectives (self
, docdata
):
371 self
.shorttermcareer
.setPlainText (u
'\n'.join (docdata
.data
["shorttermobjectives"]))
372 self
.longtermgoals
.setPlainText (u
'\n'.join (docdata
.data
["longtermgoals"]))
374 # function to clear skill sets data in the GUI
375 def reset_skillsets_info (self
):
376 self
.reset_skillset_fields ()
377 self
.skillslist
.clear ()
379 # function to set the skill sets data in the GUI from document data
380 def set_skillsets_info (self
, docdata
):
381 # clear the skill sets information
382 self
.reset_skillsets_info ()
384 for item
in docdata
.data
["skillsets"]:
385 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
391 self
.skillslist
.addTopLevelItem (skillitem
)
394 # function to clear additional information data in the GUI
395 def reset_additional_info (self
):
396 self
.reset_language_fields ()
397 self
.languageslist
.clear ()
398 self
.additionalinformation
.setPlainText ("")
400 # function to set additional information data in the GUI from the document data
401 def set_additional_info (self
, docdata
):
402 # clear the additional information
403 self
.reset_additional_info ()
405 # set the languages list
406 for item
in docdata
.data
["languagesknown"]:
407 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
410 str (item
["canspeak"]),
411 str (item
["canreadwrite"]),
412 str (item
["isproficient"])
415 self
.languageslist
.addTopLevelItem (langitem
)
417 self
.additionalinformation
.setPlainText (docdata
.data
["additionalinformation"])
419 # function to clear all the fields and reset them to defaults
420 def new_document (self
):
421 # first clear the individual record fields in the tabs
422 self
.reset_language_fields ()
423 self
.reset_skillset_fields ()
425 # clear document data
426 self
.title
.setText ("")
428 self
.reset_personal_info ()
429 self
.reset_profile_highlights ()
430 self
.reset_professional_history ()
431 self
.reset_educational_qualifications ()
432 self
.reset_career_objectives ()
433 self
.reset_skillsets_info ()
434 self
.reset_additional_info ()
436 # set the page to first page
437 self
.pages
.setCurrentIndex (0)
439 # set current file to none and modified to false
440 self
.currentfile
= None
441 self
.ismodified
= False
443 # set the window title
444 self
.setWindowTitle ("BiaCV - untitled")
446 # file new action is triggered
447 def on_file_new (self
):
448 # if the previous document is modified
449 # as if it should be discarded
450 if self
.ismodified
is True:
451 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
,
452 lang
.CONFIRM_DISCARD_SAVE
,
453 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
454 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
456 # if not modified then simply create a new document
460 # when the document is modified
461 def on_document_modified (self
):
462 # set the document modified flag
463 self
.ismodified
= True
465 # update a language in the list of languages
466 def on_update_lang (self
):
467 # get the selected language
468 selitems
= self
.languageslist
.selectedItems ()
470 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
472 # check if the language string is not empty
473 if self
.language
.text () == "":
474 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
476 selitem
= selitems
[0]
477 selitem
.setText (0, self
.language
.text ())
478 selitem
.setText (1, str (self
.canspeak
.isChecked ()))
479 selitem
.setText (2, str (self
.canreadwrite
.isChecked ()))
480 selitem
.setText (3, str (self
.isproficient
.isChecked ()))
482 # modified the document
483 self
.ismodified
= True
485 # selecting a language from the list of languages
486 def on_select_lang (self
):
487 # set the language fields from the selected item
488 self
.set_language_fields ()
490 # delete a language from the list of languages known
491 def on_delete_lang (self
):
492 # get selected language
493 selitems
= self
.languageslist
.selectedItems ()
495 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_REQ_MISSING
)
498 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
499 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
500 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
501 for item
in selitems
:
502 self
.languageslist
.takeTopLevelItem (self
.languageslist
.indexOfTopLevelItem (item
))
504 self
.reset_language_fields ()
505 # set the modified flag
506 self
.ismodified
= True
508 # add a language to the list of languages known
509 def on_add_lang (self
):
510 # check if the language is set
511 if self
.language
.text () == "":
512 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
514 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
516 self
.language
.text (),
517 str (self
.canspeak
.isChecked ()),
518 str (self
.canreadwrite
.isChecked ()),
519 str (self
.isproficient
.isChecked ())
522 self
.languageslist
.addTopLevelItem (langitem
)
523 self
.reset_language_fields ()
525 # set the modified flag
526 self
.ismodified
= True
528 # set the language fields from the selected item
529 def set_language_fields (self
):
530 selitems
= self
.languageslist
.selectedItems ()
533 selitem
= selitems
[0]
534 self
.language
.setText (selitem
.text (0))
535 self
.canspeak
.setChecked (selitem
.text (1) == "True")
536 self
.canreadwrite
.setChecked (selitem
.text(2) == "True")
537 self
.isproficient
.setChecked (selitem
.text(3) == "True")
539 # reset the language fields
540 def reset_language_fields (self
):
541 self
.language
.setText ("")
542 self
.canspeak
.setChecked (True)
543 self
.canreadwrite
.setChecked (False)
544 self
.isproficient
.setChecked (False)
546 # update the skill set button event
547 def on_update_skill (self
):
548 # get the selected item
549 selitems
= self
.skillslist
.selectedItems ()
551 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
553 if self
.skillsettitle
.text () == "":
554 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
556 selitem
= selitems
[0]
558 selitem
.setText (0, self
.skillsettitle
.text ())
559 selitem
.setText (1, self
.skilldescription
.toPlainText ())
560 # set the modified flag
561 self
.ismodified
= True
563 # selecting a skill from the list event
564 def on_select_skill (self
):
565 self
.set_skill_fields ()
567 # set the skill fields from the selected skill from the list
568 def set_skill_fields (self
):
569 # get the selected items
570 selitems
= self
.skillslist
.selectedItems ()
573 selitem
= selitems
[0]
574 self
.skillsettitle
.setText (selitem
.text (0))
575 self
.skilldescription
.setPlainText (selitem
.text (1))
577 # delete skill set button is clicked
578 def on_delete_skill (self
):
579 # get the selected items
580 selitems
= self
.skillslist
.selectedItems ()
582 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
585 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
586 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
588 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
589 for item
in selitems
:
590 self
.skillslist
.takeTopLevelItem (self
.skillslist
.indexOfTopLevelItem (item
))
592 self
.reset_skillset_fields ()
593 # set the modified flag
594 self
.ismodified
= True
596 # add skill set button is clicked
597 def on_add_skill (self
):
598 # if the skill title is blank
599 if self
.skillsettitle
.text () == "":
600 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
602 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
604 self
.skillsettitle
.text (),
605 self
.skilldescription
.toPlainText ()
608 self
.skillslist
.addTopLevelItem (skillitem
)
609 self
.reset_skillset_fields ()
610 # set the modified flag
611 self
.ismodified
= True
613 # clear the skill set fields
614 def reset_skillset_fields (self
):
615 self
.skillsettitle
.setText ("")
616 self
.skilldescription
.setPlainText ("")
618 # update professional history button is clicked
619 def on_update_profession (self
):
620 # get the selected item
621 selitems
= self
.professionlist
.selectedItems ()
623 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
625 selitem
= selitems
[0]
626 # if designation is not set
627 if self
.designation
.text () == "":
628 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
630 # if currently employed in that position, leaving date is to be disabled
632 if self
.currentemployment
.isChecked ():
635 # if the leaving date is < join date
636 if self
.leavedate
.date () < self
.joindate
.date ():
637 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_DATE
)
639 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
641 selitem
.setText (0, self
.designation
.text ())
642 selitem
.setText (1, self
.joindate
.date ().toString ("dd MMM, yyyy"))
643 selitem
.setText (2, leavedatestr
)
644 selitem
.setText (3, self
.organization
.text ())
645 selitem
.setText (4, self
.additionalinfo
.text ())
646 # set the modified flag
647 self
.ismodified
= True
649 # delete professional history button is clicked
650 def on_delete_profession (self
):
651 # get the selected items
652 selitems
= self
.professionlist
.selectedItems ()
654 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
657 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
658 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
660 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
661 for item
in selitems
:
662 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
663 self
.reset_profession_fields ()
664 # set the modified flag
665 self
.ismodified
= True
667 # add professional history button is clicked
668 def on_add_profession (self
):
669 if self
.designation
.text () == "":
670 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
672 # if currently employed in that position, leaving date is to be disabled
674 if self
.currentemployment
.isChecked ():
677 # if the leaving date is < join date
678 if self
.leavedate
.date () < self
.joindate
.date ():
679 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_DATE
)
681 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
683 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
685 self
.designation
.text (),
686 self
.joindate
.date ().toString ("dd MMM, yyyy"),
688 self
.organization
.text (),
689 self
.additionalinfo
.text ()
693 self
.professionlist
.addTopLevelItem (professionitem
)
695 self
.reset_profession_fields ()
696 # set the modified flag
697 self
.ismodified
= True
699 # when selection of profession list is changed
700 def on_select_profession (self
):
701 self
.set_profession_fields ()
703 # set the profession fields from the selected item in profession list
704 def set_profession_fields (self
):
705 selitems
= self
.professionlist
.selectedItems ()
708 selitem
= selitems
[0]
709 self
.designation
.setText (selitem
.text (0))
710 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
711 if selitem
.text (2) == "":
712 self
.leavedate
.setEnabled (False)
713 self
.currentemployment
.setChecked (True)
715 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
716 self
.leavedate
.setEnabled (True)
717 self
.currentemployment
.setChecked (False)
719 self
.organization
.setText (selitem
.text (3))
720 self
.additionalinfo
.setText (selitem
.text (4))
722 def reset_profession_fields (self
):
723 self
.designation
.setText ("")
724 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
725 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
726 self
.currentemployment
.setChecked (False)
727 self
.organization
.setText ("")
728 self
.additionalinfo
.setText ("")
730 # current employment check box is changed
731 def on_change_currentemployment (self
, val
):
733 self
.leavedate
.setEnabled (False)
735 self
.leavedate
.setEnabled (True)
737 # delete educational qualification
738 def on_delete_education (self
):
739 # get the selected items in the education list
740 selitems
= self
.educationlist
.selectedItems ()
741 # if no items are selected
743 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
744 # delete the items after confirmation
746 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
747 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
748 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
749 # remove the item selected
750 for item
in selitems
:
751 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
752 self
.reset_education_fields ()
753 # set the modified flag
754 self
.ismodified
= True
756 # selection is changed
757 def on_select_education (self
):
758 self
.set_education_fields ()
760 # update educational qualification button
761 def on_update_education (self
):
762 selitems
= self
.educationlist
.selectedItems ()
763 # if no item is selected
765 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
767 # if the qualification title is not set
768 if self
.degree_name
.text () == "":
769 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
771 selitem
= selitems
[0]
773 selitem
.setText (0, self
.degree_name
.text ())
774 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
775 selitem
.setText (2, self
.institution
.text ())
776 selitem
.setText (3, self
.university
.text ())
777 selitem
.setText (4, self
.grade
.text ())
778 selitem
.setText (5, str (self
.percentage
.value ()))
779 # set the modified flag
780 self
.ismodified
= True
782 # add educational qualification button
783 def on_add_education (self
):
784 # check if the qualification title is set
785 if self
.degree_name
.text () == "":
786 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
788 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
789 self
.degree_name
.text (),
790 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
791 self
.institution
.text (),
792 self
.university
.text (),
794 str (self
.percentage
.value ())
796 self
.educationlist
.addTopLevelItem (educationitem
)
798 self
.reset_education_fields ()
799 # set the modified flag
800 self
.ismodified
= True
802 # set fields in the education tab from current selected item
803 def set_education_fields (self
):
804 selitems
= self
.educationlist
.selectedItems ()
807 selitem
= selitems
[0]
808 # set the fields to the data in the selected item in the list
809 self
.degree_name
.setText (selitem
.text (0))
810 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
811 self
.institution
.setText (selitem
.text (2))
812 self
.university
.setText (selitem
.text (3))
813 self
.grade
.setText (selitem
.text(4))
814 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
816 # reset fields in the education tab
817 def reset_education_fields (self
):
818 self
.degree_name
.setText ("")
819 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
820 self
.institution
.setText ("")
821 self
.university
.setText ("")
822 self
.grade
.setText ("")
823 self
.percentage
.setValue (50.0)