- propertyName = qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole))
- self.pageContent.propertyTable.item(index, 0).setText(propertyName)
-
- def _showPropertyDescription(self):
- self._resetPropertyDescription()
- description = self._projectInfoRetrieve("CONFIGURATIONS")[self._currentModuleConfigurations()][self._currentProperty()]["description"]
- name = self._currentProperty()
- self._currentPropertyItem().setText(name + "\n" + description)
-
- def _setupUi(self):
- self.pageContent.moduleTable.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)
- self.pageContent.moduleTable.horizontalHeader().setStretchLastSection(True)
- self.pageContent.moduleTable.horizontalHeader().setVisible(False)
- self.pageContent.moduleTable.verticalHeader().setResizeMode(QHeaderView.ResizeToContents)
- self.pageContent.moduleTable.verticalHeader().setVisible(False)
- self.pageContent.moduleTable.setColumnCount(2)
- self.pageContent.moduleTable.setRowCount(0)
- self.pageContent.propertyTable.horizontalHeader().setResizeMode(QHeaderView.Stretch)
- self.pageContent.propertyTable.horizontalHeader().setVisible(False)
- self.pageContent.propertyTable.verticalHeader().setResizeMode(QHeaderView.ResizeToContents)
- self.pageContent.propertyTable.verticalHeader().setVisible(False)
- self.pageContent.propertyTable.setColumnCount(2)
- self.pageContent.propertyTable.setRowCount(0)
+ property_name = qvariant_converter.getString(self.pageContent.propertyTable.item(index, 0).data(Qt.UserRole))
+ # Awful solution! Needed because if the user change the module, the selection changed...
+ if property_name not in self.currentModuleConfigurations().keys():
+ break
+ self.pageContent.propertyTable.item(index, 0).setText(self.currentModuleConfigurations()[property_name]['brief'])
+
+ def moduleSelected(self, selectedModule):
+ """
+ Resolves the selection dependencies.
+ """
+ modules = self.projectInfo("MODULES")
+ modules[selectedModule]["enabled"] = True
+ self.setProjectInfo("MODULES", modules)
+ depends = self.projectInfo("MODULES")[selectedModule]["depends"]
+ unsatisfied = []
+ if self.pageContent.automaticFix.isChecked():
+ unsatisfied = self.selectDependencyCheck(selectedModule)
+ if len(unsatisfied) > 0:
+ for module in unsatisfied:
+ modules = self.projectInfo("MODULES")
+ modules[module]["enabled"] = True
+ for category in range(self.pageContent.moduleTree.topLevelItemCount()):
+ item = self.pageContent.moduleTree.topLevelItem(category)
+ for child in range(item.childCount()):
+ if unicode(item.child(child).text(0)) in unsatisfied:
+ item.child(child).setCheckState(0, Qt.Checked)
+
+ def moduleUnselected(self, unselectedModule):
+ """
+ Resolves the unselection dependencies.
+ """
+ modules = self.projectInfo("MODULES")
+ modules[unselectedModule]["enabled"] = False
+ self.setProjectInfo("MODULES", modules)
+ unsatisfied = []
+ if self.pageContent.automaticFix.isChecked():
+ unsatisfied = self.unselectDependencyCheck(unselectedModule)
+ if len(unsatisfied) > 0:
+ message = self.tr("The module %1 is needed by the following modules:\n%2.\n\nDo you want to remove these modules too?")
+ message = message.arg(unselectedModule).arg(", ".join(unsatisfied))
+ choice = QMessageBox.warning(self, self.tr("Dependency error"), message, QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
+ if choice == QMessageBox.Yes:
+ for module in unsatisfied:
+ modules = self.projectInfo("MODULES")
+ modules[module]["enabled"] = False
+ for category in range(self.pageContent.moduleTree.topLevelItemCount()):
+ item = self.pageContent.moduleTree.topLevelItem(category)
+ for child in range(item.childCount()):
+ if unicode(item.child(child).text(0)) in unsatisfied:
+ item.child(child).setCheckState(0, Qt.Unchecked)
+
+ def selectDependencyCheck(self, module):
+ """
+ Returns the list of unsatisfied dependencies after a selection.
+ """
+ unsatisfied = set()
+ modules = self.projectInfo("MODULES")
+ files = self.projectInfo("FILES")
+ for dependency in modules[module]["depends"]:
+ if dependency in modules and not modules[dependency]["enabled"]:
+ unsatisfied |= set([dependency])
+ if dependency not in unsatisfied:
+ unsatisfied |= self.selectDependencyCheck(dependency)
+ if dependency not in modules:
+ if dependency in files:
+ files[dependency] += 1
+ else:
+ files[dependency] = 1
+ self.setProjectInfo("FILES", files)
+ return unsatisfied
+
+ def unselectDependencyCheck(self, dependency):
+ """
+ Returns the list of unsatisfied dependencies after an unselection.
+ """
+ unsatisfied = set()
+ modules = self.projectInfo("MODULES")
+ for module, informations in modules.items():
+ if dependency in informations["depends"] and informations["enabled"]:
+ unsatisfied |= set([module])
+ if dependency not in unsatisfied:
+ unsatisfied |= self.unselectDependencyCheck(module)
+ return unsatisfied
+
+ def removeFileDependencies(self, module):
+ """
+ Removes the files dependencies of the given module.
+ """
+ modules = self.projectInfo("MODULES")
+ files = self.projectInfo("FILES")
+ dependencies = modules[module]["depends"]
+ for dependency in dependencies:
+ if dependency in files:
+ files[dependency] -= 1
+ if files[dependency] == 0:
+ del files[dependency]
+ self.setProjectInfo("FILES", files)
+
+class QControlGroup(QObject):
+ """
+ Simple class that permit to connect different signals of different widgets
+ with a slot that emit a signal. Permits to group widget and to understand which of
+ them has sent the signal.
+ """
+
+ def __init__(self):
+ QObject.__init__(self)
+ self._controls = {}
+
+ def addControl(self, id, control):
+ """
+ Add a control.
+ """
+ self._controls[id] = control
+ if type(control) == QCheckBox:
+ self.connect(control, SIGNAL("stateChanged(int)"), lambda: self.stateChanged(id))
+ elif type(control) == QSpinBox:
+ self.connect(control, SIGNAL("valueChanged(int)"), lambda: self.stateChanged(id))
+ elif type(control) == QComboBox:
+ self.connect(control, SIGNAL("currentIndexChanged(int)"), lambda: self.stateChanged(id))
+ elif type(control) == QDoubleSpinBox:
+ self.connect(control, SIGNAL("valueChanged(double)"), lambda: self.stateChanged(id))
+
+ def clear(self):
+ """
+ Remove all the controls.
+ """
+ self._controls = {}