# remove the item selected
for item in selitems:
self.educationlist.takeTopLevelItem (self.educationlist.indexOfTopLevelItem (item))
+ self.reset_education_fields ()
+ # selection is changed
+ def on_select_education (self):
+ self.set_education_fields ()
+
+ # update educational qualification button
+ def on_update_education (self):
+ selitems = self.educationlist.selectedItems ()
+ # if no item is selected
+ if selitems == []:
+ PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "No item selected")
+ return
+ # if the qualification title is not set
+ if self.degree_name.text () == "":
+ PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "A required field is missing.")
+ return
+ selitem = selitems[0]
+
+ selitem.setText (0, self.degree_name.text ())
+ selitem.setText (1, self.yearofpassing.date ().toString ("MMM, yyyy"))
+ selitem.setText (2, self.institution.text ())
+ selitem.setText (3, self.university.text ())
+ selitem.setText (4, self.grade.text ())
+ selitem.setText (5, str (self.percentage.value ()))
# add educational qualification button
def on_add_education (self):
# check if the qualification title is set
if self.degree_name.text () == "":
- PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", "Some required fields are missing.")
+ PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", "A required fields is missing.")
else:
educationitem = PyQt4.QtGui.QTreeWidgetItem ([
self.degree_name.text (),
str (self.percentage.value ())
])
self.educationlist.addTopLevelItem (educationitem)
+ # clear the fields
+ self.reset_education_fields ()
+
+ # set fields in the education tab from current selected item
+ def set_education_fields (self):
+ selitems = self.educationlist.selectedItems ()
+ if selitems == []:
+ return
+ selitem = selitems[0]
+ # set the fields to the data in the selected item in the list
+ self.degree_name.setText (selitem.text (0))
+ self.yearofpassing.setDate (PyQt4.QtCore.QDate.fromString (selitem.text(1), "MMM, yyyy"))
+ self.institution.setText (selitem.text (2))
+ self.university.setText (selitem.text (3))
+ self.grade.setText (selitem.text(4))
+ self.percentage.setValue (self.percentage.valueFromText (selitem.text(5)))
+
+ # reset fields in the education tab
+ def reset_education_fields (self):
+ self.degree_name.setText ("")
+ self.yearofpassing.setDate (PyQt4.QtCore.QDate (1988, 1, 1))
+ self.institution.setText ("")
+ self.university.setText ("")
+ self.grade.setText ("")
+ self.percentage.setValue (50.0)
+