1 # class for main window
4 import biacv_mainwindow_ui
as bui
6 class Biacv_mainwindow (PyQt4
.QtGui
.QMainWindow
, bui
.Ui_biacv_mainwindow
):
8 PyQt4
.QtGui
.QMainWindow
.__init
__ (self
)
10 self
.currentfile
= None
12 # add skill set button is clicked
13 def on_add_skill (self
):
14 # if the skill title is blank
15 if self
.skillsettitle
.text () == "":
16 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
18 skillitem
= PyQt4
.QtGui
.QTreeWidgetItem (
20 self
.skillsettitle
.text (),
21 self
.skilldescription
.toPlainText ()
24 self
.skillslist
.addTopLevelItem (skillitem
)
25 self
.reset_skillset_fields ()
27 # clear the skill set fields
28 def reset_skillset_fields (self
):
29 self
.skillsetitle
.setText ("")
30 self
.skilldescription
.setPlainText ("")
32 # update professional history button is clicked
33 def on_update_profession (self
):
34 # get the selected item
35 selitems
= self
.professionlist
.selectedItems ()
37 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected.")
40 # if designation is not set
41 if self
.designation
.text () == "":
42 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
44 # if currently employed in that position, leaving date is to be disabled
45 # and set to "current"
46 if self
.currentemployment
.isChecked ():
47 leavedatestr
= "current"
49 # if the leaving date is < join date
50 if self
.leavedate
.date () < self
.joindate
.date ():
51 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add",
52 "Leaving date cannot be earlier than join date.")
54 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
56 selitem
.setText (0, self
.designation
.text ())
57 selitem
.setText (1, self
.joindate
.date ().toString ("dd MMM, yyyy"))
58 selitem
.setText (2, leavedatestr
)
59 selitem
.setText (3, self
.organization
.text ())
60 selitem
.setText (4, self
.additionalinfo
.text ())
62 # delete professional history button is clicked
63 def on_delete_profession (self
):
64 # get the selected items
65 selitems
= self
.professionlist
.selectedItems ()
67 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No item selected.")
70 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
71 "Are you sure you wish to delete the selected item?",
72 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
74 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
76 self
.professionlist
.takeTopLevelItem (self
.professionlist
.indexOfTopLevelItem (item
))
77 self
.reset_profession_fields ()
79 # add professional history button is clicked
80 def on_add_profession (self
):
81 if self
.designation
.text () == "":
82 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required field is missing.")
84 # if currently employed in that position, leaving date is to be disabled
85 # and set to "current"
86 if self
.currentemployment
.isChecked ():
87 leavedatestr
= "current"
89 # if the leaving date is < join date
90 if self
.leavedate
.date () < self
.joindate
.date ():
91 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add",
92 "Leaving date cannot be earlier than join date.")
94 leavedatestr
= self
.leavedate
.date ().toString ("dd MMM, yyyy")
96 professionitem
= PyQt4
.QtGui
.QTreeWidgetItem (
98 self
.designation
.text (),
99 self
.joindate
.date ().toString ("dd MMM, yyyy"),
101 self
.organization
.text (),
102 self
.additionalinfo
.text ()
106 self
.professionlist
.addTopLevelItem (professionitem
)
108 self
.reset_profession_fields ()
110 # when selection of profession list is changed
111 def on_select_profession (self
):
112 self
.set_profession_fields ()
114 # set the profession fields from the selected item in profession list
115 def set_profession_fields (self
):
116 selitems
= self
.professionlist
.selectedItems ()
119 selitem
= selitems
[0]
120 self
.designation
.setText (selitem
.text (0))
121 self
.joindate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "dd MMM, yyyy"))
122 if selitem
.text (2) == "current":
123 self
.leavedate
.setEnabled (False)
124 self
.currentemployment
.setChecked (True)
126 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text (2), "dd MMM, yyyy"))
127 self
.leavedate
.setEnabled (True)
128 self
.currentemployment
.setChecked (False)
130 self
.organization
.setText (selitem
.text (3))
131 self
.additionalinfo
.setText (selitem
.text (4))
133 def reset_profession_fields (self
):
134 self
.designation
.setText ("")
135 self
.joindate
.setDate (PyQt4
.QtCore
.QDate (2000, 1, 1))
136 self
.leavedate
.setDate (PyQt4
.QtCore
.QDate (2003, 1, 1))
137 self
.currentemployment
.setChecked (False)
138 self
.organization
.setText ("")
139 self
.additionalinfo
.setText ("")
141 # current employment check box is changed
142 def on_change_currentemployment (self
, val
):
144 self
.leavedate
.setEnabled (False)
146 self
.leavedate
.setEnabled (True)
148 # delete educational qualification
149 def on_delete_education (self
):
150 # get the selected items in the education list
151 selitems
= self
.educationlist
.selectedItems ()
152 # if no items are selected
154 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
155 # delete the items after confirmation
157 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
158 "Are you sure you wish to delete selected item?",
159 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
160 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
161 # remove the item selected
162 for item
in selitems
:
163 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
164 self
.reset_education_fields ()
166 # selection is changed
167 def on_select_education (self
):
168 self
.set_education_fields ()
170 # update educational qualification button
171 def on_update_education (self
):
172 selitems
= self
.educationlist
.selectedItems ()
173 # if no item is selected
175 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected")
177 # if the qualification title is not set
178 if self
.degree_name
.text () == "":
179 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
181 selitem
= selitems
[0]
183 selitem
.setText (0, self
.degree_name
.text ())
184 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
185 selitem
.setText (2, self
.institution
.text ())
186 selitem
.setText (3, self
.university
.text ())
187 selitem
.setText (4, self
.grade
.text ())
188 selitem
.setText (5, str (self
.percentage
.value ()))
190 # add educational qualification button
191 def on_add_education (self
):
192 # check if the qualification title is set
193 if self
.degree_name
.text () == "":
194 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required fields is missing.")
196 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
197 self
.degree_name
.text (),
198 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
199 self
.institution
.text (),
200 self
.university
.text (),
202 str (self
.percentage
.value ())
204 self
.educationlist
.addTopLevelItem (educationitem
)
206 self
.reset_education_fields ()
208 # set fields in the education tab from current selected item
209 def set_education_fields (self
):
210 selitems
= self
.educationlist
.selectedItems ()
213 selitem
= selitems
[0]
214 # set the fields to the data in the selected item in the list
215 self
.degree_name
.setText (selitem
.text (0))
216 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
217 self
.institution
.setText (selitem
.text (2))
218 self
.university
.setText (selitem
.text (3))
219 self
.grade
.setText (selitem
.text(4))
220 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
222 # reset fields in the education tab
223 def reset_education_fields (self
):
224 self
.degree_name
.setText ("")
225 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
226 self
.institution
.setText ("")
227 self
.university
.setText ("")
228 self
.grade
.setText ("")
229 self
.percentage
.setValue (50.0)