8c3b13222a487449f2fd940af4eaa0e829761dcb
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 a language from the list of languages known
13 def on_delete_lang (self
):
14 # get selected language
15 selitems
= self
.languageslist
.selectedItems ()
17 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items 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
)
23 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
25 self
.languageslist
.takeTopLevelItem (self
.languageslist
.indexOfTopLevelItem (item
))
27 self
.reset_language_fields ()
29 # add a language to the list of languages known
30 def on_add_lang (self
):
31 # check if the language is set
32 if self
.language
.text () == "":
33 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
35 langitem
= PyQt4
.QtGui
.QTreeWidgetItem (
37 self
.language
.text (),
38 str (self
.canspeak
.isChecked ()),
39 str (self
.canreadwrite
.isChecked ()),
40 str (self
.isproficient
.isChecked ())
43 self
.languageslist
.addTopLevelItem (langitem
)
44 self
.reset_language_fields ()
46 # reset the language fields
47 def reset_language_fields (self
):
48 self
.language
.setText ("")
49 self
.canspeak
.setChecked (True)
50 self
.canreadwrite
.setChecked (False)
51 self
.isproficient
.setChecked (False)
53 # update the skill set button event
54 def on_update_skill (self
):
55 # get the selected item
56 selitems
= self
.skillslist
.selectedItems ()
58 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected.")
60 if self
.skillsettitle
.text () == "":
61 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
65 selitem
.setText (0, self
.skillsettitle
.text ())
66 selitem
.setText (1, self
.skilldescription
.toPlainText ())
68 # selecting a skill from the list event
69 def on_select_skill (self
):
70 self
.set_skill_fields ()
72 # set the skill fields from the selected skill from the list
73 def set_skill_fields (self
):
74 # get the selected items
75 selitems
= self
.skillslist
.selectedItems ()
79 self
.skillsettitle
.setText (selitem
.text (0))
80 self
.skilldescription
.setPlainText (selitem
.text (1))
82 # delete skill set button is clicked
83 def on_delete_skill (self
):
84 # get the selected items
85 selitems
= self
.skillslist
.selectedItems ()
87 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
90 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
91 "Are you sure you wish to delete the selected item?",
92 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
94 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
96 self
.skillslist
.takeTopLevelItem (self
.skillslist
.indexOfTopLevelItem (item
))
98 self
.reset_skillset_fields ()
100 # add skill set button is clicked
101 def on_add_skill (self
):
102 # if the skill title is blank
103 if self
.skillsettitle
.text () == "":
104 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
106 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
108 self
.skillsettitle
.text (),
109 self
.skilldescription
.toPlainText ()
112 self
.skillslist
.addTopLevelItem (skillitem
)
113 self
.reset_skillset_fields ()
115 # clear the skill set fields
116 def reset_skillset_fields (self
):
117 self
.skillsettitle
.setText ("")
118 self
.skilldescription
.setPlainText ("")
120 # update professional history button is clicked
121 def on_update_profession (self
):
122 # get the selected item
123 selitems
= self
.professionlist
.selectedItems ()
125 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected.")
127 selitem
= selitems
[0]
128 # if designation is not set
129 if self
.designation
.text () == "":
130 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
132 # if currently employed in that position, leaving date is to be disabled
133 # and set to "current"
134 if self
.currentemployment
.isChecked ():
135 leavedatestr
= "current"
137 # if the leaving date is < join date
138 if self
.leavedate
.date () < self
.joindate
.date ():
139 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add",
140 "Leaving date cannot be earlier than join date.")
142 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
144 selitem
.setText (0, self
.designation
.text ())
145 selitem
.setText (1, self
.joindate
.date ().toString ("dd MMM, yyyy"))
146 selitem
.setText (2, leavedatestr
)
147 selitem
.setText (3, self
.organization
.text ())
148 selitem
.setText (4, self
.additionalinfo
.text ())
150 # delete professional history button is clicked
151 def on_delete_profession (self
):
152 # get the selected items
153 selitems
= self
.professionlist
.selectedItems ()
155 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No item selected.")
158 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
159 "Are you sure you wish to delete the selected item?",
160 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
162 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
163 for item
in selitems
:
164 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
165 self
.reset_profession_fields ()
167 # add professional history button is clicked
168 def on_add_profession (self
):
169 if self
.designation
.text () == "":
170 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
172 # if currently employed in that position, leaving date is to be disabled
173 # and set to "current"
174 if self
.currentemployment
.isChecked ():
175 leavedatestr
= "current"
177 # if the leaving date is < join date
178 if self
.leavedate
.date () < self
.joindate
.date ():
179 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add",
180 "Leaving date cannot be earlier than join date.")
182 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
184 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
186 self
.designation
.text (),
187 self
.joindate
.date ().toString ("dd MMM, yyyy"),
189 self
.organization
.text (),
190 self
.additionalinfo
.text ()
194 self
.professionlist
.addTopLevelItem (professionitem
)
196 self
.reset_profession_fields ()
198 # when selection of profession list is changed
199 def on_select_profession (self
):
200 self
.set_profession_fields ()
202 # set the profession fields from the selected item in profession list
203 def set_profession_fields (self
):
204 selitems
= self
.professionlist
.selectedItems ()
207 selitem
= selitems
[0]
208 self
.designation
.setText (selitem
.text (0))
209 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
210 if selitem
.text (2) == "current":
211 self
.leavedate
.setEnabled (False)
212 self
.currentemployment
.setChecked (True)
214 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
215 self
.leavedate
.setEnabled (True)
216 self
.currentemployment
.setChecked (False)
218 self
.organization
.setText (selitem
.text (3))
219 self
.additionalinfo
.setText (selitem
.text (4))
221 def reset_profession_fields (self
):
222 self
.designation
.setText ("")
223 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
224 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
225 self
.currentemployment
.setChecked (False)
226 self
.organization
.setText ("")
227 self
.additionalinfo
.setText ("")
229 # current employment check box is changed
230 def on_change_currentemployment (self
, val
):
232 self
.leavedate
.setEnabled (False)
234 self
.leavedate
.setEnabled (True)
236 # delete educational qualification
237 def on_delete_education (self
):
238 # get the selected items in the education list
239 selitems
= self
.educationlist
.selectedItems ()
240 # if no items are selected
242 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
243 # delete the items after confirmation
245 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
246 "Are you sure you wish to delete selected item?",
247 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
248 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
249 # remove the item selected
250 for item
in selitems
:
251 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
252 self
.reset_education_fields ()
254 # selection is changed
255 def on_select_education (self
):
256 self
.set_education_fields ()
258 # update educational qualification button
259 def on_update_education (self
):
260 selitems
= self
.educationlist
.selectedItems ()
261 # if no item is selected
263 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected")
265 # if the qualification title is not set
266 if self
.degree_name
.text () == "":
267 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
269 selitem
= selitems
[0]
271 selitem
.setText (0, self
.degree_name
.text ())
272 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
273 selitem
.setText (2, self
.institution
.text ())
274 selitem
.setText (3, self
.university
.text ())
275 selitem
.setText (4, self
.grade
.text ())
276 selitem
.setText (5, str (self
.percentage
.value ()))
278 # add educational qualification button
279 def on_add_education (self
):
280 # check if the qualification title is set
281 if self
.degree_name
.text () == "":
282 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required fields is missing.")
284 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
285 self
.degree_name
.text (),
286 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
287 self
.institution
.text (),
288 self
.university
.text (),
290 str (self
.percentage
.value ())
292 self
.educationlist
.addTopLevelItem (educationitem
)
294 self
.reset_education_fields ()
296 # set fields in the education tab from current selected item
297 def set_education_fields (self
):
298 selitems
= self
.educationlist
.selectedItems ()
301 selitem
= selitems
[0]
302 # set the fields to the data in the selected item in the list
303 self
.degree_name
.setText (selitem
.text (0))
304 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
305 self
.institution
.setText (selitem
.text (2))
306 self
.university
.setText (selitem
.text (3))
307 self
.grade
.setText (selitem
.text(4))
308 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
310 # reset fields in the education tab
311 def reset_education_fields (self
):
312 self
.degree_name
.setText ("")
313 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
314 self
.institution
.setText ("")
315 self
.university
.setText ("")
316 self
.grade
.setText ("")
317 self
.percentage
.setValue (50.0)