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 # delete professional history button is clicked
13 def on_delete_profession (self
):
14 # get the selected items
15 selitems
= self
.professionlist
.selectedItems ()
17 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No item selected.")
20 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
21 "Are you sure you wish to delete the selected item?",
22 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
24 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
26 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
27 self
.reset_profession_fields ()
29 # add professional history button is clicked
30 def on_add_profession (self
):
31 if self
.designation
.text () == "":
32 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
35 if self
.currentemployment
.isChecked ():
36 leavedatestr
= "current"
38 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
40 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
42 self
.designation
.text (),
43 self
.joindate
.date ().toString ("dd MMM, yyyy"),
45 self
.organization
.text (),
46 self
.additionalinfo
.text ()
50 self
.professionlist
.addTopLevelItem (professionitem
)
52 self
.reset_profession_fields ()
54 # when selection of profession list is changed
55 def on_select_profession (self
):
56 self
.set_profession_fields ()
58 # set the profession fields from the selected item in profession list
59 def set_profession_fields (self
):
60 selitems
= self
.professionlist
.selectedItems ()
64 self
.designation
.setText (selitem
.text (0))
65 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
66 if selitem
.text (2) == "current":
67 self
.leavedate
.setEnabled (False)
68 self
.currentemployment
.setChecked (True)
70 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
71 self
.leavedate
.setEnabled (True)
72 self
.currentemployment
.setChecked (False)
74 self
.organization
.setText (selitem
.text (3))
75 self
.additionalinfo
.setText (selitem
.text (4))
77 def reset_profession_fields (self
):
78 self
.designation
.setText ("")
79 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
80 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
81 self
.currentemployment
.setChecked (False)
82 self
.organization
.setText ("")
83 self
.additionalinfo
.setText ("")
85 # current employment check box is changed
86 def on_change_currentemployment (self
, val
):
88 self
.leavedate
.setEnabled (False)
90 self
.leavedate
.setEnabled (True)
92 # delete educational qualification
93 def on_delete_education (self
):
94 # get the selected items in the education list
95 selitems
= self
.educationlist
.selectedItems ()
96 # if no items are selected
98 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
99 # delete the items after confirmation
101 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
102 "Are you sure you wish to delete selected item?",
103 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
104 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
105 # remove the item selected
106 for item
in selitems
:
107 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
108 self
.reset_education_fields ()
110 # selection is changed
111 def on_select_education (self
):
112 self
.set_education_fields ()
114 # update educational qualification button
115 def on_update_education (self
):
116 selitems
= self
.educationlist
.selectedItems ()
117 # if no item is selected
119 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected")
121 # if the qualification title is not set
122 if self
.degree_name
.text () == "":
123 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
125 selitem
= selitems
[0]
127 selitem
.setText (0, self
.degree_name
.text ())
128 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
129 selitem
.setText (2, self
.institution
.text ())
130 selitem
.setText (3, self
.university
.text ())
131 selitem
.setText (4, self
.grade
.text ())
132 selitem
.setText (5, str (self
.percentage
.value ()))
134 # add educational qualification button
135 def on_add_education (self
):
136 # check if the qualification title is set
137 if self
.degree_name
.text () == "":
138 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required fields is missing.")
140 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
141 self
.degree_name
.text (),
142 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
143 self
.institution
.text (),
144 self
.university
.text (),
146 str (self
.percentage
.value ())
148 self
.educationlist
.addTopLevelItem (educationitem
)
150 self
.reset_education_fields ()
152 # set fields in the education tab from current selected item
153 def set_education_fields (self
):
154 selitems
= self
.educationlist
.selectedItems ()
157 selitem
= selitems
[0]
158 # set the fields to the data in the selected item in the list
159 self
.degree_name
.setText (selitem
.text (0))
160 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
161 self
.institution
.setText (selitem
.text (2))
162 self
.university
.setText (selitem
.text (3))
163 self
.grade
.setText (selitem
.text(4))
164 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
166 # reset fields in the education tab
167 def reset_education_fields (self
):
168 self
.degree_name
.setText ("")
169 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
170 self
.institution
.setText ("")
171 self
.university
.setText ("")
172 self
.grade
.setText ("")
173 self
.percentage
.setValue (50.0)