Rewrite the BModulePage class
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 23 Jan 2009 13:57:08 +0000 (13:57 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 23 Jan 2009 13:57:08 +0000 (13:57 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2214 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BModulePage.py
wizard/module_select.ui

index deefec6d76bf4772b88f8eceacbb57839df9406c..9c26fcbecf2df11166c6f3ff69593cd0326abfe2 100644 (file)
@@ -25,21 +25,84 @@ class BModulePage(BWizardPage):
         self._connectSignals()
     
     def reloadData(self):
+        self._setupButtonGroup()
         self._loadModuleData()
+        self._fillModuleTable()
+    
+    def _setupButtonGroup(self):
+        self._buttonGroup = QButtonGroup()
+        self._buttonGroup.setExclusive(False)
     
     def _loadModuleData(self):
         modules = bertos_utils.loadModuleInfosDict(self._projectInfoRetrieve("SOURCES_PATH"))
         lists = bertos_utils.loadDefineListsDict(self._projectInfoRetrieve("SOURCES_PATH"))
         configurations = {}
         for module, informations in modules.items():
-            configurations.update(bertos_utils.loadConfigurationInfos(self._projectInfoRetrieve("SOURCES_PATH") + "/" + informations["configuration"]))
-        print "modules", modules
-        print "lists", lists
-        print "configurations", configurations
+            configurations[informations["configuration"]] = bertos_utils.loadConfigurationInfos(self._projectInfoRetrieve("SOURCES_PATH") +
+                                                                                                "/" + informations["configuration"])
+        self._projectInfoStore("MODULES", modules)
+        self._projectInfoStore("LISTS", lists)
+        self._projectInfoStore("CONFIGURATIONS", configurations)
+    
+    def _fillModuleTable(self):
+        modules = self._projectInfoRetrieve("MODULES")
+        self.pageContent.moduleTable.setRowCount(len(modules))
+        for index, module in enumerate(modules):
+            self.pageContent.moduleTable.setItem(index, 1, QTableWidgetItem(module))
+            checkBox = QCheckBox()
+            self._buttonGroup.addButton(checkBox, index)
+            self.pageContent.moduleTable.setCellWidget(index, 0, checkBox)
+    
+    def _fillPropertyTable(self):
+        module = unicode(self.pageContent.moduleTable.item(self.pageContent.moduleTable.currentRow(), 1).text())
+        configuration = self._projectInfoRetrieve("MODULES")[module]["configuration"]
+        configurations = self._projectInfoRetrieve("CONFIGURATIONS")[configuration]
+        self.pageContent.propertyTable.clear()
+        self.pageContent.propertyTable.setRowCount(len(configurations))
+        for index, parameter in enumerate(configurations):
+            self.pageContent.propertyTable.setItem(index, 0, QTableWidgetItem(parameter))
+            if "type" in configurations[parameter]["informations"].keys() and configurations[parameter]["informations"]["type"] == "boolean":
+                ## boolean parameter
+                checkBox = QCheckBox()
+                self.pageContent.propertyTable.setCellWidget(index, 1, checkBox)
+                if configurations[parameter]["value"] == "1":
+                    checkBox.setChecked(True)
+                else:
+                    checkBox.setChecked(False)
+            elif "type" in configurations[parameter]["informations"].keys() and configurations[parameter]["informations"]["type"] == "enum":
+                ## enum parameter
+                comboBox = QComboBox()
+                self.pageContent.propertyTable.setCellWidget(index, 1, comboBox)
+                enum = self._projectInfoRetrieve("LISTS")[configurations[parameter]["informations"]["value_list"]]
+                for element in enum:
+                    comboBox.addItem(element)
+            else:
+                ## int, long or undefined type parameter
+                spinBox = QSpinBox()
+                self.pageContent.propertyTable.setCellWidget(index, 1, spinBox)
+                if "min" in configurations[parameter]["informations"].keys():
+                    minimum = int(configurations[parameter]["informations"]["min"])
+                else:
+                    minimum = -32768
+                spinBox.setMinimum(minimum)
+                if "max" in configurations[parameter]["informations"].keys():
+                    maximum = int(configurations[parameter]["infomations"]["max"])
+                else:
+                    maximum = 32767
+                spinBox.setMaximum(maximum)
+                if "long" in configurations[parameter]["informations"].keys() and configurations[parameter]["informations"]["long"] == "True":
+                    spinBox.setSuffix("L")
+                spinBox.setValue(int(configurations[parameter]["value"].replace("L", "")))
     
     def _setupUi(self):
-        self.pageContent.moduleList.setSortingEnabled(True)
-        self.pageContent.propertyTable.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)
+        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)
@@ -47,4 +110,4 @@ class BModulePage(BWizardPage):
         self.pageContent.propertyTable.setRowCount(0)
     
     def _connectSignals(self):
-        pass
\ No newline at end of file
+        self.connect(self.pageContent.moduleTable, SIGNAL("itemSelectionChanged()"), self._fillPropertyTable)
\ No newline at end of file
index a6400fee855cd8472312f65fc3daa97e41d22a03..d9b8486ea85eefb70fd3922496be5fe6d5300a93 100644 (file)
   </property>
   <layout class="QHBoxLayout" name="horizontalLayout" >
    <item>
-    <widget class="QListWidget" name="moduleList" >
-     <property name="sizePolicy" >
-      <sizepolicy vsizetype="Expanding" hsizetype="Fixed" >
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
+    <widget class="QTableWidget" name="moduleTable" >
      <property name="maximumSize" >
       <size>
-       <width>120</width>
+       <width>150</width>
        <height>16777215</height>
       </size>
      </property>
+     <property name="editTriggers" >
+      <set>QAbstractItemView::NoEditTriggers</set>
+     </property>
+     <property name="selectionMode" >
+      <enum>QAbstractItemView::SingleSelection</enum>
+     </property>
+     <property name="selectionBehavior" >
+      <enum>QAbstractItemView::SelectRows</enum>
+     </property>
+     <property name="showGrid" >
+      <bool>false</bool>
+     </property>
     </widget>
    </item>
    <item>