f33a265b3021c223a70adc707750ed1315ef7b36
1 # class for main window
4 import biacv_mainwindow_ui
as bui
6 class Biacv_mainwindow (PyQt4
.QtGui
.QMainWindow
, bui
.Ui_biacv_mainwindow
):
8 PyQt4
.QtGui
.QMainWindow
.__init
__ (self
)
10 self
.currentfile
= None
12 # add professional history button is clicked
13 def on_add_profession (self
):
14 if self
.designation
.text () == "":
15 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
18 if self
.currentemployment
.isChecked ():
19 leavedatestr
= "current"
21 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
23 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
25 self
.designation
.text (),
26 self
.joindate
.date ().toString ("dd MMM, yyyy"),
28 self
.organization
.text (),
29 self
.additionalinfo
.text ()
33 self
.professionlist
.addTopLevelItem (professionitem
)
35 self
.reset_profession_fields ()
37 def reset_profession_fields (self
):
38 self
.designation
.setText ("")
39 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
40 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
41 self
.currentemployment
.setChecked (False)
42 self
.organization
.setText ("")
43 self
.additionalinfo
.setText ("")
45 # current employment check box is changed
46 def on_change_currentemployment (self
, val
):
48 self
.leavedate
.setEnabled (False)
50 self
.leavedate
.setEnabled (True)
52 # delete educational qualification
53 def on_delete_education (self
):
54 # get the selected items in the education list
55 selitems
= self
.educationlist
.selectedItems ()
56 # if no items are selected
58 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
59 # delete the items after confirmation
61 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
62 "Are you sure you wish to delete selected item?",
63 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
64 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
65 # remove the item selected
67 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
68 self
.reset_education_fields ()
70 # selection is changed
71 def on_select_education (self
):
72 self
.set_education_fields ()
74 # update educational qualification button
75 def on_update_education (self
):
76 selitems
= self
.educationlist
.selectedItems ()
77 # if no item is selected
79 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected")
81 # if the qualification title is not set
82 if self
.degree_name
.text () == "":
83 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
87 selitem
.setText (0, self
.degree_name
.text ())
88 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
89 selitem
.setText (2, self
.institution
.text ())
90 selitem
.setText (3, self
.university
.text ())
91 selitem
.setText (4, self
.grade
.text ())
92 selitem
.setText (5, str (self
.percentage
.value ()))
94 # add educational qualification button
95 def on_add_education (self
):
96 # check if the qualification title is set
97 if self
.degree_name
.text () == "":
98 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required fields is missing.")
100 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
101 self
.degree_name
.text (),
102 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
103 self
.institution
.text (),
104 self
.university
.text (),
106 str (self
.percentage
.value ())
108 self
.educationlist
.addTopLevelItem (educationitem
)
110 self
.reset_education_fields ()
112 # set fields in the education tab from current selected item
113 def set_education_fields (self
):
114 selitems
= self
.educationlist
.selectedItems ()
117 selitem
= selitems
[0]
118 # set the fields to the data in the selected item in the list
119 self
.degree_name
.setText (selitem
.text (0))
120 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
121 self
.institution
.setText (selitem
.text (2))
122 self
.university
.setText (selitem
.text (3))
123 self
.grade
.setText (selitem
.text(4))
124 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
126 # reset fields in the education tab
127 def reset_education_fields (self
):
128 self
.degree_name
.setText ("")
129 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
130 self
.institution
.setText ("")
131 self
.university
.setText ("")
132 self
.grade
.setText ("")
133 self
.percentage
.setValue (50.0)