Add preset load functionality.
[bertos.git] / wizard / BBoardPage.py
index 6b8dddfff2bcc84723cc27848afd27460c00d9a2..2bf90ff38843d975dc3263722b01a9387ba9dc52 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # encoding: utf-8
 #
-# This file is part of slimqc.
+# This file is part of bertos.
 #
 # Bertos is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # Author: Lorenzo Berni <duplo@develer.com>
 #
 
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+
 from BWizardPage import BWizardPage
 
-from const import *
+from BCpuPage import BCpuPage
+from BOutputPage import BOutputPage
+from BRoutePage import BRoutePage
+
+import const
+import qvariant_converter
+from bertos_utils import presetList
 
 class BBoardPage(BWizardPage):
     """
@@ -44,5 +53,62 @@ class BBoardPage(BWizardPage):
     """
     
     def __init__(self):
-        BWizardPage.__init__(self, UI_LOCATION + "/board_select.ui")
+        BWizardPage.__init__(self, const.UI_LOCATION + "/board_select.ui")
         self.setTitle(self.tr("Select the board from the predefined ones"))
+        self._last_selected = None
+
+    ## Overloaded QWizardPage methods ##
+
+    def isComplete(self):
+        """
+        Overload of the QWizardPage isComplete method.
+        """
+        return False
+
+    def nextId(self):
+        """
+        Overload of the QWizardPage nextId method.
+        """
+        return self.wizard().pageIndex(BRoutePage)
+
+    ####
+
+    ## Overloaded BWizardPage methods ##
+
+    def setupUi(self):
+        """
+        Overload of the BWizardPage setupUi method.
+        """
+        pass
+
+    def connectSignals(self):
+        """
+        Overload of the BWizardPage connectSignals method.
+        """
+        pass
+
+    def reloadData(self):
+        """
+        Overload of the BWizardPage reloadData method.
+        """
+        self._fillPresetTree()
+
+    ####
+
+    ## Slots ##
+
+
+    ####
+
+    def _fillPresetTree(self):
+        self.project.loadProjectPresets()
+        preset_tree = self.project.info("PRESET_TREE")
+        for obj in preset_tree['children']:
+            self._createPresetNode(self.pageContent.boardTree, obj)
+
+    def _createPresetNode(self, parent, obj):
+        item_name = obj['info'].get('name', obj['info']['filename'])
+        item = QTreeWidgetItem(parent, [item_name]) 
+        children_dict = obj['children']
+        for child in children_dict:
+            self._createPresetNode(item, child)