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 educational qualifications
97 self
.set_educational_qualifications (docdata
)
99 # set the professional history
100 self
.set_professional_history (docdata
)
102 # set the career objectives
103 self
.set_career_objectives (docdata
)
105 # set the skills list
106 self
.set_skillsets_info (docdata
)
108 # set the additional information
109 self
.set_additional_info (docdata
)
111 # set the current document
112 self
.currentfile
= openfilename
113 self
.ismodified
= False
115 # set the window title
116 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
118 # function to save a file as a new document
119 def on_file_save_as (self
):
120 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
123 # if save file name is not none
124 if savefilename
<> "":
125 mydata
= self
.get_document_data ()
126 mydata
.save_data (savefilename
)
127 self
.ismodified
= False
128 self
.currentfile
= savefilename
129 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
131 # function to save a file
132 def on_file_save (self
):
133 # only save modified file
134 if self
.ismodified
is False:
137 # if no current file get file name from file save dialog
138 if self
.currentfile
is None:
139 savefilename
= PyQt4
.QtGui
.QFileDialog
.getSaveFileName (self
,
142 if savefilename
<> "":
143 mydata
= self
.get_document_data ()
144 mydata
.save_data (savefilename
)
145 self
.ismodified
= False
146 self
.currentfile
= savefilename
147 self
.setWindowTitle ("BiaCV - " + self
.currentfile
)
149 mydata
= self
.get_document_data ()
150 mydata
.save_data (self
.currentfile
)
151 self
.ismodified
= False
153 # function to set document data from the GUI
154 def get_document_data (self
):
155 docdata
= data
.BiaCVData ()
157 # set the document title
158 docdata
.set_document_title (unicode (self
.title
.text ().toUtf8 (), "utf-8"))
160 # get the marital status string from check box
161 if self
.married
.isChecked ():
163 elif self
.single
.isChecked ():
164 maritalstatus
= False
168 docdata
.set_personal_info (
169 unicode (self
.nametitle
.lineEdit ().text ().toUtf8 (), "utf-8"),
170 unicode (self
.firstname
.text ().toUtf8 (), "utf-8"),
171 unicode (self
.lastname
.text ().toUtf8 (), "utf-8"),
172 unicode (self
.dateofbirth
.date().toString ("dd MMM, yyyy"), "utf-8"),
173 unicode (self
.street
.text ().toUtf8 (), "utf-8"),
174 unicode (self
.area
.text ().toUtf8 (), "utf-8"),
175 unicode (self
.city
.text ().toUtf8 (), "utf-8"),
176 unicode (self
.areacode
.text ().toUtf8 (), "utf-8"),
177 unicode (self
.country
.text ().toUtf8 (), "utf-8"),
178 unicode (self
.countrycode_landline
.text ().toUtf8 (), "utf-8"),
179 unicode (self
.telephone
.text ().toUtf8 (), "utf-8"),
180 unicode (self
.countrycode_mobile
.text ().toUtf8 (), "utf-8"),
181 unicode (self
.mobilenumber
.text ().toUtf8 (), "utf-8"),
182 unicode (self
.email
.text ().toUtf8 (), "utf-8"),
185 # get the list of educational qualifications from the treewidget
188 while i
< self
.educationlist
.topLevelItemCount ():
189 curitem
= self
.educationlist
.topLevelItem (i
)
191 curdict
["degree"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
192 curdict
["graduation"] = unicode (curitem
.text (1).toUtf8 (), "utf-8")
193 curdict
["institution"] = unicode (curitem
.text (2).toUtf8 (), "utf-8")
194 curdict
["university"] = unicode (curitem
.text (3).toUtf8 (), "utf-8")
195 curdict
["grade"] = unicode (curitem
.text (4).toUtf8 (), "utf-8")
196 curdict
["percentage"] = float (curitem
.text (5))
197 education
.append (curdict
)
200 # set the educational qualifications
201 docdata
.set_educational_qualifications (education
)
203 # get the list of professional history from the treewidget
206 while i
< self
.professionlist
.topLevelItemCount ():
207 curitem
= self
.professionlist
.topLevelItem (i
)
209 curdict
["jobtitle"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
210 curdict
["joindate"] = unicode (curitem
.text (1), "utf-8")
211 curdict
["leavedate"] = unicode (curitem
.text (2), "utf-8")
212 curdict
["organization"] = unicode (curitem
.text (3).toUtf8 (), "utf-8")
213 curdict
["additionalinfo"] = unicode (curitem
.text (4).toUtf8 (), "utf-8")
214 professional
.append (curdict
)
217 # set the professional qualifications
218 docdata
.set_professional_history (professional
)
220 # set the career objectives
221 shorttermobjectives
= unicode (self
.shorttermcareer
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
222 longtermgoals
= unicode (self
.longtermgoals
.toPlainText ().toUtf8 (), "utf-8").splitlines ()
224 docdata
.set_career_objectives (shorttermobjectives
, longtermgoals
)
229 while i
< self
.skillslist
.topLevelItemCount ():
230 curitem
= self
.skillslist
.topLevelItem (i
)
232 curdict
["skilltitle"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
233 curdict
["skilldesc"] = unicode (curitem
.text (1).toUtf8 (), "utf-8")
234 skills
.append (curdict
)
236 # set the list of skills
237 docdata
.set_skillsets (skills
)
239 # get the list of languages
242 while i
< self
.languageslist
.topLevelItemCount ():
243 curitem
= self
.languageslist
.topLevelItem (i
)
245 curdict
["language"] = unicode (curitem
.text (0).toUtf8 (), "utf-8")
246 curdict
["canspeak" ] = (curitem
.text (1) == "True")
247 curdict
["canreadwrite"] = (curitem
.text (2) == "True")
248 curdict
["isproficient"] = (curitem
.text (3) == "True")
249 langsknown
.append (curdict
)
252 additionalinformation
= unicode (self
.additionalinformation
.toPlainText ().toUtf8 (), "utf-8")
254 docdata
.set_additional_information (langsknown
, additionalinformation
)
258 # function to reset personal information data in the GUI
259 def reset_personal_info (self
):
260 self
.nametitle
.setEditText ("")
261 self
.firstname
.setText ("")
262 self
.lastname
.setText ("")
263 self
.dateofbirth
.setDate (PyQt4
.QtCore
.QDate (1970, 1, 1))
264 self
.street
.setText ("")
265 self
.area
.setText ("")
266 self
.city
.setText ("")
267 self
.countrycode_landline
.setText ("")
268 self
.telephone
.setText ("")
269 self
.countrycode_mobile
.setText ("")
270 self
.mobilenumber
.setText ("")
271 self
.email
.setText ("")
272 self
.areacode
.setText ("")
273 self
.unspecified
.setChecked (True)
275 # function to set personal information data in the GUI from document data
276 def set_personal_info (self
, docdata
):
277 self
.nametitle
.setEditText (docdata
.data
["nametitle"])
278 self
.firstname
.setText (docdata
.data
["firstname"])
279 self
.lastname
.setText (docdata
.data
["lastname"])
280 self
.dateofbirth
.setDate (PyQt4
.QtCore
.QDate
.fromString (docdata
.data
["dateofbirth"], "dd MMM, yyyy"))
281 self
.street
.setText (docdata
.data
["street"])
282 self
.area
.setText (docdata
.data
["area"])
283 self
.city
.setText (docdata
.data
["city"])
284 self
.countrycode_landline
.setText (docdata
.data
["countrycode_landline"])
285 self
.telephone
.setText (docdata
.data
["landline"])
286 self
.countrycode_mobile
.setText (docdata
.data
["countrycode_mobile"])
287 self
.mobilenumber
.setText (docdata
.data
["mobile"])
288 self
.email
.setText (docdata
.data
["email"])
289 self
.areacode
.setText (docdata
.data
["areacode"])
290 self
.country
.setText (docdata
.data
["country"])
292 if docdata
.data
["maritalstatus"] is True:
293 self
.married
.setChecked (True)
294 elif docdata
.data
["maritalstatus"] is False:
295 self
.single
.setChecked (True)
297 self
.unspecified
.setChecked (True)
299 # function to clear professional history in the GUI
300 def reset_professional_history (self
):
301 self
.reset_profession_fields ()
302 self
.professionlist
.clear ()
304 # function to set the professional history in the GUI from the document data
305 def set_professional_history (self
, docdata
):
306 # reset the professional history
307 self
.reset_professional_history ()
309 # add the professional history items to list
310 for item
in docdata
.data
["professionalhistory"]:
311 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
316 item
["organization"],
317 item
["additionalinfo"]
320 self
.professionlist
.addTopLevelItem (professionitem
)
322 # function to clear educational qualifications in the GUI
323 def reset_educational_qualifications (self
):
324 self
.reset_education_fields ()
325 self
.educationlist
.clear ()
327 # function to set education qualifications in the GUI from document data
328 def set_educational_qualifications (self
, docdata
):
329 # reset the educational qualifications
330 self
.reset_educational_qualifications ()
332 # add education items to list
333 for item
in docdata
.data
["educationalqualifications"]:
334 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem (
341 str (item
["percentage"])
344 self
.educationlist
.addTopLevelItem (educationitem
)
346 # function to clear career objectives data in the GUI
347 def reset_career_objectives (self
):
348 self
.shorttermcareer
.setPlainText ("")
349 self
.longtermgoals
.setPlainText ("")
351 # function to set career objectives data in the GUI from document data
352 def set_career_objectives (self
, docdata
):
353 self
.shorttermcareer
.setPlainText (u
'\n'.join (docdata
.data
["shorttermobjectives"]))
354 self
.longtermgoals
.setPlainText (u
'\n'.join (docdata
.data
["longtermgoals"]))
356 # function to clear skill sets data in the GUI
357 def reset_skillsets_info (self
):
358 self
.reset_skillset_fields ()
359 self
.skillslist
.clear ()
361 # function to set the skill sets data in the GUI from document data
362 def set_skillsets_info (self
, docdata
):
363 # clear the skill sets information
364 self
.reset_skillsets_info ()
366 for item
in docdata
.data
["skillsets"]:
367 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
373 self
.skillslist
.addTopLevelItem (skillitem
)
376 # function to clear additional information data in the GUI
377 def reset_additional_info (self
):
378 self
.reset_language_fields ()
379 self
.languageslist
.clear ()
380 self
.additionalinformation
.setPlainText ("")
382 # function to set additional information data in the GUI from the document data
383 def set_additional_info (self
, docdata
):
384 # clear the additional information
385 self
.reset_additional_info ()
387 # set the languages list
388 for item
in docdata
.data
["languagesknown"]:
389 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
392 str (item
["canspeak"]),
393 str (item
["canreadwrite"]),
394 str (item
["isproficient"])
397 self
.languageslist
.addTopLevelItem (langitem
)
399 self
.additionalinformation
.setPlainText (docdata
.data
["additionalinformation"])
401 # function to clear all the fields and reset them to defaults
402 def new_document (self
):
403 # first clear the individual record fields in the tabs
404 self
.reset_language_fields ()
405 self
.reset_skillset_fields ()
407 # clear document data
408 self
.title
.setText ("")
410 self
.reset_personal_info ()
411 self
.reset_professional_history ()
412 self
.reset_educational_qualifications ()
413 self
.reset_career_objectives ()
414 self
.reset_skillsets_info ()
415 self
.reset_additional_info ()
417 # set the page to first page
418 self
.pages
.setCurrentIndex (0)
420 # set current file to none and modified to false
421 self
.currentfile
= None
422 self
.ismodified
= False
424 # set the window title
425 self
.setWindowTitle ("BiaCV - untitled")
427 # file new action is triggered
428 def on_file_new (self
):
429 # if the previous document is modified
430 # as if it should be discarded
431 if self
.ismodified
is True:
432 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
,
433 lang
.CONFIRM_DISCARD_SAVE
,
434 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
435 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
437 # if not modified then simply create a new document
441 # when the document is modified
442 def on_document_modified (self
):
443 # set the document modified flag
444 self
.ismodified
= True
446 # update a language in the list of languages
447 def on_update_lang (self
):
448 # get the selected language
449 selitems
= self
.languageslist
.selectedItems ()
451 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
453 # check if the language string is not empty
454 if self
.language
.text () == "":
455 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
457 selitem
= selitems
[0]
458 selitem
.setText (0, self
.language
.text ())
459 selitem
.setText (1, str (self
.canspeak
.isChecked ()))
460 selitem
.setText (2, str (self
.canreadwrite
.isChecked ()))
461 selitem
.setText (3, str (self
.isproficient
.isChecked ()))
463 # modified the document
464 self
.ismodified
= True
466 # selecting a language from the list of languages
467 def on_select_lang (self
):
468 # set the language fields from the selected item
469 self
.set_language_fields ()
471 # delete a language from the list of languages known
472 def on_delete_lang (self
):
473 # get selected language
474 selitems
= self
.languageslist
.selectedItems ()
476 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_REQ_MISSING
)
479 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
480 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
481 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
482 for item
in selitems
:
483 self
.languageslist
.takeTopLevelItem (self
.languageslist
.indexOfTopLevelItem (item
))
485 self
.reset_language_fields ()
486 # set the modified flag
487 self
.ismodified
= True
489 # add a language to the list of languages known
490 def on_add_lang (self
):
491 # check if the language is set
492 if self
.language
.text () == "":
493 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
495 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
497 self
.language
.text (),
498 str (self
.canspeak
.isChecked ()),
499 str (self
.canreadwrite
.isChecked ()),
500 str (self
.isproficient
.isChecked ())
503 self
.languageslist
.addTopLevelItem (langitem
)
504 self
.reset_language_fields ()
506 # set the modified flag
507 self
.ismodified
= True
509 # set the language fields from the selected item
510 def set_language_fields (self
):
511 selitems
= self
.languageslist
.selectedItems ()
514 selitem
= selitems
[0]
515 self
.language
.setText (selitem
.text (0))
516 self
.canspeak
.setChecked (selitem
.text (1) == "True")
517 self
.canreadwrite
.setChecked (selitem
.text(2) == "True")
518 self
.isproficient
.setChecked (selitem
.text(3) == "True")
520 # reset the language fields
521 def reset_language_fields (self
):
522 self
.language
.setText ("")
523 self
.canspeak
.setChecked (True)
524 self
.canreadwrite
.setChecked (False)
525 self
.isproficient
.setChecked (False)
527 # update the skill set button event
528 def on_update_skill (self
):
529 # get the selected item
530 selitems
= self
.skillslist
.selectedItems ()
532 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
534 if self
.skillsettitle
.text () == "":
535 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
537 selitem
= selitems
[0]
539 selitem
.setText (0, self
.skillsettitle
.text ())
540 selitem
.setText (1, self
.skilldescription
.toPlainText ())
541 # set the modified flag
542 self
.ismodified
= True
544 # selecting a skill from the list event
545 def on_select_skill (self
):
546 self
.set_skill_fields ()
548 # set the skill fields from the selected skill from the list
549 def set_skill_fields (self
):
550 # get the selected items
551 selitems
= self
.skillslist
.selectedItems ()
554 selitem
= selitems
[0]
555 self
.skillsettitle
.setText (selitem
.text (0))
556 self
.skilldescription
.setPlainText (selitem
.text (1))
558 # delete skill set button is clicked
559 def on_delete_skill (self
):
560 # get the selected items
561 selitems
= self
.skillslist
.selectedItems ()
563 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
566 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
567 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
569 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
570 for item
in selitems
:
571 self
.skillslist
.takeTopLevelItem (self
.skillslist
.indexOfTopLevelItem (item
))
573 self
.reset_skillset_fields ()
574 # set the modified flag
575 self
.ismodified
= True
577 # add skill set button is clicked
578 def on_add_skill (self
):
579 # if the skill title is blank
580 if self
.skillsettitle
.text () == "":
581 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
583 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
585 self
.skillsettitle
.text (),
586 self
.skilldescription
.toPlainText ()
589 self
.skillslist
.addTopLevelItem (skillitem
)
590 self
.reset_skillset_fields ()
591 # set the modified flag
592 self
.ismodified
= True
594 # clear the skill set fields
595 def reset_skillset_fields (self
):
596 self
.skillsettitle
.setText ("")
597 self
.skilldescription
.setPlainText ("")
599 # update professional history button is clicked
600 def on_update_profession (self
):
601 # get the selected item
602 selitems
= self
.professionlist
.selectedItems ()
604 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
606 selitem
= selitems
[0]
607 # if designation is not set
608 if self
.designation
.text () == "":
609 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
611 # if currently employed in that position, leaving date is to be disabled
612 # and set to "current"
613 if self
.currentemployment
.isChecked ():
614 leavedatestr
= "current"
616 # if the leaving date is < join date
617 if self
.leavedate
.date () < self
.joindate
.date ():
618 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_DATE
)
620 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
622 selitem
.setText (0, self
.designation
.text ())
623 selitem
.setText (1, self
.joindate
.date ().toString ("dd MMM, yyyy"))
624 selitem
.setText (2, leavedatestr
)
625 selitem
.setText (3, self
.organization
.text ())
626 selitem
.setText (4, self
.additionalinfo
.text ())
627 # set the modified flag
628 self
.ismodified
= True
630 # delete professional history button is clicked
631 def on_delete_profession (self
):
632 # get the selected items
633 selitems
= self
.professionlist
.selectedItems ()
635 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
638 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
639 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
641 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
642 for item
in selitems
:
643 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
644 self
.reset_profession_fields ()
645 # set the modified flag
646 self
.ismodified
= True
648 # add professional history button is clicked
649 def on_add_profession (self
):
650 if self
.designation
.text () == "":
651 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
653 # if currently employed in that position, leaving date is to be disabled
654 # and set to "current"
655 if self
.currentemployment
.isChecked ():
656 leavedatestr
= "current"
658 # if the leaving date is < join date
659 if self
.leavedate
.date () < self
.joindate
.date ():
660 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_DATE
)
662 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
664 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
666 self
.designation
.text (),
667 self
.joindate
.date ().toString ("dd MMM, yyyy"),
669 self
.organization
.text (),
670 self
.additionalinfo
.text ()
674 self
.professionlist
.addTopLevelItem (professionitem
)
676 self
.reset_profession_fields ()
677 # set the modified flag
678 self
.ismodified
= True
680 # when selection of profession list is changed
681 def on_select_profession (self
):
682 self
.set_profession_fields ()
684 # set the profession fields from the selected item in profession list
685 def set_profession_fields (self
):
686 selitems
= self
.professionlist
.selectedItems ()
689 selitem
= selitems
[0]
690 self
.designation
.setText (selitem
.text (0))
691 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
692 if selitem
.text (2) == "current":
693 self
.leavedate
.setEnabled (False)
694 self
.currentemployment
.setChecked (True)
696 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
697 self
.leavedate
.setEnabled (True)
698 self
.currentemployment
.setChecked (False)
700 self
.organization
.setText (selitem
.text (3))
701 self
.additionalinfo
.setText (selitem
.text (4))
703 def reset_profession_fields (self
):
704 self
.designation
.setText ("")
705 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
706 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
707 self
.currentemployment
.setChecked (False)
708 self
.organization
.setText ("")
709 self
.additionalinfo
.setText ("")
711 # current employment check box is changed
712 def on_change_currentemployment (self
, val
):
714 self
.leavedate
.setEnabled (False)
716 self
.leavedate
.setEnabled (True)
718 # delete educational qualification
719 def on_delete_education (self
):
720 # get the selected items in the education list
721 selitems
= self
.educationlist
.selectedItems ()
722 # if no items are selected
724 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_DELETE
, lang
.ERROR_NO_SELECTION
)
725 # delete the items after confirmation
727 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, lang
.CONFIRM
, lang
.CONFIRM_DELETE
,
728 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
729 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
730 # remove the item selected
731 for item
in selitems
:
732 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
733 self
.reset_education_fields ()
734 # set the modified flag
735 self
.ismodified
= True
737 # selection is changed
738 def on_select_education (self
):
739 self
.set_education_fields ()
741 # update educational qualification button
742 def on_update_education (self
):
743 selitems
= self
.educationlist
.selectedItems ()
744 # if no item is selected
746 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_NO_SELECTION
)
748 # if the qualification title is not set
749 if self
.degree_name
.text () == "":
750 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_UPDATE
, lang
.ERROR_REQ_MISSING
)
752 selitem
= selitems
[0]
754 selitem
.setText (0, self
.degree_name
.text ())
755 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
756 selitem
.setText (2, self
.institution
.text ())
757 selitem
.setText (3, self
.university
.text ())
758 selitem
.setText (4, self
.grade
.text ())
759 selitem
.setText (5, str (self
.percentage
.value ()))
760 # set the modified flag
761 self
.ismodified
= True
763 # add educational qualification button
764 def on_add_education (self
):
765 # check if the qualification title is set
766 if self
.degree_name
.text () == "":
767 PyQt4
.QtGui
.QMessageBox
.critical (self
, lang
.ERROR_ADD
, lang
.ERROR_REQ_MISSING
)
769 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
770 self
.degree_name
.text (),
771 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
772 self
.institution
.text (),
773 self
.university
.text (),
775 str (self
.percentage
.value ())
777 self
.educationlist
.addTopLevelItem (educationitem
)
779 self
.reset_education_fields ()
780 # set the modified flag
781 self
.ismodified
= True
783 # set fields in the education tab from current selected item
784 def set_education_fields (self
):
785 selitems
= self
.educationlist
.selectedItems ()
788 selitem
= selitems
[0]
789 # set the fields to the data in the selected item in the list
790 self
.degree_name
.setText (selitem
.text (0))
791 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
792 self
.institution
.setText (selitem
.text (2))
793 self
.university
.setText (selitem
.text (3))
794 self
.grade
.setText (selitem
.text(4))
795 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
797 # reset fields in the education tab
798 def reset_education_fields (self
):
799 self
.degree_name
.setText ("")
800 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
801 self
.institution
.setText ("")
802 self
.university
.setText ("")
803 self
.grade
.setText ("")
804 self
.percentage
.setValue (50.0)