X-Git-Url: https://harishankar.org/repos/?p=biacv.git;a=blobdiff_plain;f=biacv_mainwindow.py;h=18dc486925719ec351351c609901ac5ed0b7e38b;hp=ac393f76079f809e90307d3575628e216938efb0;hb=4bb46b8b31777371863b0854225b8115e3882f5a;hpb=9aa733bc55ede2589ab2d55ad33fa805a77e1f82 diff --git a/biacv_mainwindow.py b/biacv_mainwindow.py index ac393f7..18dc486 100644 --- a/biacv_mainwindow.py +++ b/biacv_mainwindow.py @@ -25,13 +25,37 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): # 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 (), @@ -42,3 +66,29 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): 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) +