Update educational qualifications completed
authorHarishankar <v.harishankar@gmail.com>
Wed, 30 Nov 2011 09:07:21 +0000 (14:37 +0530)
committerHarishankar <v.harishankar@gmail.com>
Wed, 30 Nov 2011 09:07:21 +0000 (14:37 +0530)
Completed the update educational qualifications button
functionality.

biacv_mainwindow.py
biacv_mainwindow.ui
biacv_mainwindow_ui.py

index ac393f7..18dc486 100644 (file)
@@ -25,13 +25,37 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                                # remove the item selected
                                for item in selitems:
                                        self.educationlist.takeTopLevelItem (self.educationlist.indexOfTopLevelItem (item))
+                               self.reset_education_fields ()
 
+       # selection is changed
+       def on_select_education (self):
+               self.set_education_fields ()
+
+       # update educational qualification button
+       def on_update_education (self):
+               selitems = self.educationlist.selectedItems ()
+               # if no item is selected
+               if selitems == []:
+                       PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "No item selected")
+                       return
+               # if the qualification title is not set
+               if self.degree_name.text () == "":
+                       PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "A required field is missing.")
+                       return
+               selitem = selitems[0]
+
+               selitem.setText (0, self.degree_name.text ())
+               selitem.setText (1, self.yearofpassing.date ().toString ("MMM, yyyy"))
+               selitem.setText (2, self.institution.text ())
+               selitem.setText (3, self.university.text ())
+               selitem.setText (4, self.grade.text ())
+               selitem.setText (5, str (self.percentage.value ()))
 
        # add educational qualification button
        def on_add_education (self):
                # check if the qualification title is set
                if self.degree_name.text () == "":
-                       PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", "Some required fields are missing.")
+                       PyQt4.QtGui.QMessageBox.critical (self, "Cannot add", "A required fields is missing.")
                else:
                        educationitem = PyQt4.QtGui.QTreeWidgetItem ([
                                        self.degree_name.text (),
@@ -42,3 +66,29 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                                        str (self.percentage.value ())
                        ])
                        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):
+               selitems = self.educationlist.selectedItems ()
+               if selitems == []:
+                       return
+               selitem = selitems[0]
+               # set the fields to the data in the selected item in the list
+               self.degree_name.setText (selitem.text (0))
+               self.yearofpassing.setDate (PyQt4.QtCore.QDate.fromString (selitem.text(1), "MMM, yyyy"))
+               self.institution.setText (selitem.text (2))
+               self.university.setText (selitem.text (3))
+               self.grade.setText (selitem.text(4))
+               self.percentage.setValue (self.percentage.valueFromText (selitem.text(5)))
+
+       # reset fields in the education tab
+       def reset_education_fields (self):
+               self.degree_name.setText ("")
+               self.yearofpassing.setDate (PyQt4.QtCore.QDate (1988, 1, 1))
+               self.institution.setText ("")
+               self.university.setText ("")
+               self.grade.setText ("")
+               self.percentage.setValue (50.0)
+
index 7abd581..4fb9cc8 100644 (file)
@@ -28,7 +28,7 @@
     <item row="1" column="0" colspan="2">
      <widget class="QTabWidget" name="pages">
       <property name="currentIndex">
-       <number>0</number>
+       <number>1</number>
       </property>
       <widget class="QWidget" name="tab">
        <attribute name="title">
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>educationlist</sender>
+   <signal>itemSelectionChanged()</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_select_education()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>281</x>
+     <y>290</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>726</x>
+     <y>472</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>updateeducation</sender>
+   <signal>clicked()</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_update_education()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>608</x>
+     <y>202</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>728</x>
+     <y>218</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>educationlist</sender>
+   <signal>activated(QModelIndex)</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_select_education()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>648</x>
+     <y>303</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>729</x>
+     <y>329</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>on_add_education()</slot>
   <slot>on_delete_education()</slot>
+  <slot>on_select_education()</slot>
+  <slot>on_update_education()</slot>
  </slots>
 </ui>
index b98aa3d..9d60bad 100644 (file)
@@ -2,7 +2,7 @@
 
 # Form implementation generated from reading ui file 'biacv_mainwindow.ui'
 #
-# Created: Wed Nov 30 12:43:29 2011
+# Created: Wed Nov 30 14:34:55 2011
 #      by: PyQt4 UI code generator 4.8.6
 #
 # WARNING! All changes made in this file will be lost!
@@ -510,9 +510,12 @@ class Ui_biacv_mainwindow(object):
         self.menubar.addAction(self.menu_Help.menuAction())
 
         self.retranslateUi(biacv_mainwindow)
-        self.pages.setCurrentIndex(0)
+        self.pages.setCurrentIndex(1)
         QtCore.QObject.connect(self.addeducation, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_add_education)
         QtCore.QObject.connect(self.deleteeducation, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_delete_education)
+        QtCore.QObject.connect(self.educationlist, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), biacv_mainwindow.on_select_education)
+        QtCore.QObject.connect(self.updateeducation, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_update_education)
+        QtCore.QObject.connect(self.educationlist, QtCore.SIGNAL(_fromUtf8("activated(QModelIndex)")), biacv_mainwindow.on_select_education)
         QtCore.QMetaObject.connectSlotsByName(biacv_mainwindow)
 
     def retranslateUi(self, biacv_mainwindow):