2 # class for main window
5 import biacv_mainwindow_ui
as bui
7 class Biacv_mainwindow (PyQt4
.QtGui
.QMainWindow
, bui
.Ui_biacv_mainwindow
):
9 PyQt4
.QtGui
.QMainWindow
.__init
__ (self
)
11 self
.currentfile
= None
13 # update a language in the list of languages
14 def on_update_lang (self
):
15 # get the selected language
16 selitems
= self
.languageslist
.selectedItems ()
18 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected.")
20 # check if the language string is not empty
21 if self
.language
.text () == "":
22 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
25 selitem
.setText (0, self
.language
.text ())
26 selitem
.setText (1, str (self
.canspeak
.isChecked ()))
27 selitem
.setText (2, str (self
.canreadwrite
.isChecked ()))
28 selitem
.setText (3, str (self
.isproficient
.isChecked ()))
30 # selecting a language from the list of languages
31 def on_select_lang (self
):
32 # set the language fields from the selected item
33 self
.set_language_fields ()
35 # delete a language from the list of languages known
36 def on_delete_lang (self
):
37 # get selected language
38 selitems
= self
.languageslist
.selectedItems ()
40 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
43 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
44 "Are you sure you wish to delete the selected item?",
45 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
46 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
48 self
.languageslist
.takeTopLevelItem (self
.languageslist
.indexOfTopLevelItem (item
))
50 self
.reset_language_fields ()
52 # add a language to the list of languages known
53 def on_add_lang (self
):
54 # check if the language is set
55 if self
.language
.text () == "":
56 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
58 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
60 self
.language
.text (),
61 str (self
.canspeak
.isChecked ()),
62 str (self
.canreadwrite
.isChecked ()),
63 str (self
.isproficient
.isChecked ())
66 self
.languageslist
.addTopLevelItem (langitem
)
67 self
.reset_language_fields ()
69 # set the language fields from the selected item
70 def set_language_fields (self
):
71 selitems
= self
.languageslist
.selectedItems ()
75 self
.language
.setText (selitem
.text (0))
76 self
.canspeak
.setChecked (selitem
.text (1) == "True")
77 self
.canreadwrite
.setChecked (selitem
.text(2) == "True")
78 self
.isproficient
.setChecked (selitem
.text(3) == "True")
80 # reset the language fields
81 def reset_language_fields (self
):
82 self
.language
.setText ("")
83 self
.canspeak
.setChecked (True)
84 self
.canreadwrite
.setChecked (False)
85 self
.isproficient
.setChecked (False)
87 # update the skill set button event
88 def on_update_skill (self
):
89 # get the selected item
90 selitems
= self
.skillslist
.selectedItems ()
92 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected.")
94 if self
.skillsettitle
.text () == "":
95 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
99 selitem
.setText (0, self
.skillsettitle
.text ())
100 selitem
.setText (1, self
.skilldescription
.toPlainText ())
102 # selecting a skill from the list event
103 def on_select_skill (self
):
104 self
.set_skill_fields ()
106 # set the skill fields from the selected skill from the list
107 def set_skill_fields (self
):
108 # get the selected items
109 selitems
= self
.skillslist
.selectedItems ()
112 selitem
= selitems
[0]
113 self
.skillsettitle
.setText (selitem
.text (0))
114 self
.skilldescription
.setPlainText (selitem
.text (1))
116 # delete skill set button is clicked
117 def on_delete_skill (self
):
118 # get the selected items
119 selitems
= self
.skillslist
.selectedItems ()
121 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
124 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
125 "Are you sure you wish to delete the selected item?",
126 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
128 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
129 for item
in selitems
:
130 self
.skillslist
.takeTopLevelItem (self
.skillslist
.indexOfTopLevelItem (item
))
132 self
.reset_skillset_fields ()
134 # add skill set button is clicked
135 def on_add_skill (self
):
136 # if the skill title is blank
137 if self
.skillsettitle
.text () == "":
138 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
140 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
142 self
.skillsettitle
.text (),
143 self
.skilldescription
.toPlainText ()
146 self
.skillslist
.addTopLevelItem (skillitem
)
147 self
.reset_skillset_fields ()
149 # clear the skill set fields
150 def reset_skillset_fields (self
):
151 self
.skillsettitle
.setText ("")
152 self
.skilldescription
.setPlainText ("")
154 # update professional history button is clicked
155 def on_update_profession (self
):
156 # get the selected item
157 selitems
= self
.professionlist
.selectedItems ()
159 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected.")
161 selitem
= selitems
[0]
162 # if designation is not set
163 if self
.designation
.text () == "":
164 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
166 # if currently employed in that position, leaving date is to be disabled
167 # and set to "current"
168 if self
.currentemployment
.isChecked ():
169 leavedatestr
= "current"
171 # if the leaving date is < join date
172 if self
.leavedate
.date () < self
.joindate
.date ():
173 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add",
174 "Leaving date cannot be earlier than join date.")
176 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
178 selitem
.setText (0, self
.designation
.text ())
179 selitem
.setText (1, self
.joindate
.date ().toString ("dd MMM, yyyy"))
180 selitem
.setText (2, leavedatestr
)
181 selitem
.setText (3, self
.organization
.text ())
182 selitem
.setText (4, self
.additionalinfo
.text ())
184 # delete professional history button is clicked
185 def on_delete_profession (self
):
186 # get the selected items
187 selitems
= self
.professionlist
.selectedItems ()
189 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No item selected.")
192 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
193 "Are you sure you wish to delete the selected item?",
194 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
196 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
197 for item
in selitems
:
198 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
199 self
.reset_profession_fields ()
201 # add professional history button is clicked
202 def on_add_profession (self
):
203 if self
.designation
.text () == "":
204 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
206 # if currently employed in that position, leaving date is to be disabled
207 # and set to "current"
208 if self
.currentemployment
.isChecked ():
209 leavedatestr
= "current"
211 # if the leaving date is < join date
212 if self
.leavedate
.date () < self
.joindate
.date ():
213 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add",
214 "Leaving date cannot be earlier than join date.")
216 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
218 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
220 self
.designation
.text (),
221 self
.joindate
.date ().toString ("dd MMM, yyyy"),
223 self
.organization
.text (),
224 self
.additionalinfo
.text ()
228 self
.professionlist
.addTopLevelItem (professionitem
)
230 self
.reset_profession_fields ()
232 # when selection of profession list is changed
233 def on_select_profession (self
):
234 self
.set_profession_fields ()
236 # set the profession fields from the selected item in profession list
237 def set_profession_fields (self
):
238 selitems
= self
.professionlist
.selectedItems ()
241 selitem
= selitems
[0]
242 self
.designation
.setText (selitem
.text (0))
243 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
244 if selitem
.text (2) == "current":
245 self
.leavedate
.setEnabled (False)
246 self
.currentemployment
.setChecked (True)
248 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
249 self
.leavedate
.setEnabled (True)
250 self
.currentemployment
.setChecked (False)
252 self
.organization
.setText (selitem
.text (3))
253 self
.additionalinfo
.setText (selitem
.text (4))
255 def reset_profession_fields (self
):
256 self
.designation
.setText ("")
257 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
258 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
259 self
.currentemployment
.setChecked (False)
260 self
.organization
.setText ("")
261 self
.additionalinfo
.setText ("")
263 # current employment check box is changed
264 def on_change_currentemployment (self
, val
):
266 self
.leavedate
.setEnabled (False)
268 self
.leavedate
.setEnabled (True)
270 # delete educational qualification
271 def on_delete_education (self
):
272 # get the selected items in the education list
273 selitems
= self
.educationlist
.selectedItems ()
274 # if no items are selected
276 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
277 # delete the items after confirmation
279 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
280 "Are you sure you wish to delete selected item?",
281 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
282 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
283 # remove the item selected
284 for item
in selitems
:
285 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
286 self
.reset_education_fields ()
288 # selection is changed
289 def on_select_education (self
):
290 self
.set_education_fields ()
292 # update educational qualification button
293 def on_update_education (self
):
294 selitems
= self
.educationlist
.selectedItems ()
295 # if no item is selected
297 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected")
299 # if the qualification title is not set
300 if self
.degree_name
.text () == "":
301 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
303 selitem
= selitems
[0]
305 selitem
.setText (0, self
.degree_name
.text ())
306 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
307 selitem
.setText (2, self
.institution
.text ())
308 selitem
.setText (3, self
.university
.text ())
309 selitem
.setText (4, self
.grade
.text ())
310 selitem
.setText (5, str (self
.percentage
.value ()))
312 # add educational qualification button
313 def on_add_education (self
):
314 # check if the qualification title is set
315 if self
.degree_name
.text () == "":
316 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required fields is missing.")
318 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
319 self
.degree_name
.text (),
320 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
321 self
.institution
.text (),
322 self
.university
.text (),
324 str (self
.percentage
.value ())
326 self
.educationlist
.addTopLevelItem (educationitem
)
328 self
.reset_education_fields ()
330 # set fields in the education tab from current selected item
331 def set_education_fields (self
):
332 selitems
= self
.educationlist
.selectedItems ()
335 selitem
= selitems
[0]
336 # set the fields to the data in the selected item in the list
337 self
.degree_name
.setText (selitem
.text (0))
338 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
339 self
.institution
.setText (selitem
.text (2))
340 self
.university
.setText (selitem
.text (3))
341 self
.grade
.setText (selitem
.text(4))
342 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
344 # reset fields in the education tab
345 def reset_education_fields (self
):
346 self
.degree_name
.setText ("")
347 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
348 self
.institution
.setText ("")
349 self
.university
.setText ("")
350 self
.grade
.setText ("")
351 self
.percentage
.setValue (50.0)