Update language in list
authorHarishankar <v.harishankar@gmail.com>
Fri, 2 Dec 2011 05:25:43 +0000 (10:55 +0530)
committerHarishankar <v.harishankar@gmail.com>
Fri, 2 Dec 2011 05:25:43 +0000 (10:55 +0530)
Update language in list of languages implemented

biacv_mainwindow.py
biacv_mainwindow.ui
biacv_mainwindow_ui.py

index 8c3b132..feaa8d3 100644 (file)
@@ -1,3 +1,4 @@
+# BiaCV
 # class for main window
 
 import PyQt4
@@ -9,6 +10,28 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                self.setupUi (self)
                self.currentfile = None
 
+       # update a language in the list of languages
+       def on_update_lang (self):
+               # get the selected language
+               selitems = self.languageslist.selectedItems ()
+               if selitems == []:
+                       PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "No item selected.")
+                       return
+               # check if the language string is not empty
+               if self.language.text () == "":
+                       PyQt4.QtGui.QMessageBox.critical (self, "Cannot update", "A required field is missing.")
+                       return
+               selitem = selitems[0]
+               selitem.setText (0, self.language.text ())
+               selitem.setText (1, str (self.canspeak.isChecked ()))
+               selitem.setText (2, str (self.canreadwrite.isChecked ()))
+               selitem.setText (3, str (self.isproficient.isChecked ()))
+
+       # selecting a language from the list of languages
+       def on_select_lang (self):
+               # set the language fields from the selected item
+               self.set_language_fields ()
+
        # delete a language from the list of languages known
        def on_delete_lang (self):
                # get selected language
@@ -43,6 +66,17 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                self.languageslist.addTopLevelItem (langitem)
                self.reset_language_fields ()
 
+       # set the language fields from the selected item
+       def set_language_fields (self):
+               selitems = self.languageslist.selectedItems ()
+               if selitems == []:
+                       return
+               selitem = selitems[0]
+               self.language.setText (selitem.text (0))
+               self.canspeak.setChecked (selitem.text (1) == "True")
+               self.canreadwrite.setChecked (selitem.text(2) == "True")
+               self.isproficient.setChecked (selitem.text(3) == "True")
+
        # reset the language fields
        def reset_language_fields (self):
                self.language.setText ("")
index dac093c..2aa4322 100644 (file)
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>languageslist</sender>
+   <signal>activated(QModelIndex)</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_select_lang()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>554</x>
+     <y>224</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>730</x>
+     <y>118</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>languageslist</sender>
+   <signal>itemSelectionChanged()</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_select_lang()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>617</x>
+     <y>189</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>730</x>
+     <y>314</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>updatelanguage</sender>
+   <signal>clicked()</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_update_lang()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>605</x>
+     <y>140</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>729</x>
+     <y>462</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>on_add_education()</slot>
   <slot>on_update_skill()</slot>
   <slot>on_add_lang()</slot>
   <slot>on_delete_lang()</slot>
+  <slot>on_select_lang()</slot>
+  <slot>on_update_lang()</slot>
  </slots>
 </ui>
index 5f71108..7a91297 100644 (file)
@@ -2,7 +2,7 @@
 
 # Form implementation generated from reading ui file 'biacv_mainwindow.ui'
 #
-# Created: Fri Dec  2 10:24:51 2011
+# Created: Fri Dec  2 10:52:04 2011
 #      by: PyQt4 UI code generator 4.8.6
 #
 # WARNING! All changes made in this file will be lost!
@@ -581,6 +581,9 @@ class Ui_biacv_mainwindow(object):
         QtCore.QObject.connect(self.updateskill, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_update_skill)
         QtCore.QObject.connect(self.addlanguage, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_add_lang)
         QtCore.QObject.connect(self.deletelanguage, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_delete_lang)
+        QtCore.QObject.connect(self.languageslist, QtCore.SIGNAL(_fromUtf8("activated(QModelIndex)")), biacv_mainwindow.on_select_lang)
+        QtCore.QObject.connect(self.languageslist, QtCore.SIGNAL(_fromUtf8("itemSelectionChanged()")), biacv_mainwindow.on_select_lang)
+        QtCore.QObject.connect(self.updatelanguage, QtCore.SIGNAL(_fromUtf8("clicked()")), biacv_mainwindow.on_update_lang)
         QtCore.QMetaObject.connectSlotsByName(biacv_mainwindow)
 
     def retranslateUi(self, biacv_mainwindow):