From: Harishankar Date: Sun, 4 Dec 2011 11:28:09 +0000 (+0530) Subject: File -> New action implemented X-Git-Url: https://harishankar.org/repos/?p=biacv.git;a=commitdiff_plain;h=cbb2972b6b829a3c38cfac1a41ed44db29524550 File -> New action implemented Implemented File -> New action. --- diff --git a/biacv_lang.py b/biacv_lang.py index d999189..5f85c28 100644 --- a/biacv_lang.py +++ b/biacv_lang.py @@ -7,4 +7,5 @@ ERROR_DELETE = "Error deleting" ERROR_ADD = "Error adding" CONFIRM = "Confirm" CONFIRM_DELETE = "Are you sure you wish to delete the selected item?" +CONFIRM_DISCARD_SAVE = "There are unsaved changes in current document. Do you wish to discard all changes?" ERROR_DATE = "There is a problem with the date range selected." diff --git a/biacv_mainwindow.py b/biacv_mainwindow.py index 1bd6563..7d577da 100644 --- a/biacv_mainwindow.py +++ b/biacv_mainwindow.py @@ -12,11 +12,90 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): self.currentfile = None self.ismodified = False + # function to reset personal information data in the GUI + def reset_personal_info (self): + self.nametitle.setEditText ("") + self.firstname.setText ("") + self.lastname.setText ("") + self.dateofbirth.setDate (PyQt4.QtCore.QDate (1970, 1, 1)) + self.street.setText ("") + self.area.setText ("") + self.city.setText ("") + self.countrycode_landline.setText ("") + self.telephone.setText ("") + self.countrycode_mobile.setText ("") + self.mobilenumber.setText ("") + self.email.setText ("") + self.areacode.setText ("") + self.unspecified.setChecked (True) + + # function to clear professional history in the GUI + def reset_professional_history (self): + self.reset_profession_fields () + self.professionlist.clear () + + # function to clear educational qualifications in the GUI + def reset_educational_qualifications (self): + self.reset_education_fields () + self.educationlist.clear () + + # function to clear career objectives data in the GUI + def reset_career_objectives (self): + self.shorttermcareer.setPlainText ("") + self.longtermgoals.setPlainText ("") + + # function to clear skill sets data in the GUI + def reset_skillsets_info (self): + self.reset_skillset_fields () + self.skillslist.clear () + + # function to clear additional information data in the GUI + def reset_additional_info (self): + self.reset_language_fields () + self.languageslist.clear () + self.additionalinformation.setPlainText ("") + + # function to clear all the fields and reset them to defaults + def new_document (self): + # first clear the individual record fields in the tabs + self.reset_language_fields () + self.reset_skillset_fields () + + # clear document data + self.title.setText ("") + + self.reset_personal_info () + self.reset_professional_history () + self.reset_educational_qualifications () + self.reset_career_objectives () + self.reset_skillsets_info () + self.reset_additional_info () + + # set the page to first page + self.pages.setCurrentIndex (0) + + # set current file to none and modified to false + self.currentfile = None + self.ismodified = False + + # file new action is triggered + def on_file_new (self): + # if the previous document is modified + # as if it should be discarded + if self.ismodified is True: + ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, + lang.CONFIRM_DISCARD_SAVE, + PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No) + if ans == PyQt4.QtGui.QMessageBox.Yes: + self.new_document () + # if not modified then simply create a new document + else: + self.new_document () + # when the document is modified def on_document_modified (self): # set the document modified flag self.ismodified = True - print "True" # update a language in the list of languages def on_update_lang (self): diff --git a/biacv_mainwindow.ui b/biacv_mainwindow.ui index 13de132..844088e 100644 --- a/biacv_mainwindow.ui +++ b/biacv_mainwindow.ui @@ -1275,8 +1275,8 @@ on_add_lang() - 547 - 155 + 468 + 132 729 @@ -1291,8 +1291,8 @@ on_delete_lang() - 716 - 155 + 656 + 132 733 @@ -1307,8 +1307,8 @@ on_select_lang() - 112 - 189 + 94 + 160 730 @@ -1323,8 +1323,8 @@ on_select_lang() - 112 - 189 + 94 + 160 730 @@ -1339,8 +1339,8 @@ on_update_lang() - 644 - 155 + 591 + 132 729 @@ -1627,8 +1627,8 @@ on_document_modified() - 98 - 177 + 99 + 101 0 @@ -1643,8 +1643,8 @@ on_document_modified() - 82 - 350 + 86 + 297 2 @@ -1659,8 +1659,8 @@ on_document_modified() - 86 - 375 + 90 + 333 1 @@ -1668,6 +1668,22 @@ + + action_New + triggered() + biacv_mainwindow + on_file_new() + + + -1 + -1 + + + 364 + 248 + + + on_add_education() @@ -1688,5 +1704,6 @@ on_select_lang() on_update_lang() on_document_modified() + on_file_new() diff --git a/biacv_mainwindow_ui.py b/biacv_mainwindow_ui.py index 0ae8372..0d88db2 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: Sun Dec 4 14:23:51 2011 +# Created: Sun Dec 4 16:35:10 2011 # by: PyQt4 UI code generator 4.8.6 # # WARNING! All changes made in this file will be lost! @@ -604,6 +604,7 @@ class Ui_biacv_mainwindow(object): QtCore.QObject.connect(self.shorttermcareer, QtCore.SIGNAL(_fromUtf8("textChanged()")), biacv_mainwindow.on_document_modified) QtCore.QObject.connect(self.longtermgoals, QtCore.SIGNAL(_fromUtf8("textChanged()")), biacv_mainwindow.on_document_modified) QtCore.QObject.connect(self.additionalinformation, QtCore.SIGNAL(_fromUtf8("textChanged()")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.action_New, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_file_new) QtCore.QMetaObject.connectSlotsByName(biacv_mainwindow) def retranslateUi(self, biacv_mainwindow):