X-Git-Url: https://harishankar.org/repos/?a=blobdiff_plain;f=biacv_mainwindow.py;h=801928e9786e8fcf96c336112aae67a04ccd9f0b;hb=af2f737f8a7fd79ae16607a18a0936bb74281caf;hp=e58aa37e920a7eae7f7858de4ee264ace98ed7de;hpb=2329fe7718e8c0aa0d1c2cc92c56653ec7757e5c;p=biacv.git diff --git a/biacv_mainwindow.py b/biacv_mainwindow.py index e58aa37..801928e 100644 --- a/biacv_mainwindow.py +++ b/biacv_mainwindow.py @@ -9,6 +9,127 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): self.setupUi (self) self.currentfile = None + # add a language to the list of languages known + def on_add_lang (self): + # check if the language is set + if self.language.text () == "": + PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", "A required field is missing.") + return + langitem = PyQt4.QtGui.QTreeWidgetItem ( + [ + self.language.text (), + str (self.canspeak.isChecked ()), + str (self.canreadwrite.isChecked ()), + str (self.isproficient.isChecked ()) + ] + ) + self.languageslist.addTopLevelItem (langitem) + self.reset_language_fields () + + # reset the language fields + def reset_language_fields (self): + self.language.setText ("") + self.canspeak.setChecked (True) + self.canreadwrite.setChecked (False) + self.isproficient.setChecked (False) + + # update the skill set button event + def on_update_skill (self): + # get the selected item + selitems = self.skillslist.selectedItems () + if selitems == []: + PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "No item selected.") + return + if self.skillsettitle.text () == "": + PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "A required field is missing.") + return + selitem = selitems[0] + + selitem.setText (0, self.skillsettitle.text ()) + selitem.setText (1, self.skilldescription.toPlainText ()) + + # selecting a skill from the list event + def on_select_skill (self): + self.set_skill_fields () + + # set the skill fields from the selected skill from the list + def set_skill_fields (self): + # get the selected items + selitems = self.skillslist.selectedItems () + if selitems == []: + return + selitem = selitems[0] + self.skillsettitle.setText (selitem.text (0)) + self.skilldescription.setPlainText (selitem.text (1)) + + # delete skill set button is clicked + def on_delete_skill (self): + # get the selected items + selitems = self.skillslist.selectedItems () + if selitems == []: + PyQt4.QtGui.QMessageBox.critical (self, "Cannot delete", "No items selected.") + return + # confirm + ans = PyQt4.QtGui.QMessageBox.question (self, "Confirm", + "Are you sure you wish to delete the selected item?", + PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No) + # answer is yes + if ans == PyQt4.QtGui.QMessageBox.Yes: + for item in selitems: + self.skillslist.takeTopLevelItem (self.skillslist.indexOfTopLevelItem (item)) + + self.reset_skillset_fields () + + # add skill set button is clicked + def on_add_skill (self): + # if the skill title is blank + if self.skillsettitle.text () == "": + PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", "A required field is missing.") + return + skillitem = PyQt4.QtGui.QTreeWidgetItem ( + [ + self.skillsettitle.text (), + self.skilldescription.toPlainText () + ] + ) + self.skillslist.addTopLevelItem (skillitem) + self.reset_skillset_fields () + + # clear the skill set fields + def reset_skillset_fields (self): + self.skillsettitle.setText ("") + self.skilldescription.setPlainText ("") + + # update professional history button is clicked + def on_update_profession (self): + # get the selected item + selitems = self.professionlist.selectedItems () + if selitems == []: + PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "No item selected.") + return + selitem = selitems[0] + # if designation is not set + if self.designation.text () == "": + PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "A required field is missing.") + return + # if currently employed in that position, leaving date is to be disabled + # and set to "current" + if self.currentemployment.isChecked (): + leavedatestr = "current" + else: + # if the leaving date is < join date + if self.leavedate.date () < self.joindate.date (): + PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", + "Leaving date cannot be earlier than join date.") + return + leavedatestr = self.leavedate.date ().toString ("dd MMM, yyyy") + + selitem.setText (0, self.designation.text ()) + selitem.setText (1, self.joindate.date ().toString ("dd MMM, yyyy")) + selitem.setText (2, leavedatestr) + selitem.setText (3, self.organization.text ()) + selitem.setText (4, self.additionalinfo.text ()) + # delete professional history button is clicked def on_delete_profession (self): # get the selected items @@ -31,10 +152,16 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): if self.designation.text () == "": PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", "A required field is missing.") return - + # if currently employed in that position, leaving date is to be disabled + # and set to "current" if self.currentemployment.isChecked (): leavedatestr = "current" else: + # if the leaving date is < join date + if self.leavedate.date () < self.joindate.date (): + PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", + "Leaving date cannot be earlier than join date.") + return leavedatestr = self.leavedate.date ().toString ("dd MMM, yyyy") professionitem = PyQt4.QtGui.QTreeWidgetItem (