From ee10e19ca6c9acf564a7d50dd8b658034b6ae037 Mon Sep 17 00:00:00 2001 From: Harishankar Date: Fri, 2 Dec 2011 10:55:43 +0530 Subject: [PATCH] Update language in list Update language in list of languages implemented --- biacv_mainwindow.py | 34 ++++++++++++++++++++++++++++ biacv_mainwindow.ui | 50 ++++++++++++++++++++++++++++++++++++++++++ biacv_mainwindow_ui.py | 5 ++++- 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/biacv_mainwindow.py b/biacv_mainwindow.py index 8c3b132..feaa8d3 100644 --- a/biacv_mainwindow.py +++ b/biacv_mainwindow.py @@ -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 ("") diff --git a/biacv_mainwindow.ui b/biacv_mainwindow.ui index dac093c..2aa4322 100644 --- a/biacv_mainwindow.ui +++ b/biacv_mainwindow.ui @@ -1300,6 +1300,54 @@ + + languageslist + activated(QModelIndex) + biacv_mainwindow + on_select_lang() + + + 554 + 224 + + + 730 + 118 + + + + + languageslist + itemSelectionChanged() + biacv_mainwindow + on_select_lang() + + + 617 + 189 + + + 730 + 314 + + + + + updatelanguage + clicked() + biacv_mainwindow + on_update_lang() + + + 605 + 140 + + + 729 + 462 + + + on_add_education() @@ -1317,5 +1365,7 @@ on_update_skill() on_add_lang() on_delete_lang() + on_select_lang() + on_update_lang() diff --git a/biacv_mainwindow_ui.py b/biacv_mainwindow_ui.py index 5f71108..7a91297 100644 --- a/biacv_mainwindow_ui.py +++ b/biacv_mainwindow_ui.py @@ -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): -- 2.20.1