From 6f0fce4b0186aea9896ac6f30b2385bfba3771d2 Mon Sep 17 00:00:00 2001 From: Harishankar Date: Sun, 4 Dec 2011 14:27:21 +0530 Subject: [PATCH] Implemented document save status flag Implemented a flag to check if a document is currently modified or not. To further implement the "Open", "Save" and "Save As" features and also checking when quitting. --- biacv_mainwindow.py | 33 ++++ biacv_mainwindow.ui | 403 ++++++++++++++++++++++++++++++++++++----- biacv_mainwindow_ui.py | 22 ++- 3 files changed, 416 insertions(+), 42 deletions(-) diff --git a/biacv_mainwindow.py b/biacv_mainwindow.py index 0f0f9ad..1bd6563 100644 --- a/biacv_mainwindow.py +++ b/biacv_mainwindow.py @@ -10,6 +10,13 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): PyQt4.QtGui.QMainWindow.__init__ (self) self.setupUi (self) self.currentfile = None + self.ismodified = False + + # 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): @@ -28,6 +35,9 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): selitem.setText (2, str (self.canreadwrite.isChecked ())) selitem.setText (3, str (self.isproficient.isChecked ())) + # modified the document + self.ismodified = True + # selecting a language from the list of languages def on_select_lang (self): # set the language fields from the selected item @@ -48,6 +58,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): self.languageslist.takeTopLevelItem (self.languageslist.indexOfTopLevelItem (item)) self.reset_language_fields () + # set the modified flag + self.ismodified = True # add a language to the list of languages known def on_add_lang (self): @@ -66,6 +78,9 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): self.languageslist.addTopLevelItem (langitem) self.reset_language_fields () + # set the modified flag + self.ismodified = True + # set the language fields from the selected item def set_language_fields (self): selitems = self.languageslist.selectedItems () @@ -98,6 +113,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): selitem.setText (0, self.skillsettitle.text ()) selitem.setText (1, self.skilldescription.toPlainText ()) + # set the modified flag + self.ismodified = True # selecting a skill from the list event def on_select_skill (self): @@ -129,6 +146,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): self.skillslist.takeTopLevelItem (self.skillslist.indexOfTopLevelItem (item)) self.reset_skillset_fields () + # set the modified flag + self.ismodified = True # add skill set button is clicked def on_add_skill (self): @@ -144,6 +163,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): ) self.skillslist.addTopLevelItem (skillitem) self.reset_skillset_fields () + # set the modified flag + self.ismodified = True # clear the skill set fields def reset_skillset_fields (self): @@ -178,6 +199,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): selitem.setText (2, leavedatestr) selitem.setText (3, self.organization.text ()) selitem.setText (4, self.additionalinfo.text ()) + # set the modified flag + self.ismodified = True # delete professional history button is clicked def on_delete_profession (self): @@ -194,6 +217,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): for item in selitems: self.professionlist.takeTopLevelItem (self.professionlist.indexOfTopLevelItem (item)) self.reset_profession_fields () + # set the modified flag + self.ismodified = True # add professional history button is clicked def on_add_profession (self): @@ -224,6 +249,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): self.professionlist.addTopLevelItem (professionitem) self.reset_profession_fields () + # set the modified flag + self.ismodified = True # when selection of profession list is changed def on_select_profession (self): @@ -279,6 +306,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): for item in selitems: self.educationlist.takeTopLevelItem (self.educationlist.indexOfTopLevelItem (item)) self.reset_education_fields () + # set the modified flag + self.ismodified = True # selection is changed def on_select_education (self): @@ -303,6 +332,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): selitem.setText (3, self.university.text ()) selitem.setText (4, self.grade.text ()) selitem.setText (5, str (self.percentage.value ())) + # set the modified flag + self.ismodified = True # add educational qualification button def on_add_education (self): @@ -321,6 +352,8 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): self.educationlist.addTopLevelItem (educationitem) # clear the fields self.reset_education_fields () + # set the modified flag + self.ismodified = True # set fields in the education tab from current selected item def set_education_fields (self): diff --git a/biacv_mainwindow.ui b/biacv_mainwindow.ui index 2aa4322..13de132 100644 --- a/biacv_mainwindow.ui +++ b/biacv_mainwindow.ui @@ -1019,8 +1019,8 @@ on_add_education() - 534 - 198 + 426 + 189 730 @@ -1035,8 +1035,8 @@ on_delete_education() - 677 - 198 + 658 + 189 728 @@ -1051,8 +1051,8 @@ on_select_education() - 281 - 290 + 100 + 217 726 @@ -1067,8 +1067,8 @@ on_update_education() - 608 - 202 + 579 + 189 728 @@ -1083,8 +1083,8 @@ on_select_education() - 648 - 303 + 100 + 217 729 @@ -1099,8 +1099,8 @@ on_change_currentemployment() - 368 - 140 + 328 + 136 728 @@ -1115,8 +1115,8 @@ on_add_profession() - 391 - 222 + 309 + 216 729 @@ -1131,8 +1131,8 @@ on_select_profession() - 553 - 351 + 99 + 244 727 @@ -1147,8 +1147,8 @@ on_select_profession() - 420 - 323 + 99 + 244 729 @@ -1163,8 +1163,8 @@ on_delete_profession() - 621 - 223 + 596 + 216 729 @@ -1179,8 +1179,8 @@ on_update_profession() - 510 - 230 + 453 + 216 726 @@ -1195,8 +1195,8 @@ on_add_skill() - 307 - 240 + 207 + 234 730 @@ -1211,8 +1211,8 @@ on_delete_skill() - 598 - 238 + 566 + 234 728 @@ -1227,8 +1227,8 @@ on_select_skill() - 453 - 359 + 99 + 261 730 @@ -1243,8 +1243,8 @@ on_select_skill() - 602 - 331 + 99 + 261 726 @@ -1259,8 +1259,8 @@ on_update_skill() - 437 - 243 + 386 + 234 728 @@ -1275,8 +1275,8 @@ on_add_lang() - 545 - 138 + 547 + 155 729 @@ -1291,8 +1291,8 @@ on_delete_lang() - 687 - 142 + 716 + 155 733 @@ -1307,8 +1307,8 @@ on_select_lang() - 554 - 224 + 112 + 189 730 @@ -1323,7 +1323,7 @@ on_select_lang() - 617 + 112 189 @@ -1339,8 +1339,8 @@ on_update_lang() - 605 - 140 + 644 + 155 729 @@ -1348,6 +1348,326 @@ + + title + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 480 + 41 + + + 728 + 28 + + + + + nametitle + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 132 + 144 + + + 3 + 470 + + + + + firstname + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 267 + 145 + + + 29 + 475 + + + + + lastname + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 479 + 142 + + + 1 + 452 + + + + + dateofbirth + dateChanged(QDate) + biacv_mainwindow + on_document_modified() + + + 223 + 186 + + + 538 + 23 + + + + + street + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 170 + 265 + + + 196 + 23 + + + + + countrycode_landline + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 437 + 268 + + + 88 + 24 + + + + + telephone + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 527 + 264 + + + 165 + -2 + + + + + area + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 204 + 305 + + + -1 + 50 + + + + + countrycode_mobile + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 409 + 309 + + + 575 + 51 + + + + + mobilenumber + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 588 + 305 + + + 0 + 89 + + + + + city + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 93 + 356 + + + -3 + 171 + + + + + email + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 372 + 351 + + + 2 + 203 + + + + + areacode + textChanged(QString) + biacv_mainwindow + on_document_modified() + + + 118 + 396 + + + 0 + 273 + + + + + married + toggled(bool) + biacv_mainwindow + on_document_modified() + + + 149 + 436 + + + 1 + 327 + + + + + single + toggled(bool) + biacv_mainwindow + on_document_modified() + + + 212 + 431 + + + 3 + 237 + + + + + unspecified + toggled(bool) + biacv_mainwindow + on_document_modified() + + + 303 + 436 + + + -2 + 137 + + + + + shorttermcareer + textChanged() + biacv_mainwindow + on_document_modified() + + + 98 + 177 + + + 0 + 120 + + + + + longtermgoals + textChanged() + biacv_mainwindow + on_document_modified() + + + 82 + 350 + + + 2 + 443 + + + + + additionalinformation + textChanged() + biacv_mainwindow + on_document_modified() + + + 86 + 375 + + + 1 + 377 + + + on_add_education() @@ -1367,5 +1687,6 @@ on_delete_lang() on_select_lang() on_update_lang() + on_document_modified() diff --git a/biacv_mainwindow_ui.py b/biacv_mainwindow_ui.py index 7a91297..0ae8372 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: Fri Dec 2 10:52:04 2011 +# Created: Sun Dec 4 14:23:51 2011 # by: PyQt4 UI code generator 4.8.6 # # WARNING! All changes made in this file will be lost! @@ -584,6 +584,26 @@ class Ui_biacv_mainwindow(object): QtCore.QObject.connect(self.languageslist, QtCore.SIGNAL(_fromUtf8("activated(QModelIndex)")), biacv_mainwindow.on_select_lang) QtCore.QObject.connect(self.languageslist, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), biacv_mainwindow.on_select_lang) QtCore.QObject.connect(self.updatelanguage, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_update_lang) + QtCore.QObject.connect(self.title, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.nametitle, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.firstname, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.lastname, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.dateofbirth, QtCore.SIGNAL(_fromUtf8("dateChanged(QDate)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.street, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.countrycode_landline, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.telephone, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.area, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.countrycode_mobile, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.mobilenumber, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.city, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.email, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.areacode, QtCore.SIGNAL(_fromUtf8("textChanged(QString)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.married, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.single, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), biacv_mainwindow.on_document_modified) + QtCore.QObject.connect(self.unspecified, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), biacv_mainwindow.on_document_modified) + 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.QMetaObject.connectSlotsByName(biacv_mainwindow) def retranslateUi(self, biacv_mainwindow): -- 2.20.1