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 # update the skill set button event
13 def on_update_skill (self
):
14 # get the selected item
15 selitems
= self
.skillslist
.selectedItems ()
17 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected.")
19 if self
.skillsettitle
.text () == "":
20 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
24 selitem
.setText (0, self
.skillsettitle
.text ())
25 selitem
.setText (1, self
.skilldescription
.toPlainText ())
27 # selecting a skill from the list event
28 def on_select_skill (self
):
29 self
.set_skill_fields ()
31 # set the skill fields from the selected skill from the list
32 def set_skill_fields (self
):
33 # get the selected items
34 selitems
= self
.skillslist
.selectedItems ()
38 self
.skillsettitle
.setText (selitem
.text (0))
39 self
.skilldescription
.setPlainText (selitem
.text (1))
41 # delete skill set button is clicked
42 def on_delete_skill (self
):
43 # get the selected items
44 selitems
= self
.skillslist
.selectedItems ()
46 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
49 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
50 "Are you sure you wish to delete the selected item?",
51 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
53 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
55 self
.skillslist
.takeTopLevelItem (self
.skillslist
.indexOfTopLevelItem (item
))
57 self
.reset_skillset_fields ()
59 # add skill set button is clicked
60 def on_add_skill (self
):
61 # if the skill title is blank
62 if self
.skillsettitle
.text () == "":
63 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
65 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
67 self
.skillsettitle
.text (),
68 self
.skilldescription
.toPlainText ()
71 self
.skillslist
.addTopLevelItem (skillitem
)
72 self
.reset_skillset_fields ()
74 # clear the skill set fields
75 def reset_skillset_fields (self
):
76 self
.skillsettitle
.setText ("")
77 self
.skilldescription
.setPlainText ("")
79 # update professional history button is clicked
80 def on_update_profession (self
):
81 # get the selected item
82 selitems
= self
.professionlist
.selectedItems ()
84 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected.")
87 # if designation is not set
88 if self
.designation
.text () == "":
89 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
91 # if currently employed in that position, leaving date is to be disabled
92 # and set to "current"
93 if self
.currentemployment
.isChecked ():
94 leavedatestr
= "current"
96 # if the leaving date is < join date
97 if self
.leavedate
.date () < self
.joindate
.date ():
98 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add",
99 "Leaving date cannot be earlier than join date.")
101 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
103 selitem
.setText (0, self
.designation
.text ())
104 selitem
.setText (1, self
.joindate
.date ().toString ("dd MMM, yyyy"))
105 selitem
.setText (2, leavedatestr
)
106 selitem
.setText (3, self
.organization
.text ())
107 selitem
.setText (4, self
.additionalinfo
.text ())
109 # delete professional history button is clicked
110 def on_delete_profession (self
):
111 # get the selected items
112 selitems
= self
.professionlist
.selectedItems ()
114 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No item selected.")
117 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
118 "Are you sure you wish to delete the selected item?",
119 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
121 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
122 for item
in selitems
:
123 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
124 self
.reset_profession_fields ()
126 # add professional history button is clicked
127 def on_add_profession (self
):
128 if self
.designation
.text () == "":
129 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
131 # if currently employed in that position, leaving date is to be disabled
132 # and set to "current"
133 if self
.currentemployment
.isChecked ():
134 leavedatestr
= "current"
136 # if the leaving date is < join date
137 if self
.leavedate
.date () < self
.joindate
.date ():
138 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add",
139 "Leaving date cannot be earlier than join date.")
141 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
143 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
145 self
.designation
.text (),
146 self
.joindate
.date ().toString ("dd MMM, yyyy"),
148 self
.organization
.text (),
149 self
.additionalinfo
.text ()
153 self
.professionlist
.addTopLevelItem (professionitem
)
155 self
.reset_profession_fields ()
157 # when selection of profession list is changed
158 def on_select_profession (self
):
159 self
.set_profession_fields ()
161 # set the profession fields from the selected item in profession list
162 def set_profession_fields (self
):
163 selitems
= self
.professionlist
.selectedItems ()
166 selitem
= selitems
[0]
167 self
.designation
.setText (selitem
.text (0))
168 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
169 if selitem
.text (2) == "current":
170 self
.leavedate
.setEnabled (False)
171 self
.currentemployment
.setChecked (True)
173 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
174 self
.leavedate
.setEnabled (True)
175 self
.currentemployment
.setChecked (False)
177 self
.organization
.setText (selitem
.text (3))
178 self
.additionalinfo
.setText (selitem
.text (4))
180 def reset_profession_fields (self
):
181 self
.designation
.setText ("")
182 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
183 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
184 self
.currentemployment
.setChecked (False)
185 self
.organization
.setText ("")
186 self
.additionalinfo
.setText ("")
188 # current employment check box is changed
189 def on_change_currentemployment (self
, val
):
191 self
.leavedate
.setEnabled (False)
193 self
.leavedate
.setEnabled (True)
195 # delete educational qualification
196 def on_delete_education (self
):
197 # get the selected items in the education list
198 selitems
= self
.educationlist
.selectedItems ()
199 # if no items are selected
201 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
202 # delete the items after confirmation
204 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
205 "Are you sure you wish to delete selected item?",
206 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
207 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
208 # remove the item selected
209 for item
in selitems
:
210 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
211 self
.reset_education_fields ()
213 # selection is changed
214 def on_select_education (self
):
215 self
.set_education_fields ()
217 # update educational qualification button
218 def on_update_education (self
):
219 selitems
= self
.educationlist
.selectedItems ()
220 # if no item is selected
222 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected")
224 # if the qualification title is not set
225 if self
.degree_name
.text () == "":
226 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
228 selitem
= selitems
[0]
230 selitem
.setText (0, self
.degree_name
.text ())
231 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
232 selitem
.setText (2, self
.institution
.text ())
233 selitem
.setText (3, self
.university
.text ())
234 selitem
.setText (4, self
.grade
.text ())
235 selitem
.setText (5, str (self
.percentage
.value ()))
237 # add educational qualification button
238 def on_add_education (self
):
239 # check if the qualification title is set
240 if self
.degree_name
.text () == "":
241 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required fields is missing.")
243 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
244 self
.degree_name
.text (),
245 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
246 self
.institution
.text (),
247 self
.university
.text (),
249 str (self
.percentage
.value ())
251 self
.educationlist
.addTopLevelItem (educationitem
)
253 self
.reset_education_fields ()
255 # set fields in the education tab from current selected item
256 def set_education_fields (self
):
257 selitems
= self
.educationlist
.selectedItems ()
260 selitem
= selitems
[0]
261 # set the fields to the data in the selected item in the list
262 self
.degree_name
.setText (selitem
.text (0))
263 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
264 self
.institution
.setText (selitem
.text (2))
265 self
.university
.setText (selitem
.text (3))
266 self
.grade
.setText (selitem
.text(4))
267 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
269 # reset fields in the education tab
270 def reset_education_fields (self
):
271 self
.degree_name
.setText ("")
272 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
273 self
.institution
.setText ("")
274 self
.university
.setText ("")
275 self
.grade
.setText ("")
276 self
.percentage
.setValue (50.0)