681469d52baa28871d8809c05745b2a590abe533
[biacv.git] / biacv_mainwindow.py
1 # BiaCV
2 # class for main window
3
4 import PyQt4
5 import biacv_mainwindow_ui as bui
6 import biacv_lang as lang
7 import biacv_data as data
8
9 class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
10 def __init__ (self):
11 PyQt4.QtGui.QMainWindow.__init__ (self)
12 self.setupUi (self)
13 self.currentfile = None
14 self.ismodified = False
15 self.setWindowTitle ("BiaCV - untitled")
16
17 # function to open a file
18 def on_file_open (self):
19 # if modified, confirm
20 if self.ismodified is True:
21 ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, lang.CONFIRM_DISCARD_SAVE,
22 PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
23 # if no, then don't open the file
24 if ans <> PyQt4.QtGui.QMessageBox.Yes:
25 return
26
27 # open file dialog
28 openfilename = PyQt4.QtGui.QFileDialog.getOpenFileName (self, lang.OPEN_TITLE)
29 # if no open file name then return
30 if openfilename == "":
31 return
32
33 # load the document data from open file name
34 docdata = data.BiaCVData ()
35 docdata.load_data (openfilename)
36
37 # set the title
38 self.title.setText (docdata.data["title"])
39
40 # set the personal information fields from document data
41 self.set_personal_info (docdata)
42
43 # set the educational qualifications
44 self.set_educational_qualifications (docdata)
45
46 # set the professional history
47 self.set_professional_history (docdata)
48
49 # set the career objectives
50 self.set_career_objectives (docdata)
51
52 # set the skills list
53 self.set_skillsets_info (docdata)
54
55 # set the additional information
56 self.set_additional_info (docdata)
57
58 # set the current document
59 self.currentfile = openfilename
60 self.ismodified = False
61
62 # set the window title
63 self.setWindowTitle ("BiaCV - " + self.currentfile)
64
65 # function to save a file as a new document
66 def on_file_save_as (self):
67 savefilename = PyQt4.QtGui.QFileDialog.getSaveFileName (self,
68 lang.SAVE_TITLE)
69
70 # if save file name is not none
71 if savefilename <> "":
72 mydata = self.get_document_data ()
73 mydata.save_data (savefilename)
74 self.ismodified = False
75 self.currentfile = savefilename
76 self.setWindowTitle ("BiaCV - " + self.currentfile)
77
78 # function to save a file
79 def on_file_save (self):
80 # only save modified file
81 if self.ismodified is False:
82 return
83
84 # if no current file get file name from file save dialog
85 if self.currentfile is None:
86 savefilename = PyQt4.QtGui.QFileDialog.getSaveFileName (self,
87 lang.SAVE_TITLE)
88
89 if savefilename <> "":
90 mydata = self.get_document_data ()
91 mydata.save_data (savefilename)
92 self.ismodified = False
93 self.currentfile = savefilename
94 self.setWindowTitle ("BiaCV - " + self.currentfile)
95 else:
96 mydata = self.get_document_data ()
97 mydata.save_data (self.currentfile)
98 self.ismodified = False
99
100 # function to set document data from the GUI
101 def get_document_data (self):
102 docdata = data.BiaCVData ()
103
104 # set the document title
105 docdata.set_document_title (unicode (self.title.text ().toUtf8 (), "utf-8"))
106
107 # get the marital status string from check box
108 if self.married.isChecked ():
109 maritalstatus = True
110 elif self.single.isChecked ():
111 maritalstatus = False
112 else:
113 maritalstatus = None
114
115 docdata.set_personal_info (
116 unicode (self.nametitle.lineEdit ().text ().toUtf8 (), "utf-8"),
117 unicode (self.firstname.text ().toUtf8 (), "utf-8"),
118 unicode (self.lastname.text ().toUtf8 (), "utf-8"),
119 unicode (self.dateofbirth.date().toString ("dd MMM, yyyy"), "utf-8"),
120 unicode (self.street.text ().toUtf8 (), "utf-8"),
121 unicode (self.area.text ().toUtf8 (), "utf-8"),
122 unicode (self.city.text ().toUtf8 (), "utf-8"),
123 unicode (self.areacode.text ().toUtf8 (), "utf-8"),
124 unicode (self.countrycode_landline.text ().toUtf8 (), "utf-8"),
125 unicode (self.telephone.text ().toUtf8 (), "utf-8"),
126 unicode (self.countrycode_mobile.text ().toUtf8 (), "utf-8"),
127 unicode (self.mobilenumber.text ().toUtf8 (), "utf-8"),
128 unicode (self.email.text ().toUtf8 (), "utf-8"),
129 maritalstatus
130 )
131 # get the list of educational qualifications from the treewidget
132 education = []
133 i = 0
134 while i < self.educationlist.topLevelItemCount ():
135 curitem = self.educationlist.topLevelItem (i)
136 curdict = {}
137 curdict["degree"] = unicode (curitem.text (0).toUtf8 (), "utf-8")
138 curdict["graduation"] = unicode (curitem.text (1).toUtf8 (), "utf-8")
139 curdict["institution"] = unicode (curitem.text (2).toUtf8 (), "utf-8")
140 curdict["university"] = unicode (curitem.text (3).toUtf8 (), "utf-8")
141 curdict["grade"] = unicode (curitem.text (4).toUtf8 (), "utf-8")
142 curdict["percentage"] = float (curitem.text (5))
143 education.append (curdict)
144 i += 1
145
146 # set the educational qualifications
147 docdata.set_educational_qualifications (education)
148
149 # get the list of professional history from the treewidget
150 professional = []
151 i = 0
152 while i < self.professionlist.topLevelItemCount ():
153 curitem = self.professionlist.topLevelItem (i)
154 curdict = {}
155 curdict["jobtitle"] = unicode (curitem.text (0).toUtf8 (), "utf-8")
156 curdict["joindate"] = unicode (curitem.text (1), "utf-8")
157 curdict["leavedate"] = unicode (curitem.text (2), "utf-8")
158 curdict["organization"] = unicode (curitem.text (3).toUtf8 (), "utf-8")
159 curdict["additionalinfo"] = unicode (curitem.text (4).toUtf8 (), "utf-8")
160 professional.append (curdict)
161 i += 1
162
163 # set the professional qualifications
164 docdata.set_professional_history (professional)
165
166 # set the career objectives
167 shorttermobjectives = unicode (self.shorttermcareer.toPlainText ().toUtf8 (), "utf-8").splitlines ()
168 longtermgoals = unicode (self.longtermgoals.toPlainText ().toUtf8 (), "utf-8").splitlines ()
169
170 docdata.set_career_objectives (shorttermobjectives, longtermgoals)
171
172 # set the skill sets
173 skills = []
174 i = 0
175 while i < self.skillslist.topLevelItemCount ():
176 curitem = self.skillslist.topLevelItem (i)
177 curdict = {}
178 curdict["skilltitle"] = unicode (curitem.text (0).toUtf8 (), "utf-8")
179 curdict["skilldesc"] = unicode (curitem.text (1).toUtf8 (), "utf-8")
180 skills.append (curdict)
181 i += 1
182 # set the list of skills
183 docdata.set_skillsets (skills)
184
185 # get the list of languages
186 langsknown = []
187 i = 0
188 while i < self.languageslist.topLevelItemCount ():
189 curitem = self.languageslist.topLevelItem (i)
190 curdict = {}
191 curdict["language"] = unicode (curitem.text (0).toUtf8 (), "utf-8")
192 curdict["canspeak" ] = (curitem.text (1) == "True")
193 curdict["canreadwrite"] = (curitem.text (2) == "True")
194 curdict["isproficient"] = (curitem.text (3) == "True")
195 langsknown.append (curdict)
196 i += 1
197
198 additionalinformation = unicode (self.additionalinformation.toPlainText ().toUtf8 (), "utf-8")
199
200 docdata.set_additional_information (langsknown, additionalinformation)
201
202 return docdata
203
204 # function to reset personal information data in the GUI
205 def reset_personal_info (self):
206 self.nametitle.setEditText ("")
207 self.firstname.setText ("")
208 self.lastname.setText ("")
209 self.dateofbirth.setDate (PyQt4.QtCore.QDate (1970, 1, 1))
210 self.street.setText ("")
211 self.area.setText ("")
212 self.city.setText ("")
213 self.countrycode_landline.setText ("")
214 self.telephone.setText ("")
215 self.countrycode_mobile.setText ("")
216 self.mobilenumber.setText ("")
217 self.email.setText ("")
218 self.areacode.setText ("")
219 self.unspecified.setChecked (True)
220
221 # function to set personal information data in the GUI from document data
222 def set_personal_info (self, docdata):
223 self.nametitle.setEditText (docdata.data["nametitle"])
224 self.firstname.setText (docdata.data["firstname"])
225 self.lastname.setText (docdata.data["lastname"])
226 self.dateofbirth.setDate (PyQt4.QtCore.QDate.fromString (docdata.data["dateofbirth"], "dd MMM, yyyy"))
227 self.street.setText (docdata.data["street"])
228 self.area.setText (docdata.data["area"])
229 self.city.setText (docdata.data["city"])
230 self.countrycode_landline.setText (docdata.data["countrycode_landline"])
231 self.telephone.setText (docdata.data["landline"])
232 self.countrycode_mobile.setText (docdata.data["countrycode_mobile"])
233 self.mobilenumber.setText (docdata.data["mobile"])
234 self.email.setText (docdata.data["email"])
235 self.areacode.setText (docdata.data["areacode"])
236 if docdata.data["maritalstatus"] is True:
237 self.married.setChecked (True)
238 elif docdata.data["maritalstatus"] is False:
239 self.single.setChecked (True)
240 else:
241 self.unspecified.setChecked (True)
242
243 # function to clear professional history in the GUI
244 def reset_professional_history (self):
245 self.reset_profession_fields ()
246 self.professionlist.clear ()
247
248 # function to set the professional history in the GUI from the document data
249 def set_professional_history (self, docdata):
250 # reset the professional history
251 self.reset_professional_history ()
252
253 # add the professional history items to list
254 for item in docdata.data["professionalhistory"]:
255 professionitem = PyQt4.QtGui.QTreeWidgetItem (
256 [
257 item["jobtitle"],
258 item["joindate"],
259 item["leavedate"],
260 item["organization"],
261 item["additionalinfo"]
262 ]
263 )
264 self.professionlist.addTopLevelItem (professionitem)
265
266 # function to clear educational qualifications in the GUI
267 def reset_educational_qualifications (self):
268 self.reset_education_fields ()
269 self.educationlist.clear ()
270
271 # function to set education qualifications in the GUI from document data
272 def set_educational_qualifications (self, docdata):
273 # reset the educational qualifications
274 self.reset_educational_qualifications ()
275
276 # add education items to list
277 for item in docdata.data["educationalqualifications"]:
278 educationitem = PyQt4.QtGui.QTreeWidgetItem (
279 [
280 item["degree"],
281 item["graduation"],
282 item["institution"],
283 item["university"],
284 item["grade"],
285 str (item["percentage"])
286 ]
287 )
288 self.educationlist.addTopLevelItem (educationitem)
289
290 # function to clear career objectives data in the GUI
291 def reset_career_objectives (self):
292 self.shorttermcareer.setPlainText ("")
293 self.longtermgoals.setPlainText ("")
294
295 # function to set career objectives data in the GUI from document data
296 def set_career_objectives (self, docdata):
297 self.shorttermcareer.setPlainText (u'\n'.join (docdata.data["shorttermobjectives"]))
298 self.longtermgoals.setPlainText (u'\n'.join (docdata.data["longtermgoals"]))
299
300 # function to clear skill sets data in the GUI
301 def reset_skillsets_info (self):
302 self.reset_skillset_fields ()
303 self.skillslist.clear ()
304
305 # function to set the skill sets data in the GUI from document data
306 def set_skillsets_info (self, docdata):
307 # clear the skill sets information
308 self.reset_skillsets_info ()
309
310 for item in docdata.data["skillsets"]:
311 skillitem = PyQt4.QtGui.QTreeWidgetItem (
312 [
313 item["skilltitle"],
314 item["skilldesc"]
315 ]
316 )
317 self.skillslist.addTopLevelItem (skillitem)
318
319
320 # function to clear additional information data in the GUI
321 def reset_additional_info (self):
322 self.reset_language_fields ()
323 self.languageslist.clear ()
324 self.additionalinformation.setPlainText ("")
325
326 # function to set additional information data in the GUI from the document data
327 def set_additional_info (self, docdata):
328 # clear the additional information
329 self.reset_additional_info ()
330
331 # set the languages list
332 for item in docdata.data["languagesknown"]:
333 langitem = PyQt4.QtGui.QTreeWidgetItem (
334 [
335 item["language"],
336 str (item["canspeak"]),
337 str (item["canreadwrite"]),
338 str (item["isproficient"])
339 ]
340 )
341 self.languageslist.addTopLevelItem (langitem)
342
343 self.additionalinformation.setPlainText (docdata.data["additionalinformation"])
344
345 # function to clear all the fields and reset them to defaults
346 def new_document (self):
347 # first clear the individual record fields in the tabs
348 self.reset_language_fields ()
349 self.reset_skillset_fields ()
350
351 # clear document data
352 self.title.setText ("")
353
354 self.reset_personal_info ()
355 self.reset_professional_history ()
356 self.reset_educational_qualifications ()
357 self.reset_career_objectives ()
358 self.reset_skillsets_info ()
359 self.reset_additional_info ()
360
361 # set the page to first page
362 self.pages.setCurrentIndex (0)
363
364 # set current file to none and modified to false
365 self.currentfile = None
366 self.ismodified = False
367
368 # set the window title
369 self.setWindowTitle ("BiaCV - untitled")
370
371 # file new action is triggered
372 def on_file_new (self):
373 # if the previous document is modified
374 # as if it should be discarded
375 if self.ismodified is True:
376 ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM,
377 lang.CONFIRM_DISCARD_SAVE,
378 PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
379 if ans == PyQt4.QtGui.QMessageBox.Yes:
380 self.new_document ()
381 # if not modified then simply create a new document
382 else:
383 self.new_document ()
384
385 # when the document is modified
386 def on_document_modified (self):
387 # set the document modified flag
388 self.ismodified = True
389
390 # update a language in the list of languages
391 def on_update_lang (self):
392 # get the selected language
393 selitems = self.languageslist.selectedItems ()
394 if selitems == []:
395 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_UPDATE, lang.ERROR_NO_SELECTION)
396 return
397 # check if the language string is not empty
398 if self.language.text () == "":
399 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_UPDATE, lang.ERROR_REQ_MISSING)
400 return
401 selitem = selitems[0]
402 selitem.setText (0, self.language.text ())
403 selitem.setText (1, str (self.canspeak.isChecked ()))
404 selitem.setText (2, str (self.canreadwrite.isChecked ()))
405 selitem.setText (3, str (self.isproficient.isChecked ()))
406
407 # modified the document
408 self.ismodified = True
409
410 # selecting a language from the list of languages
411 def on_select_lang (self):
412 # set the language fields from the selected item
413 self.set_language_fields ()
414
415 # delete a language from the list of languages known
416 def on_delete_lang (self):
417 # get selected language
418 selitems = self.languageslist.selectedItems ()
419 if selitems == []:
420 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_DELETE, lang.ERROR_REQ_MISSING)
421 return
422 # confirm
423 ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, lang.CONFIRM_DELETE,
424 PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
425 if ans == PyQt4.QtGui.QMessageBox.Yes:
426 for item in selitems:
427 self.languageslist.takeTopLevelItem (self.languageslist.indexOfTopLevelItem (item))
428
429 self.reset_language_fields ()
430 # set the modified flag
431 self.ismodified = True
432
433 # add a language to the list of languages known
434 def on_add_lang (self):
435 # check if the language is set
436 if self.language.text () == "":
437 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_ADD, lang.ERROR_REQ_MISSING)
438 return
439 langitem = PyQt4.QtGui.QTreeWidgetItem (
440 [
441 self.language.text (),
442 str (self.canspeak.isChecked ()),
443 str (self.canreadwrite.isChecked ()),
444 str (self.isproficient.isChecked ())
445 ]
446 )
447 self.languageslist.addTopLevelItem (langitem)
448 self.reset_language_fields ()
449
450 # set the modified flag
451 self.ismodified = True
452
453 # set the language fields from the selected item
454 def set_language_fields (self):
455 selitems = self.languageslist.selectedItems ()
456 if selitems == []:
457 return
458 selitem = selitems[0]
459 self.language.setText (selitem.text (0))
460 self.canspeak.setChecked (selitem.text (1) == "True")
461 self.canreadwrite.setChecked (selitem.text(2) == "True")
462 self.isproficient.setChecked (selitem.text(3) == "True")
463
464 # reset the language fields
465 def reset_language_fields (self):
466 self.language.setText ("")
467 self.canspeak.setChecked (True)
468 self.canreadwrite.setChecked (False)
469 self.isproficient.setChecked (False)
470
471 # update the skill set button event
472 def on_update_skill (self):
473 # get the selected item
474 selitems = self.skillslist.selectedItems ()
475 if selitems == []:
476 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_UPDATE, lang.ERROR_NO_SELECTION)
477 return
478 if self.skillsettitle.text () == "":
479 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_UPDATE, lang.ERROR_REQ_MISSING)
480 return
481 selitem = selitems[0]
482
483 selitem.setText (0, self.skillsettitle.text ())
484 selitem.setText (1, self.skilldescription.toPlainText ())
485 # set the modified flag
486 self.ismodified = True
487
488 # selecting a skill from the list event
489 def on_select_skill (self):
490 self.set_skill_fields ()
491
492 # set the skill fields from the selected skill from the list
493 def set_skill_fields (self):
494 # get the selected items
495 selitems = self.skillslist.selectedItems ()
496 if selitems == []:
497 return
498 selitem = selitems[0]
499 self.skillsettitle.setText (selitem.text (0))
500 self.skilldescription.setPlainText (selitem.text (1))
501
502 # delete skill set button is clicked
503 def on_delete_skill (self):
504 # get the selected items
505 selitems = self.skillslist.selectedItems ()
506 if selitems == []:
507 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_DELETE, lang.ERROR_NO_SELECTION)
508 return
509 # confirm
510 ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, lang.CONFIRM_DELETE,
511 PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
512 # answer is yes
513 if ans == PyQt4.QtGui.QMessageBox.Yes:
514 for item in selitems:
515 self.skillslist.takeTopLevelItem (self.skillslist.indexOfTopLevelItem (item))
516
517 self.reset_skillset_fields ()
518 # set the modified flag
519 self.ismodified = True
520
521 # add skill set button is clicked
522 def on_add_skill (self):
523 # if the skill title is blank
524 if self.skillsettitle.text () == "":
525 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_ADD, lang.ERROR_REQ_MISSING)
526 return
527 skillitem = PyQt4.QtGui.QTreeWidgetItem (
528 [
529 self.skillsettitle.text (),
530 self.skilldescription.toPlainText ()
531 ]
532 )
533 self.skillslist.addTopLevelItem (skillitem)
534 self.reset_skillset_fields ()
535 # set the modified flag
536 self.ismodified = True
537
538 # clear the skill set fields
539 def reset_skillset_fields (self):
540 self.skillsettitle.setText ("")
541 self.skilldescription.setPlainText ("")
542
543 # update professional history button is clicked
544 def on_update_profession (self):
545 # get the selected item
546 selitems = self.professionlist.selectedItems ()
547 if selitems == []:
548 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_UPDATE, lang.ERROR_NO_SELECTION)
549 return
550 selitem = selitems[0]
551 # if designation is not set
552 if self.designation.text () == "":
553 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_UPDATE, lang.ERROR_REQ_MISSING)
554 return
555 # if currently employed in that position, leaving date is to be disabled
556 # and set to "current"
557 if self.currentemployment.isChecked ():
558 leavedatestr = "current"
559 else:
560 # if the leaving date is < join date
561 if self.leavedate.date () < self.joindate.date ():
562 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_ADD, lang.ERROR_DATE)
563 return
564 leavedatestr = self.leavedate.date ().toString ("dd MMM, yyyy")
565
566 selitem.setText (0, self.designation.text ())
567 selitem.setText (1, self.joindate.date ().toString ("dd MMM, yyyy"))
568 selitem.setText (2, leavedatestr)
569 selitem.setText (3, self.organization.text ())
570 selitem.setText (4, self.additionalinfo.text ())
571 # set the modified flag
572 self.ismodified = True
573
574 # delete professional history button is clicked
575 def on_delete_profession (self):
576 # get the selected items
577 selitems = self.professionlist.selectedItems ()
578 if selitems == []:
579 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_DELETE, lang.ERROR_NO_SELECTION)
580 return
581 # confirm deletion
582 ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, lang.CONFIRM_DELETE,
583 PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
584 # if confirmed
585 if ans == PyQt4.QtGui.QMessageBox.Yes:
586 for item in selitems:
587 self.professionlist.takeTopLevelItem (self.professionlist.indexOfTopLevelItem (item))
588 self.reset_profession_fields ()
589 # set the modified flag
590 self.ismodified = True
591
592 # add professional history button is clicked
593 def on_add_profession (self):
594 if self.designation.text () == "":
595 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_ADD, lang.ERROR_REQ_MISSING)
596 return
597 # if currently employed in that position, leaving date is to be disabled
598 # and set to "current"
599 if self.currentemployment.isChecked ():
600 leavedatestr = "current"
601 else:
602 # if the leaving date is < join date
603 if self.leavedate.date () < self.joindate.date ():
604 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_ADD, lang.ERROR_DATE)
605 return
606 leavedatestr = self.leavedate.date ().toString ("dd MMM, yyyy")
607
608 professionitem = PyQt4.QtGui.QTreeWidgetItem (
609 [
610 self.designation.text (),
611 self.joindate.date ().toString ("dd MMM, yyyy"),
612 leavedatestr,
613 self.organization.text (),
614 self.additionalinfo.text ()
615 ]
616 )
617
618 self.professionlist.addTopLevelItem (professionitem)
619
620 self.reset_profession_fields ()
621 # set the modified flag
622 self.ismodified = True
623
624 # when selection of profession list is changed
625 def on_select_profession (self):
626 self.set_profession_fields ()
627
628 # set the profession fields from the selected item in profession list
629 def set_profession_fields (self):
630 selitems = self.professionlist.selectedItems ()
631 if selitems == []:
632 return
633 selitem = selitems[0]
634 self.designation.setText (selitem.text (0))
635 self.joindate.setDate (PyQt4.QtCore.QDate.fromString (selitem.text(1), "dd MMM, yyyy"))
636 if selitem.text (2) == "current":
637 self.leavedate.setEnabled (False)
638 self.currentemployment.setChecked (True)
639 else:
640 self.leavedate.setDate (PyQt4.QtCore.QDate.fromString (selitem.text (2), "dd MMM, yyyy"))
641 self.leavedate.setEnabled (True)
642 self.currentemployment.setChecked (False)
643
644 self.organization.setText (selitem.text (3))
645 self.additionalinfo.setText (selitem.text (4))
646
647 def reset_profession_fields (self):
648 self.designation.setText ("")
649 self.joindate.setDate (PyQt4.QtCore.QDate (2000, 1, 1))
650 self.leavedate.setDate (PyQt4.QtCore.QDate (2003, 1, 1))
651 self.currentemployment.setChecked (False)
652 self.organization.setText ("")
653 self.additionalinfo.setText ("")
654
655 # current employment check box is changed
656 def on_change_currentemployment (self, val):
657 if val == True:
658 self.leavedate.setEnabled (False)
659 else:
660 self.leavedate.setEnabled (True)
661
662 # delete educational qualification
663 def on_delete_education (self):
664 # get the selected items in the education list
665 selitems = self.educationlist.selectedItems ()
666 # if no items are selected
667 if selitems == []:
668 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_DELETE, lang.ERROR_NO_SELECTION)
669 # delete the items after confirmation
670 else:
671 ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, lang.CONFIRM_DELETE,
672 PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
673 if ans == PyQt4.QtGui.QMessageBox.Yes:
674 # remove the item selected
675 for item in selitems:
676 self.educationlist.takeTopLevelItem (self.educationlist.indexOfTopLevelItem (item))
677 self.reset_education_fields ()
678 # set the modified flag
679 self.ismodified = True
680
681 # selection is changed
682 def on_select_education (self):
683 self.set_education_fields ()
684
685 # update educational qualification button
686 def on_update_education (self):
687 selitems = self.educationlist.selectedItems ()
688 # if no item is selected
689 if selitems == []:
690 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_UPDATE, lang.ERROR_NO_SELECTION)
691 return
692 # if the qualification title is not set
693 if self.degree_name.text () == "":
694 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_UPDATE, lang.ERROR_REQ_MISSING)
695 return
696 selitem = selitems[0]
697
698 selitem.setText (0, self.degree_name.text ())
699 selitem.setText (1, self.yearofpassing.date ().toString ("MMM, yyyy"))
700 selitem.setText (2, self.institution.text ())
701 selitem.setText (3, self.university.text ())
702 selitem.setText (4, self.grade.text ())
703 selitem.setText (5, str (self.percentage.value ()))
704 # set the modified flag
705 self.ismodified = True
706
707 # add educational qualification button
708 def on_add_education (self):
709 # check if the qualification title is set
710 if self.degree_name.text () == "":
711 PyQt4.QtGui.QMessageBox.critical (self, lang.ERROR_ADD, lang.ERROR_REQ_MISSING)
712 return
713 educationitem = PyQt4.QtGui.QTreeWidgetItem ([
714 self.degree_name.text (),
715 self.yearofpassing.date ().toString ("MMM, yyyy"),
716 self.institution.text (),
717 self.university.text (),
718 self.grade.text (),
719 str (self.percentage.value ())
720 ])
721 self.educationlist.addTopLevelItem (educationitem)
722 # clear the fields
723 self.reset_education_fields ()
724 # set the modified flag
725 self.ismodified = True
726
727 # set fields in the education tab from current selected item
728 def set_education_fields (self):
729 selitems = self.educationlist.selectedItems ()
730 if selitems == []:
731 return
732 selitem = selitems[0]
733 # set the fields to the data in the selected item in the list
734 self.degree_name.setText (selitem.text (0))
735 self.yearofpassing.setDate (PyQt4.QtCore.QDate.fromString (selitem.text(1), "MMM, yyyy"))
736 self.institution.setText (selitem.text (2))
737 self.university.setText (selitem.text (3))
738 self.grade.setText (selitem.text(4))
739 self.percentage.setValue (self.percentage.valueFromText (selitem.text(5)))
740
741 # reset fields in the education tab
742 def reset_education_fields (self):
743 self.degree_name.setText ("")
744 self.yearofpassing.setDate (PyQt4.QtCore.QDate (1988, 1, 1))
745 self.institution.setText ("")
746 self.university.setText ("")
747 self.grade.setText ("")
748 self.percentage.setValue (50.0)
749