From: duplo Date: Mon, 19 Apr 2010 12:36:41 +0000 (+0000) Subject: Add stub of new structure of the wizard preset path. X-Git-Tag: 2.5.0~454 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=e3892547e4cd75c1ec039e42ff7db425be9d7b72;p=bertos.git Add stub of new structure of the wizard preset path. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3454 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/BBoardPage.py b/wizard/BBoardPage.py index 28130c9e..848b0eeb 100644 --- a/wizard/BBoardPage.py +++ b/wizard/BBoardPage.py @@ -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 index 00000000..418f2b95 --- /dev/null +++ b/wizard/BRoutePage.py @@ -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 +# + +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() diff --git a/wizard/BWizard.py b/wizard/BWizard.py index 11a2dd26..4b7ab45d 100644 --- a/wizard/BWizard.py +++ b/wizard/BWizard.py @@ -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): """ diff --git a/wizard/bertos.py b/wizard/bertos.py index 0e3206c2..ce6bd30f 100755 --- a/wizard/bertos.py +++ b/wizard/bertos.py @@ -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_() diff --git a/wizard/ui/board_select.ui b/wizard/ui/board_select.ui index ad9197d6..f610d358 100644 --- a/wizard/ui/board_select.ui +++ b/wizard/ui/board_select.ui @@ -17,19 +17,18 @@ - - - - 0 - 0 - - - - - 170 - 0 - - + + + false + + + false + + + + 1 + + diff --git a/wizard/ui/route_select.ui b/wizard/ui/route_select.ui new file mode 100644 index 00000000..b8de0575 --- /dev/null +++ b/wizard/ui/route_select.ui @@ -0,0 +1,57 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Base + + + true + + + + + + + Advanced + + + + + + + false + + + Advanced options + + + + + + Empty main.c + + + + + + + + + + +