Add stub of new structure of the wizard preset path.
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 19 Apr 2010 12:36:41 +0000 (12:36 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 19 Apr 2010 12:36:41 +0000 (12:36 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3454 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BBoardPage.py
wizard/BRoutePage.py [new file with mode: 0644]
wizard/BWizard.py
wizard/bertos.py
wizard/ui/board_select.ui
wizard/ui/route_select.ui [new file with mode: 0644]

index 28130c9e4f5cb69cdde79c1662f439df3e247bee..848b0eeb07065cf7a55fa9a136c765eda1317fbc 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
@@ -40,6 +40,7 @@ from BWizardPage import BWizardPage
 
 from BCpuPage import BCpuPage
 from BOutputPage import BOutputPage
+from BRoutePage import BRoutePage
 
 import const
 import qvariant_converter
@@ -62,24 +63,13 @@ class BBoardPage(BWizardPage):
         """
         Overload of the QWizardPage isComplete method.
         """
-        return self.pageContent.boardList.currentItem() is not None
+        return False
 
     def nextId(self):
         """
         Overload of the QWizardPage nextId method.
         """
-        # Stub of nextId logic
-        if self.advanced:
-            self.setProjectInfo("PRESET_ADVANCED_CONFIG", True)
-            return self.wizard().pageIndex(BCpuPage)
-        # Search for suitable toolchains. If there isn't one return 
-        # BToolchainPage id (BToolchainPage should then route to BOutputPage
-        # instead of BModulePage).
-
-        # If a suitable toolchain is found the user has to be prompted
-        # directly to the BOutputPage
-        else:
-            return self.wizard().pageIndex(BOutputPage)
+        return self.wizard().pageIndex(BRoutePage)
 
     ####
 
@@ -95,49 +85,18 @@ class BBoardPage(BWizardPage):
         """
         Overload of the BWizardPage connectSignals method.
         """
-        self.connect(self.pageContent.boardList, SIGNAL('itemSelectionChanged()'), self.itemSelectionChanged)
+        pass
 
     def reloadData(self):
         """
         Overload of the BWizardPage reloadData method.
         """
-        presets = presetList("/Users/duplo/Development/bertos")
-        self.setProjectInfo("PRESETS", presets)
-        self.populatePresetList()
-
-    def populatePresetList(self):
-        self.pageContent.boardList.clear()
-        presets = self.projectInfo("PRESETS")
-        for preset, info in presets.items():
-            board_list = self.pageContent.boardList
-            item = QListWidgetItem(info["PRESET_NAME"], board_list)
-            item.setData(Qt.UserRole, qvariant_converter.convertString(preset))
-            if self._last_selected == preset:
-                self.pageContent.boardList.setCurrentItem(item)
-        if not self._last_selected and self.pageContent.boardList.count():
-            self.pageContent.boardList.setCurrentRow(0)
+        pass
 
     ####
 
     ## Slots ##
 
-    def itemSelectionChanged(self):
-        preset_path = qvariant_converter.getString(self.pageContent.boardList.currentItem().data(Qt.UserRole))
-        presets = self.projectInfo("PRESETS")
-        selected_preset = presets[preset_path]
-        text_components = [
-            "Board: %s" %selected_preset["PRESET_NAME"],
-            "CPU: %s" %selected_preset["CPU_NAME"],
-        ]
-        if selected_preset["PRESET_DESCRIPTION"]:
-            text_components.append("Description: %s" %selected_preset["PRESET_DESCRIPTION"])
-        text = "\n".join(text_components)
-        self.pageContent.descriptionLabel.setText(text)
-        self._last_selected = preset_path
-        self.emit(SIGNAL("completeChanged()"))
 
     ####
 
-    @property
-    def advanced(self):
-        return self.pageContent.advancedCheckBox.isChecked()
\ No newline at end of file
diff --git a/wizard/BRoutePage.py b/wizard/BRoutePage.py
new file mode 100644 (file)
index 0000000..418f2b9
--- /dev/null
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+# As a special exception, you may use this file as part of a free software
+# library without restriction.  Specifically, if other files instantiate
+# templates or use macros or inline functions from this file, or you compile
+# this file and link it with other files to produce an executable, this
+# file does not by itself cause the resulting executable to be covered by
+# the GNU General Public License.  This exception does not however
+# invalidate any other reasons why the executable file might be covered by
+# the GNU General Public License.
+#
+# Copyright 2010 Develer S.r.l. (http://www.develer.com/)
+#
+# $Id$
+#
+# Author: Lorenzo Berni <duplo@develer.com>
+#
+
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+
+from BWizardPage import BWizardPage
+
+from BCpuPage import BCpuPage
+from BOutputPage import BOutputPage
+
+import const
+import qvariant_converter
+from bertos_utils import presetList
+
+class BRoutePage(BWizardPage):
+    """
+    Let the user choice Advanced or base route.
+    """
+    
+    def __init__(self):
+        BWizardPage.__init__(self, const.UI_LOCATION + "/route_select.ui")
+        self.setTitle(self.tr("Select Advanced or Base setup"))
+        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.
+        """
+        # Route to Toolchain page if the user select advanced
+        # or to Output page if the user select base
+        return self.wizard().pageIndex(BToolchainPage)
+
+    ####
+
+    ## 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.
+        """
+        pass
+
+    ####
+
+    ## Slots ##
+
+
+    ####
+
+    @property
+    def advanced(self):
+        return self.pageContent.advancedButton.isChecked()
index 11a2dd263b8fc70d584e7f781fe4c4d88865e1bc..4b7ab45deed1bc1c3c85c09603eeb8863374c775 100644 (file)
@@ -69,12 +69,13 @@ class BWizard(QWizard):
         """
         Adds the pages in the wizard.
         """
-        self._page_list = page_list
-        for i, page in enumerate(self._page_list):
+        self._page_dict = {}
+        for i, page in enumerate(page_list):
+            self._page_dict[page] = i
             self.setPage(i, page())
 
     def pageIndex(self, page_class):
-        return self._page_list.index(page_class)
+        return self._page_dict[page_class]
 
     def connectSignals(self):
         """
index 0e3206c2144c6a2a603b35168e9dd60d4410d577..ce6bd30f2970f54904a220b8ea4982cc9466d4d1 100755 (executable)
@@ -49,6 +49,7 @@ from BWizard import BWizard
 from BIntroPage import BIntroPage
 from BFolderPage import BFolderPage
 from BBoardPage import BBoardPage
+from BRoutePage import BRoutePage
 from BOpenPage import BOpenPage
 from BVersionPage import BVersionPage
 from BCpuPage import BCpuPage
@@ -66,7 +67,7 @@ from LoadException import VersionException, ToolchainException
 
 def newProject():
     QApplication.instance().project = BProject()
-    page_list = [BIntroPage, BFolderPage, BVersionPage, BBoardPage, BCpuPage, BToolchainPage, BModulePage, BOutputPage, BCreationPage, BFinalPage]
+    page_list = [BIntroPage, BFolderPage, BVersionPage, BBoardPage, BRoutePage, BCpuPage, BToolchainPage, BModulePage, BOutputPage, BCreationPage, BFinalPage]
     wizard = BWizard(page_list)
     wizard.show()
     wizard.exec_()
index ad9197d6d23832be654af849109ebd5b34b5250f..f610d358ff4628b4a98f61b19c6ada47e18ea123 100644 (file)
    <item>
     <layout class="QVBoxLayout" name="verticalLayout_2">
      <item>
-      <widget class="QListWidget" name="boardList">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="minimumSize">
-        <size>
-         <width>170</width>
-         <height>0</height>
-        </size>
-       </property>
+      <widget class="QTreeWidget" name="boardTree">
+       <attribute name="headerVisible">
+        <bool>false</bool>
+       </attribute>
+       <attribute name="headerVisible">
+        <bool>false</bool>
+       </attribute>
+       <column>
+        <property name="text">
+         <string notr="true">1</string>
+        </property>
+       </column>
       </widget>
      </item>
      <item>
diff --git a/wizard/ui/route_select.ui b/wizard/ui/route_select.ui
new file mode 100644 (file)
index 0000000..b8de057
--- /dev/null
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QRadioButton" name="baseButton">
+     <property name="text">
+      <string>Base</string>
+     </property>
+     <property name="checked">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QRadioButton" name="advancedButton">
+     <property name="text">
+      <string>Advanced</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="advancedGroupBox">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+     <property name="title">
+      <string>Advanced options</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
+      <item>
+       <widget class="QCheckBox" name="emptyCheckBox">
+        <property name="text">
+         <string>Empty main.c</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>