Add professional qualification
[biacv.git] / biacv_mainwindow.py
index 18dc486..f33a265 100644 (file)
@@ -9,6 +9,46 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                self.setupUi (self)
                self.currentfile = None
 
+       # add professional history button is clicked
+       def on_add_profession (self):
+               if self.designation.text () == "":
+                       PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", "A required field is missing.")
+                       return
+
+               if self.currentemployment.isChecked ():
+                       leavedatestr = "current"
+               else:
+                       leavedatestr = self.leavedate.date ().toString ("dd MMM, yyyy")
+
+               professionitem = PyQt4.QtGui.QTreeWidgetItem (
+                       [
+                               self.designation.text (),
+                               self.joindate.date ().toString ("dd MMM, yyyy"),
+                               leavedatestr,
+                               self.organization.text (),
+                               self.additionalinfo.text ()
+                       ]
+                       )
+
+               self.professionlist.addTopLevelItem (professionitem)
+
+               self.reset_profession_fields ()
+
+       def reset_profession_fields (self):
+               self.designation.setText ("")
+               self.joindate.setDate (PyQt4.QtCore.QDate (2000, 1, 1))
+               self.leavedate.setDate (PyQt4.QtCore.QDate (2003, 1, 1))
+               self.currentemployment.setChecked (False)
+               self.organization.setText ("")
+               self.additionalinfo.setText ("")
+
+       # current employment check box is changed
+       def on_change_currentemployment (self, val):
+               if val == True:
+                       self.leavedate.setEnabled (False)
+               else:
+                       self.leavedate.setEnabled (True)
+
        # delete educational qualification
        def on_delete_education (self):
                # get the selected items in the education list
@@ -56,18 +96,18 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                # check if the qualification title is set
                if self.degree_name.text () == "":
                        PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", "A required fields is missing.")
-               else:
-                       educationitem = PyQt4.QtGui.QTreeWidgetItem ([
-                                       self.degree_name.text (),
-                                       self.yearofpassing.date ().toString ("MMM, yyyy"),
-                                       self.institution.text (),
-                                       self.university.text (),
-                                       self.grade.text (),
-                                       str (self.percentage.value ())
+                       return
+               educationitem = PyQt4.QtGui.QTreeWidgetItem ([
+                       self.degree_name.text (),
+                       self.yearofpassing.date ().toString ("MMM, yyyy"),
+                       self.institution.text (),
+                       self.university.text (),
+                       self.grade.text (),
+                       str (self.percentage.value ())
                        ])
-                       self.educationlist.addTopLevelItem (educationitem)
-                       # clear the fields
-                       self.reset_education_fields ()
+               self.educationlist.addTopLevelItem (educationitem)
+               # clear the fields
+               self.reset_education_fields ()
 
        # set fields in the education tab from current selected item
        def set_education_fields (self):