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 a language to the list of languages known
13 def on_add_lang (self
):
14 # check if the language is set
15 if self
.language
.text () == "":
16 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
18 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
20 self
.language
.text (),
21 str (self
.canspeak
.isChecked ()),
22 str (self
.canreadwrite
.isChecked ()),
23 str (self
.isproficient
.isChecked ())
26 self
.languageslist
.addTopLevelItem (langitem
)
27 self
.reset_language_fields ()
29 # reset the language fields
30 def reset_language_fields (self
):
31 self
.language
.setText ("")
32 self
.canspeak
.setChecked (True)
33 self
.canreadwrite
.setChecked (False)
34 self
.isproficient
.setChecked (False)
36 # update the skill set button event
37 def on_update_skill (self
):
38 # get the selected item
39 selitems
= self
.skillslist
.selectedItems ()
41 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected.")
43 if self
.skillsettitle
.text () == "":
44 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
48 selitem
.setText (0, self
.skillsettitle
.text ())
49 selitem
.setText (1, self
.skilldescription
.toPlainText ())
51 # selecting a skill from the list event
52 def on_select_skill (self
):
53 self
.set_skill_fields ()
55 # set the skill fields from the selected skill from the list
56 def set_skill_fields (self
):
57 # get the selected items
58 selitems
= self
.skillslist
.selectedItems ()
62 self
.skillsettitle
.setText (selitem
.text (0))
63 self
.skilldescription
.setPlainText (selitem
.text (1))
65 # delete skill set button is clicked
66 def on_delete_skill (self
):
67 # get the selected items
68 selitems
= self
.skillslist
.selectedItems ()
70 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
73 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
74 "Are you sure you wish to delete the selected item?",
75 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
77 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
79 self
.skillslist
.takeTopLevelItem (self
.skillslist
.indexOfTopLevelItem (item
))
81 self
.reset_skillset_fields ()
83 # add skill set button is clicked
84 def on_add_skill (self
):
85 # if the skill title is blank
86 if self
.skillsettitle
.text () == "":
87 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
89 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
91 self
.skillsettitle
.text (),
92 self
.skilldescription
.toPlainText ()
95 self
.skillslist
.addTopLevelItem (skillitem
)
96 self
.reset_skillset_fields ()
98 # clear the skill set fields
99 def reset_skillset_fields (self
):
100 self
.skillsettitle
.setText ("")
101 self
.skilldescription
.setPlainText ("")
103 # update professional history button is clicked
104 def on_update_profession (self
):
105 # get the selected item
106 selitems
= self
.professionlist
.selectedItems ()
108 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected.")
110 selitem
= selitems
[0]
111 # if designation is not set
112 if self
.designation
.text () == "":
113 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
115 # if currently employed in that position, leaving date is to be disabled
116 # and set to "current"
117 if self
.currentemployment
.isChecked ():
118 leavedatestr
= "current"
120 # if the leaving date is < join date
121 if self
.leavedate
.date () < self
.joindate
.date ():
122 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add",
123 "Leaving date cannot be earlier than join date.")
125 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
127 selitem
.setText (0, self
.designation
.text ())
128 selitem
.setText (1, self
.joindate
.date ().toString ("dd MMM, yyyy"))
129 selitem
.setText (2, leavedatestr
)
130 selitem
.setText (3, self
.organization
.text ())
131 selitem
.setText (4, self
.additionalinfo
.text ())
133 # delete professional history button is clicked
134 def on_delete_profession (self
):
135 # get the selected items
136 selitems
= self
.professionlist
.selectedItems ()
138 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No item selected.")
141 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
142 "Are you sure you wish to delete the selected item?",
143 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
145 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
146 for item
in selitems
:
147 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
148 self
.reset_profession_fields ()
150 # add professional history button is clicked
151 def on_add_profession (self
):
152 if self
.designation
.text () == "":
153 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
155 # if currently employed in that position, leaving date is to be disabled
156 # and set to "current"
157 if self
.currentemployment
.isChecked ():
158 leavedatestr
= "current"
160 # if the leaving date is < join date
161 if self
.leavedate
.date () < self
.joindate
.date ():
162 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add",
163 "Leaving date cannot be earlier than join date.")
165 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
167 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
169 self
.designation
.text (),
170 self
.joindate
.date ().toString ("dd MMM, yyyy"),
172 self
.organization
.text (),
173 self
.additionalinfo
.text ()
177 self
.professionlist
.addTopLevelItem (professionitem
)
179 self
.reset_profession_fields ()
181 # when selection of profession list is changed
182 def on_select_profession (self
):
183 self
.set_profession_fields ()
185 # set the profession fields from the selected item in profession list
186 def set_profession_fields (self
):
187 selitems
= self
.professionlist
.selectedItems ()
190 selitem
= selitems
[0]
191 self
.designation
.setText (selitem
.text (0))
192 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
193 if selitem
.text (2) == "current":
194 self
.leavedate
.setEnabled (False)
195 self
.currentemployment
.setChecked (True)
197 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
198 self
.leavedate
.setEnabled (True)
199 self
.currentemployment
.setChecked (False)
201 self
.organization
.setText (selitem
.text (3))
202 self
.additionalinfo
.setText (selitem
.text (4))
204 def reset_profession_fields (self
):
205 self
.designation
.setText ("")
206 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
207 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
208 self
.currentemployment
.setChecked (False)
209 self
.organization
.setText ("")
210 self
.additionalinfo
.setText ("")
212 # current employment check box is changed
213 def on_change_currentemployment (self
, val
):
215 self
.leavedate
.setEnabled (False)
217 self
.leavedate
.setEnabled (True)
219 # delete educational qualification
220 def on_delete_education (self
):
221 # get the selected items in the education list
222 selitems
= self
.educationlist
.selectedItems ()
223 # if no items are selected
225 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
226 # delete the items after confirmation
228 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
229 "Are you sure you wish to delete selected item?",
230 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
231 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
232 # remove the item selected
233 for item
in selitems
:
234 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
235 self
.reset_education_fields ()
237 # selection is changed
238 def on_select_education (self
):
239 self
.set_education_fields ()
241 # update educational qualification button
242 def on_update_education (self
):
243 selitems
= self
.educationlist
.selectedItems ()
244 # if no item is selected
246 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected")
248 # if the qualification title is not set
249 if self
.degree_name
.text () == "":
250 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
252 selitem
= selitems
[0]
254 selitem
.setText (0, self
.degree_name
.text ())
255 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
256 selitem
.setText (2, self
.institution
.text ())
257 selitem
.setText (3, self
.university
.text ())
258 selitem
.setText (4, self
.grade
.text ())
259 selitem
.setText (5, str (self
.percentage
.value ()))
261 # add educational qualification button
262 def on_add_education (self
):
263 # check if the qualification title is set
264 if self
.degree_name
.text () == "":
265 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required fields is missing.")
267 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
268 self
.degree_name
.text (),
269 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
270 self
.institution
.text (),
271 self
.university
.text (),
273 str (self
.percentage
.value ())
275 self
.educationlist
.addTopLevelItem (educationitem
)
277 self
.reset_education_fields ()
279 # set fields in the education tab from current selected item
280 def set_education_fields (self
):
281 selitems
= self
.educationlist
.selectedItems ()
284 selitem
= selitems
[0]
285 # set the fields to the data in the selected item in the list
286 self
.degree_name
.setText (selitem
.text (0))
287 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
288 self
.institution
.setText (selitem
.text (2))
289 self
.university
.setText (selitem
.text (3))
290 self
.grade
.setText (selitem
.text(4))
291 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
293 # reset fields in the education tab
294 def reset_education_fields (self
):
295 self
.degree_name
.setText ("")
296 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
297 self
.institution
.setText ("")
298 self
.university
.setText ("")
299 self
.grade
.setText ("")
300 self
.percentage
.setValue (50.0)