Delete professional history item done
authorHarishankar <v.harishankar@gmail.com>
Wed, 30 Nov 2011 13:12:47 +0000 (18:42 +0530)
committerHarishankar <v.harishankar@gmail.com>
Wed, 30 Nov 2011 13:12:47 +0000 (18:42 +0530)
Completed implementing the deleting of professional history item
from the list.

biacv_mainwindow.py
biacv_mainwindow.ui
biacv_mainwindow_ui.py

index f33a265..e58aa37 100644 (file)
@@ -9,6 +9,23 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                self.setupUi (self)
                self.currentfile = None
 
                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 () == "":
        # 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 ()
 
 
                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))
        def reset_profession_fields (self):
                self.designation.setText ("")
                self.joindate.setDate (PyQt4.QtCore.QDate (2000, 1, 1))
index 812e7a8..720aed2 100644 (file)
          </widget>
         </item>
         <item row="5" column="3">
          </widget>
         </item>
         <item row="5" column="3">
-         <widget class="QPushButton" name="edithistory">
+         <widget class="QPushButton" name="updatehistory">
           <property name="text">
           <property name="text">
-           <string>&amp;Edit</string>
+           <string>&amp;Update</string>
           </property>
          </widget>
         </item>
           </property>
          </widget>
         </item>
     </hint>
    </hints>
   </connection>
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>professionlist</sender>
+   <signal>itemSelectionChanged()</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_select_profession()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>553</x>
+     <y>351</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>727</x>
+     <y>379</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>professionlist</sender>
+   <signal>activated(QModelIndex)</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_select_profession()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>420</x>
+     <y>323</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>729</x>
+     <y>422</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>deletehistory</sender>
+   <signal>clicked()</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_delete_profession()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>621</x>
+     <y>223</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>729</x>
+     <y>187</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>on_add_education()</slot>
  </connections>
  <slots>
   <slot>on_add_education()</slot>
   <slot>on_update_education()</slot>
   <slot>on_change_currentemployment()</slot>
   <slot>on_add_profession()</slot>
   <slot>on_update_education()</slot>
   <slot>on_change_currentemployment()</slot>
   <slot>on_add_profession()</slot>
+  <slot>on_select_profession()</slot>
+  <slot>on_delete_profession()</slot>
  </slots>
 </ui>
  </slots>
 </ui>
index 5760b36..ce4a164 100644 (file)
@@ -2,7 +2,7 @@
 
 # Form implementation generated from reading ui file 'biacv_mainwindow.ui'
 #
 
 # 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!
 #      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.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"))
         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.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):
         QtCore.QMetaObject.connectSlotsByName(biacv_mainwindow)
 
     def retranslateUi(self, biacv_mainwindow):