From: Harishankar Date: Wed, 30 Nov 2011 09:07:21 +0000 (+0530) Subject: Update educational qualifications completed X-Git-Url: https://harishankar.org/repos/?a=commitdiff_plain;h=4bb46b8b31777371863b0854225b8115e3882f5a;p=biacv.git Update educational qualifications completed Completed the update educational qualifications button functionality. --- 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) + diff --git a/biacv_mainwindow.ui b/biacv_mainwindow.ui index 7abd581..4fb9cc8 100644 --- a/biacv_mainwindow.ui +++ b/biacv_mainwindow.ui @@ -28,7 +28,7 @@ - 0 + 1 @@ -891,9 +891,59 @@ + + educationlist + itemSelectionChanged() + biacv_mainwindow + on_select_education() + + + 281 + 290 + + + 726 + 472 + + + + + updateeducation + clicked() + biacv_mainwindow + on_update_education() + + + 608 + 202 + + + 728 + 218 + + + + + educationlist + activated(QModelIndex) + biacv_mainwindow + on_select_education() + + + 648 + 303 + + + 729 + 329 + + + on_add_education() on_delete_education() + on_select_education() + on_update_education() diff --git a/biacv_mainwindow_ui.py b/biacv_mainwindow_ui.py index b98aa3d..9d60bad 100644 --- a/biacv_mainwindow_ui.py +++ b/biacv_mainwindow_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'biacv_mainwindow.ui' # -# Created: Wed Nov 30 12:43:29 2011 +# Created: Wed Nov 30 14:34:55 2011 # by: PyQt4 UI code generator 4.8.6 # # WARNING! All changes made in this file will be lost! @@ -510,9 +510,12 @@ class Ui_biacv_mainwindow(object): self.menubar.addAction(self.menu_Help.menuAction()) self.retranslateUi(biacv_mainwindow) - self.pages.setCurrentIndex(0) + self.pages.setCurrentIndex(1) QtCore.QObject.connect(self.addeducation, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_add_education) QtCore.QObject.connect(self.deleteeducation, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_delete_education) + QtCore.QObject.connect(self.educationlist, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), biacv_mainwindow.on_select_education) + QtCore.QObject.connect(self.updateeducation, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_update_education) + QtCore.QObject.connect(self.educationlist, QtCore.SIGNAL(_fromUtf8("activated(QModelIndex)")), biacv_mainwindow.on_select_education) QtCore.QMetaObject.connectSlotsByName(biacv_mainwindow) def retranslateUi(self, biacv_mainwindow):