From 2329fe7718e8c0aa0d1c2cc92c56653ec7757e5c Mon Sep 17 00:00:00 2001 From: Harishankar Date: Wed, 30 Nov 2011 18:42:47 +0530 Subject: [PATCH] Delete professional history item done Completed implementing the deleting of professional history item from the list. --- biacv_mainwindow.py | 40 +++++++++++++++++++++++++++++++ biacv_mainwindow.ui | 54 ++++++++++++++++++++++++++++++++++++++++-- biacv_mainwindow_ui.py | 13 ++++++---- 3 files changed, 100 insertions(+), 7 deletions(-) diff --git a/biacv_mainwindow.py b/biacv_mainwindow.py index f33a265..e58aa37 100644 --- a/biacv_mainwindow.py +++ b/biacv_mainwindow.py @@ -9,6 +9,23 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): self.setupUi (self) self.currentfile = None + # delete professional history button is clicked + def on_delete_profession (self): + # get the selected items + selitems = self.professionlist.selectedItems () + if selitems == []: + PyQt4.QtGui.QMessageBox.critical (self, "Cannot delete", "No item selected.") + return + # confirm deletion + 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) + # if confirmed + if ans == PyQt4.QtGui.QMessageBox.Yes: + for item in selitems: + self.professionlist.takeTopLevelItem (self.professionlist.indexOfTopLevelItem (item)) + self.reset_profession_fields () + # add professional history button is clicked def on_add_profession (self): if self.designation.text () == "": @@ -34,6 +51,29 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): self.reset_profession_fields () + # when selection of profession list is changed + def on_select_profession (self): + self.set_profession_fields () + + # set the profession fields from the selected item in profession list + def set_profession_fields (self): + selitems = self.professionlist.selectedItems () + if selitems == []: + return + selitem = selitems[0] + self.designation.setText (selitem.text (0)) + self.joindate.setDate (PyQt4.QtCore.QDate.fromString (selitem.text(1), "dd MMM, yyyy")) + if selitem.text (2) == "current": + self.leavedate.setEnabled (False) + self.currentemployment.setChecked (True) + else: + self.leavedate.setDate (PyQt4.QtCore.QDate.fromString (selitem.text (2), "dd MMM, yyyy")) + self.leavedate.setEnabled (True) + self.currentemployment.setChecked (False) + + self.organization.setText (selitem.text (3)) + self.additionalinfo.setText (selitem.text (4)) + def reset_profession_fields (self): self.designation.setText ("") self.joindate.setDate (PyQt4.QtCore.QDate (2000, 1, 1)) diff --git a/biacv_mainwindow.ui b/biacv_mainwindow.ui index 812e7a8..720aed2 100644 --- a/biacv_mainwindow.ui +++ b/biacv_mainwindow.ui @@ -584,9 +584,9 @@ - + - &Edit + &Update @@ -1047,6 +1047,54 @@ + + professionlist + itemSelectionChanged() + biacv_mainwindow + on_select_profession() + + + 553 + 351 + + + 727 + 379 + + + + + professionlist + activated(QModelIndex) + biacv_mainwindow + on_select_profession() + + + 420 + 323 + + + 729 + 422 + + + + + deletehistory + clicked() + biacv_mainwindow + on_delete_profession() + + + 621 + 223 + + + 729 + 187 + + + on_add_education() @@ -1055,5 +1103,7 @@ on_update_education() on_change_currentemployment() on_add_profession() + on_select_profession() + on_delete_profession() diff --git a/biacv_mainwindow_ui.py b/biacv_mainwindow_ui.py index 5760b36..ce4a164 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 15:47:09 2011 +# Created: Wed Nov 30 18:36:56 2011 # by: PyQt4 UI code generator 4.8.6 # # WARNING! All changes made in this file will be lost! @@ -338,10 +338,10 @@ class Ui_biacv_mainwindow(object): self.addhistory.setText(QtGui.QApplication.translate("biacv_mainwindow", "&Add", None, QtGui.QApplication.UnicodeUTF8)) self.addhistory.setObjectName(_fromUtf8("addhistory")) self.gridLayout_4.addWidget(self.addhistory, 5, 2, 1, 1) - self.edithistory = QtGui.QPushButton(self.tab_3) - self.edithistory.setText(QtGui.QApplication.translate("biacv_mainwindow", "&Edit", None, QtGui.QApplication.UnicodeUTF8)) - self.edithistory.setObjectName(_fromUtf8("edithistory")) - self.gridLayout_4.addWidget(self.edithistory, 5, 3, 1, 1) + self.updatehistory = QtGui.QPushButton(self.tab_3) + self.updatehistory.setText(QtGui.QApplication.translate("biacv_mainwindow", "&Update", None, QtGui.QApplication.UnicodeUTF8)) + self.updatehistory.setObjectName(_fromUtf8("updatehistory")) + self.gridLayout_4.addWidget(self.updatehistory, 5, 3, 1, 1) self.deletehistory = QtGui.QPushButton(self.tab_3) self.deletehistory.setText(QtGui.QApplication.translate("biacv_mainwindow", "&Delete", None, QtGui.QApplication.UnicodeUTF8)) self.deletehistory.setObjectName(_fromUtf8("deletehistory")) @@ -549,6 +549,9 @@ class Ui_biacv_mainwindow(object): QtCore.QObject.connect(self.educationlist, QtCore.SIGNAL(_fromUtf8("activated(QModelIndex)")), biacv_mainwindow.on_select_education) QtCore.QObject.connect(self.currentemployment, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), biacv_mainwindow.on_change_currentemployment) QtCore.QObject.connect(self.addhistory, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_add_profession) + QtCore.QObject.connect(self.professionlist, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), biacv_mainwindow.on_select_profession) + QtCore.QObject.connect(self.professionlist, QtCore.SIGNAL(_fromUtf8("activated(QModelIndex)")), biacv_mainwindow.on_select_profession) + QtCore.QObject.connect(self.deletehistory, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_delete_profession) QtCore.QMetaObject.connectSlotsByName(biacv_mainwindow) def retranslateUi(self, biacv_mainwindow): -- 2.20.1