Delete education qualification from list
[biacv.git] / biacv_mainwindow.py
index 3133477..ac393f7 100644 (file)
@@ -7,7 +7,27 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
        def __init__ (self):
                PyQt4.QtGui.QMainWindow.__init__ (self)
                self.setupUi (self)
+               self.currentfile = None
 
+       # delete educational qualification
+       def on_delete_education (self):
+               # get the selected items in the education list
+               selitems = self.educationlist.selectedItems ()
+               # if no items are selected
+               if selitems == []:
+                       PyQt4.QtGui.QMessageBox.critical (self, "Cannot delete", "No items selected.")
+               # delete the items after confirmation
+               else:
+                       ans = PyQt4.QtGui.QMessageBox.question (self, "Confirm",
+                               "Are you sure you wish to delete selected item?",
+                               PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
+                       if ans == PyQt4.QtGui.QMessageBox.Yes:
+                               # remove the item selected
+                               for item in selitems:
+                                       self.educationlist.takeTopLevelItem (self.educationlist.indexOfTopLevelItem (item))
+
+
+       # add educational qualification button
        def on_add_education (self):
                # check if the qualification title is set
                if self.degree_name.text () == "":
@@ -21,4 +41,4 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                                        self.grade.text (),
                                        str (self.percentage.value ())
                        ])
-                       self.educationlist.addTopLevelItem (educationitem)
\ No newline at end of file
+                       self.educationlist.addTopLevelItem (educationitem)