Add hw error detect.
[bertos.git] / wizard / BModulePage.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # This file is part of BeRTOS.
5 #
6 # Bertos is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 #
20 # As a special exception, you may use this file as part of a free software
21 # library without restriction.  Specifically, if other files instantiate
22 # templates or use macros or inline functions from this file, or you compile
23 # this file and link it with other files to produce an executable, this
24 # file does not by itself cause the resulting executable to be covered by
25 # the GNU General Public License.  This exception does not however
26 # invalidate any other reasons why the executable file might be covered by
27 # the GNU General Public License.
28 #
29 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
30 #
31 # $Id$
32 #
33 # Author: Lorenzo Berni <duplo@develer.com>
34 #
35
36 import os
37
38 from PyQt4.QtCore import *
39 from PyQt4.QtGui import *
40 from BWizardPage import *
41 import bertos_utils
42
43 from bertos_utils import SupportedException
44 from DefineException import *
45 from const import *
46
47 class BModulePage(BWizardPage):
48     """
49     Page of the wizard that permits to select and configurate the BeRTOS modules.
50     """
51     
52     def __init__(self):
53         BWizardPage.__init__(self, UI_LOCATION + "/module_select.ui")
54         self.setTitle(self.tr("Configure the BeRTOS modules"))
55         self._control_group = QControlGroup()
56         ## special connection needed for the QControlGroup
57         self.connect(self._control_group, SIGNAL("stateChanged"), self.saveValue)
58     
59     ## Overloaded BWizardPage methods ##
60
61     def setupUi(self):
62         """
63         Overload of BWizardPage setupUi method.
64         """
65         self.pageContent.moduleTree.clear()
66         self.pageContent.moduleTree.setHeaderHidden(True)
67         self.pageContent.propertyTable.horizontalHeader().setResizeMode(QHeaderView.Stretch)
68         self.pageContent.propertyTable.horizontalHeader().setVisible(False)
69         self.pageContent.propertyTable.verticalHeader().setResizeMode(QHeaderView.ResizeToContents)
70         self.pageContent.propertyTable.verticalHeader().setVisible(False)
71         self.pageContent.propertyTable.setColumnCount(2)
72         self.pageContent.propertyTable.setRowCount(0)
73         self.pageContent.moduleLabel.setVisible(False)
74         self.pageContent.warningLabel.setVisible(False)
75     
76     def connectSignals(self):
77         """
78         Overload of the BWizardPage connectSignals method.
79         """
80         self.connect(self.pageContent.moduleTree, SIGNAL("itemPressed(QTreeWidgetItem*, int)"), self.fillPropertyTable)
81         self.connect(self.pageContent.moduleTree, SIGNAL("itemPressed(QTreeWidgetItem*, int)"), self.moduleClicked)
82         self.connect(self.pageContent.moduleTree, SIGNAL("itemChanged(QTreeWidgetItem*, int)"), self.dependencyCheck)
83
84     def reloadData(self, previous_id=None):
85         """
86         Overload of the BWizardPage reloadData method.
87         """
88         # Check if the user are approaching this page from the previous or the
89         # next one.
90         if previous_id is None or previous_id < self.wizard().currentId():
91             try:
92                 QApplication.instance().setOverrideCursor(Qt.WaitCursor)
93                 self.setupUi()
94                 self.loadModuleData()
95                 self.fillModuleTree()
96             finally:
97                 QApplication.instance().restoreOverrideCursor()
98     
99     ####
100     
101     ## Slots ##
102
103     def moduleClicked(self, item, column):
104         self.setBold(item, False)
105
106     def fillPropertyTable(self):
107         """
108         Slot called when the user selects a module from the module tree.
109         Fills the property table using the configuration parameters defined in
110         the source tree.
111         """
112         module = self.currentModule()
113         if module:
114             try:
115                 supported = bertos_utils.isSupported(self.project, module=module)
116             except SupportedException, e:
117                 self.exceptionOccurred(self.tr("Error evaluating \"%1\" for module %2").arg(e.support_string).arg(module))
118                 supported = True
119             self._control_group.clear()
120             configuration = self.projectInfo("MODULES")[module]["configuration"]
121             module_description = self.projectInfo("MODULES")[module]["description"]
122             self.pageContent.moduleLabel.setText(module_description)
123             self.pageContent.moduleLabel.setVisible(True)
124             if not supported:
125                 self.pageContent.warningLabel.setVisible(True)
126                 selected_cpu = self.projectInfo("CPU_NAME")
127                 self.pageContent.warningLabel.setText(self.tr("<font color='#FF0000'>Warning: the selected module, \
128                     is not completely supported by the %1.</font>").arg(selected_cpu))
129             else:
130                 self.pageContent.warningLabel.setVisible(False)
131             self.pageContent.propertyTable.clear()
132             self.pageContent.propertyTable.setRowCount(0)
133             if configuration != "":
134                 configurations = self.projectInfo("CONFIGURATIONS")[configuration]
135                 param_list = sorted(configurations["paramlist"])
136                 index = 0
137                 for i, property in param_list:
138                     if "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "autoenabled":
139                         # Doesn't show the hidden fields
140                         continue
141                     try:
142                         param_supported = bertos_utils.isSupported(self.project, property_id=(configuration, property))
143                     except SupportedException, e:
144                         self.exceptionOccurred(self.tr("Error evaluating \"%1\" for parameter %2").arg(e.support_string).arg(property))
145                         param_supported = True
146                     if not param_supported:
147                         # Doesn't show the unsupported parameters
148                         continue
149                     # Set the row count to the current index + 1
150                     self.pageContent.propertyTable.setRowCount(index + 1)
151                     item = QTableWidgetItem(configurations[property]["brief"])
152                     item.setFlags(item.flags() & ~Qt.ItemIsSelectable)
153                     item.setToolTip(property)
154                     item.setData(Qt.UserRole, qvariant_converter.convertString(property))
155                     self.pageContent.propertyTable.setItem(index, 0, item)
156                     if "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "boolean":
157                         self.insertCheckBox(index, configurations[property]["value"])
158                     elif "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "enum":
159                         self.insertComboBox(index, configurations[property]["value"], configurations[property]["informations"]["value_list"])
160                     elif "type" in configurations[property]["informations"] and configurations[property]["informations"]["type"] == "int":
161                         self.insertSpinBox(index, configurations[property]["value"], configurations[property]["informations"])
162                     else:
163                         # Not defined type, rendered as a text field
164                         self.pageContent.propertyTable.setItem(index, 1, QTableWidgetItem(configurations[property]["value"]))
165                     index += 1
166             if self.pageContent.propertyTable.rowCount() == 0:
167                 module_label = self.pageContent.moduleLabel.text()
168                 module_label += "\n\nNo configuration needed."
169                 self.pageContent.moduleLabel.setText(module_label) 
170         else:
171             self.pageContent.moduleLabel.setText("")
172             self.pageContent.moduleLabel.setVisible(False)
173             self.pageContent.propertyTable.clear()
174             self.pageContent.propertyTable.setRowCount(0)
175
176     def dependencyCheck(self, item):
177         """
178         Checks the dependencies of the module associated with the given item.
179         """
180         checked = False
181         module = unicode(item.text(0))
182         if item.checkState(0) == Qt.Checked:
183             self.moduleSelected(module)
184         else:
185             self.moduleUnselected(module)
186             self.removeFileDependencies(module)
187
188     def showPropertyDescription(self):
189         """
190         Slot called when the property selection changes. Shows the description
191         of the selected property.
192         """
193         self.resetPropertyDescription()
194         configurations = self.currentModuleConfigurations()
195         if self.currentProperty() in configurations:
196             description = configurations[self.currentProperty()]["brief"]
197             name = self.currentProperty()
198             self.currentPropertyItem().setText(description + "\n" + name)
199
200     def saveValue(self, index):
201         """
202         Slot called when the user modifies one of the configuration parameters.
203         It stores the new value."""
204         property = qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole))
205         configuration = self.projectInfo("MODULES")[self.currentModule()]["configuration"]
206         configurations = self.projectInfo("CONFIGURATIONS")
207         if "type" not in configurations[configuration][property]["informations"] or configurations[configuration][property]["informations"]["type"] == "int":
208             configurations[configuration][property]["value"] = unicode(int(self.pageContent.propertyTable.cellWidget(index, 1).value()))
209         elif configurations[configuration][property]["informations"]["type"] == "enum":
210             configurations[configuration][property]["value"] = unicode(self.pageContent.propertyTable.cellWidget(index, 1).currentText())
211         elif configurations[configuration][property]["informations"]["type"] == "boolean":
212             if self.pageContent.propertyTable.cellWidget(index, 1).isChecked():
213                 configurations[configuration][property]["value"] = "1"
214             else:
215                 configurations[configuration][property]["value"] = "0"
216         self.setProjectInfo("CONFIGURATIONS", configurations)
217         if self.moduleItem(self.currentModule()).checkState(0) == Qt.Checked:
218             self.dependencyCheck(self.moduleItem(self.currentModule()))
219
220     ####
221     
222     def loadModuleData(self):
223         """
224         Loads the module data.
225         """
226         # Do not load the module data again when the Wizard is in editing mode
227         # or when it's working on a preset.
228         if not self.project.edit and not self.project.from_preset:
229             # Load the module data every time so that if the user changed the cpu
230             # the right configurations are picked up.
231             try:
232                 self.project.loadModuleData()
233             except ModuleDefineException, e:
234                 self.exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line))
235             except EnumDefineException, e:
236                 self.exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line))
237             except ConfigurationDefineException, e:
238                 self.exceptionOccurred(self.tr("Error parsing line '%2' in file %1").arg(e.path).arg(e.line))
239     
240     def fillModuleTree(self):
241         """
242         Fills the module tree with the module entries separated in categories.
243         """
244         self.pageContent.moduleTree.clear()
245         modules = self.projectInfo("MODULES")
246         if not modules:
247             return
248         categories = {}
249         for module, information in modules.items():
250             if information["category"] not in categories:
251                 categories[information["category"]] = []
252             categories[information["category"]].append(module)
253         for category, module_list in categories.items():
254             item = QTreeWidgetItem(QStringList([category]))
255             for module in module_list:
256                 enabled = modules[module]["enabled"]
257                 module_item = QTreeWidgetItem(item, QStringList([module]))
258                 try:
259                     supported = bertos_utils.isSupported(self.project, module=module)
260                 except SupportedException, e:
261                     self.exceptionOccurred(self.tr("Error evaluating \"%1\" for module %2").arg(e.support_string).arg(module))
262                     supported = True
263                 if not supported:
264                     module_item.setForeground(0, QBrush(QColor(Qt.red)))
265                 if enabled:
266                     module_item.setCheckState(0, Qt.Checked)
267                 else:
268                     module_item.setCheckState(0, Qt.Unchecked)
269             self.pageContent.moduleTree.addTopLevelItem(item)
270         self.pageContent.moduleTree.sortItems(0, Qt.AscendingOrder)
271         self.fillPropertyTable()
272             
273     def insertCheckBox(self, index, value):
274         """
275         Inserts in the table at index a checkbox for a boolean property setted
276         to value.
277         """
278         check_box = QCheckBox()
279         self.pageContent.propertyTable.setCellWidget(index, 1, check_box)
280         if value == "1":
281             check_box.setChecked(True)
282         else:
283             check_box.setChecked(False)
284         self._control_group.addControl(index, check_box)
285     
286     def insertComboBox(self, index, value, value_list):
287         """
288         Inserts in the table at index a combobox for an enum property setted
289         to value.
290         """
291         try:
292             enum = self.projectInfo("LISTS")[value_list]
293             combo_box = QComboBox()
294             self.pageContent.propertyTable.setCellWidget(index, 1, combo_box)
295             for i, element in enumerate(enum):
296                 combo_box.addItem(element)
297                 if element == value:
298                     combo_box.setCurrentIndex(i)
299             self._control_group.addControl(index, combo_box)
300         except KeyError:
301             self.exceptionOccurred(self.tr("Define list \"%1\" not found. Check definition files.").arg(value_list))
302             self.pageContent.propertyTable.setItem(index, 1, QTableWidgetItem(value))
303     
304     def insertSpinBox(self, index, value, informations):
305         """
306         Inserts in the table at index a spinbox for an int, a long or an unsigned
307         long property setted to value.
308         """
309         # int, long or undefined type property
310         spin_box = None
311         if bertos_utils.isLong(informations) or bertos_utils.isUnsignedLong(informations):
312             spin_box = QDoubleSpinBox()
313             spin_box.setDecimals(0)
314         else:
315             spin_box = QSpinBox()
316         self.pageContent.propertyTable.setCellWidget(index, 1, spin_box)
317         minimum = -32768
318         maximum = 32767
319         suff = ""
320         if bertos_utils.isLong(informations):
321             minimum = -2147483648
322             maximum = 2147483647
323             suff = "L"
324         elif bertos_utils.isUnsigned(informations):
325             minimum = 0
326             maximum = 65535
327             suff = "U"
328         elif bertos_utils.isUnsignedLong(informations):
329             minimum = 0
330             maximum = 4294967295
331             suff = "UL"
332         if "min" in informations:
333             minimum = int(informations["min"])
334         if "max" in informations:
335             maximum = int(informations["max"])
336         spin_box.setRange(minimum, maximum)
337         spin_box.setSuffix(suff)
338         spin_box.setValue(int(value.replace("L", "").replace("U", "")))
339         self._control_group.addControl(index, spin_box)
340         
341     
342     def currentModule(self):
343         """
344         Retuns the current module name.
345         """
346         current_module = self.pageContent.moduleTree.currentItem()
347         # return only the child items
348         if current_module and current_module.parent():
349             return unicode(current_module.text(0))
350         else:
351             return None
352
353     def moduleItem(self, module):
354         for top_level_index in range(self.pageContent.moduleTree.topLevelItemCount()):
355             top_level_item = self.pageContent.moduleTree.topLevelItem(top_level_index)
356             for child_index in range(top_level_item.childCount()):
357                 child_item = top_level_item.child(child_index)
358                 if unicode(child_item.text(0)) == module:
359                     return child_item
360         return None
361     
362     def currentModuleConfigurations(self):
363         """
364         Returns the current module configuration.
365         """
366         return self.configurations(self.currentModule())
367     
368     def currentProperty(self):
369         """
370         Rerturns the current property from the property table.
371         """
372         return qvariant_converter.getString(self.pageContent.propertyTable.item(self.pageContent.propertyTable.currentRow(), 0).data(Qt.UserRole))
373     
374     def currentPropertyItem(self):
375         """
376         Returns the QTableWidgetItem of the current property.
377         """
378         return self.pageContent.propertyTable.item(self.pageContent.propertyTable.currentRow(), 0)
379     
380     def configurations(self, module):
381         """
382         Returns the configuration for the selected module.
383         """
384         configuration = []
385         if module:
386             # On linux platform it seems that the behaviour of the focus
387             # changing is a bit different from the mac one. So if module is
388             # None then no configurations should be returned.
389             configuration = self.projectInfo("MODULES")[module]["configuration"]
390         if len(configuration) > 0:
391             return self.projectInfo("CONFIGURATIONS")[configuration]
392         else:
393             return {}
394     
395     def resetPropertyDescription(self):
396         """
397         Resets the label for each property table entry.
398         """
399         for index in range(self.pageContent.propertyTable.rowCount()):
400             property_name = qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole))
401             # Awful solution! Needed because if the user change the module, the selection changed...
402             if property_name not in self.currentModuleConfigurations():
403                 break
404             self.pageContent.propertyTable.item(index, 0).setText(self.currentModuleConfigurations()[property_name]['brief'])
405     
406     def setBold(self, item, bold):
407         self.pageContent.moduleTree.blockSignals(True)
408         font = item.font(0)
409         font.setBold(bold)
410         item.setFont(0, font)
411         self.pageContent.moduleTree.blockSignals(False)
412
413     def isBold(self, item):
414         return item.font(0).bold()
415
416     def moduleSelected(self, selectedModule):
417         """
418         Resolves the selection dependencies.
419         """
420         try:
421             qApp.setOverrideCursor(Qt.WaitCursor)
422             modules = self.projectInfo("MODULES")
423             modules[selectedModule]["enabled"] = True
424             self.setProjectInfo("MODULES", modules)
425             depends = self.projectInfo("MODULES")[selectedModule]["depends"]
426             unsatisfied = []
427             if self.pageContent.automaticFix.isChecked():
428                 unsatisfied = self.selectDependencyCheck(selectedModule)
429             if len(unsatisfied) > 0:
430                 for module in unsatisfied:
431                     modules = self.projectInfo("MODULES")
432                     modules[module]["enabled"] = True
433                 for category in range(self.pageContent.moduleTree.topLevelItemCount()):
434                     item = self.pageContent.moduleTree.topLevelItem(category)
435                     for child in range(item.childCount()):
436                         if unicode(item.child(child).text(0)) in unsatisfied:
437                             self.setBold(item.child(child), True)
438                             self.setBold(item, True)
439                             item.child(child).setCheckState(0, Qt.Checked)
440         finally:
441             qApp.restoreOverrideCursor()
442     
443     def moduleUnselected(self, unselectedModule):
444         """
445         Resolves the unselection dependencies.
446         """
447         try:
448             qApp.setOverrideCursor(Qt.WaitCursor)
449             modules = self.projectInfo("MODULES")
450             modules[unselectedModule]["enabled"] = False
451             self.setProjectInfo("MODULES", modules)
452             unsatisfied = []
453             unsatisfied_params = []
454             if self.pageContent.automaticFix.isChecked():
455                 unsatisfied, unsatisfied_params = self.unselectDependencyCheck(unselectedModule)
456             if len(unsatisfied) > 0 or len(unsatisfied_params) > 0:
457                 message = []
458                 heading = self.tr("The module %1 is needed by").arg(unselectedModule)
459                 message.append(heading)
460                 module_list = ", ".join(unsatisfied)
461                 param_list = ", ".join(["%s (%s)" %(param_name, module) for module, param_name in unsatisfied_params])
462                 if module_list:
463                     message.append(QString(module_list))
464                 if module_list and param_list:
465                     message.append(self.tr("and by"))
466                 if param_list:
467                     message.append(QString(param_list))
468                 message_str = QStringList(message).join(" ")
469                 message_str.append(self.tr("\n\nDo you want to automatically fix these conflicts?"))
470                 qApp.restoreOverrideCursor()
471                 choice = QMessageBox.warning(self, self.tr("Dependency error"), message_str, QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
472                 qApp.setOverrideCursor(Qt.WaitCursor)
473                 if choice == QMessageBox.Yes:
474                     for module in unsatisfied:
475                         modules = self.projectInfo("MODULES")
476                         modules[module]["enabled"] = False
477                     for category in range(self.pageContent.moduleTree.topLevelItemCount()):
478                         item = self.pageContent.moduleTree.topLevelItem(category)
479                         self.setBold(item, False)
480                         for child in range(item.childCount()):
481                             if unicode(item.child(child).text(0)) in unsatisfied:
482                                 self.setBold(item.child(child), False)
483                                 item.child(child).setCheckState(0, Qt.Unchecked)
484                             else:
485                                 if self.isBold(item.child(child)):
486                                     self.setBold(item, True)
487                     for module, param in unsatisfied_params:
488                         configuration_file = self.projectInfo("MODULES")[module]["configuration"]
489                         configurations = self.projectInfo("CONFIGURATIONS")
490                         configurations[configuration_file][param]["value"] = "0"
491                         self.setProjectInfo("CONFIGURATIONS", configurations)
492         finally:
493             qApp.restoreOverrideCursor()
494     
495     def selectDependencyCheck(self, module):
496         """
497         Returns the list of unsatisfied dependencies after a selection.
498         """
499         unsatisfied = set()
500         modules = self.projectInfo("MODULES")
501         files = self.projectInfo("FILES")
502         configurations = self.projectInfo("CONFIGURATIONS").get(modules[module]["configuration"], {"paramlist": ()})
503         conditional_deps = ()
504         for i, param_name in configurations["paramlist"]:
505             information = configurations[param_name]
506             if information["informations"]["type"] == "boolean" and \
507                 information["value"] != "0" and \
508                 "conditional_deps" in information["informations"]:
509
510                 conditional_deps += information["informations"]["conditional_deps"]
511
512         for dependency in modules[module]["depends"] + conditional_deps:
513             if dependency in modules and not modules[dependency]["enabled"]:
514                 unsatisfied |= set([dependency])
515                 if dependency not in unsatisfied:
516                     unsatisfied |= self.selectDependencyCheck(dependency)
517             if dependency not in modules:
518                 if dependency in files:
519                     files[dependency] += 1
520                 else:
521                     files[dependency] = 1
522         self.setProjectInfo("FILES", files)
523         return unsatisfied
524     
525     def unselectDependencyCheck(self, dependency):
526         """
527         Returns the list of unsatisfied dependencies after an unselection.
528         """
529         unsatisfied = set()
530         unsatisfied_params = set()
531         modules = self.projectInfo("MODULES")
532         for module, informations in modules.items():
533             configurations = self.projectInfo("CONFIGURATIONS").get(informations["configuration"], {"paramlist": ()})
534             conditional_deps = {}
535             for i, param_name in configurations["paramlist"]:
536                 information = configurations[param_name]
537                 if information["informations"]["type"] == "boolean" and information["value"] != "0" and "conditional_deps" in information["informations"]:
538                     for dep in information["informations"]["conditional_deps"]:
539                         if not dep in conditional_deps:
540                             conditional_deps[dep] = []
541                         conditional_deps[dep].append((module, param_name))
542             if dependency in informations["depends"] and informations["enabled"]:
543                 unsatisfied |= set([module])
544                 if dependency not in unsatisfied:
545                     tmp = self.unselectDependencyCheck(module)
546                     unsatisfied |= tmp[0]
547                     unsatisfied_params |= tmp[1]
548             if dependency in conditional_deps:
549                 unsatisfied_params |= set(conditional_deps[dependency])
550         return unsatisfied, unsatisfied_params
551     
552     def removeFileDependencies(self, module):
553         """
554         Removes the files dependencies of the given module.
555         """
556         modules = self.projectInfo("MODULES")
557         files = self.projectInfo("FILES")
558         dependencies = modules[module]["depends"]
559         for dependency in dependencies:
560             if dependency in files:
561                 files[dependency] -= 1
562                 if files[dependency] == 0:
563                     del files[dependency]
564         self.setProjectInfo("FILES", files)
565
566 class QControlGroup(QObject):
567     """
568     Simple class that permit to connect different signals of different widgets
569     with a slot that emit a signal. Permits to group widget and to understand which of
570     them has sent the signal.
571     """
572     
573     def __init__(self):
574         QObject.__init__(self)
575         self._controls = {}
576     
577     def addControl(self, id, control):
578         """
579         Add a control.
580         """
581         self._controls[id] = control
582         if type(control) == QCheckBox:
583             self.connect(control, SIGNAL("stateChanged(int)"), lambda: self.stateChanged(id))
584         elif type(control) == QSpinBox:
585             self.connect(control, SIGNAL("valueChanged(int)"), lambda: self.stateChanged(id))
586         elif type(control) == QComboBox:
587             self.connect(control, SIGNAL("currentIndexChanged(int)"), lambda: self.stateChanged(id))
588         elif type(control) == QDoubleSpinBox:
589             self.connect(control, SIGNAL("valueChanged(double)"), lambda: self.stateChanged(id))
590     
591     def clear(self):
592         """
593         Remove all the controls.
594         """
595         self._controls = {}
596     
597     def stateChanged(self, id):
598         """
599         Slot called when the value of one of the stored widget changes. It emits
600         another signal.
601         """
602         self.emit(SIGNAL("stateChanged"), id)