From: duplo Date: Fri, 2 Apr 2010 10:31:19 +0000 (+0000) Subject: Add some logic to display the presets into the preset page. X-Git-Tag: 2.5.0~525 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=4b0ca7f4b9df26e052b13a9d6b99f693047b63cc;p=bertos.git Add some logic to display the presets into the preset page. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3383 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/BBoardPage.py b/wizard/BBoardPage.py index 54cc94cc..28130c9e 100644 --- a/wizard/BBoardPage.py +++ b/wizard/BBoardPage.py @@ -106,10 +106,11 @@ class BBoardPage(BWizardPage): 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["name"], board_list) + 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) @@ -124,7 +125,14 @@ class BBoardPage(BWizardPage): preset_path = qvariant_converter.getString(self.pageContent.boardList.currentItem().data(Qt.UserRole)) presets = self.projectInfo("PRESETS") selected_preset = presets[preset_path] - self.pageContent.descriptionLabel.setText(selected_preset['description']) + 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()")) diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index a30aaed4..4c6c3317 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -79,22 +79,32 @@ def presetList(directory): """ Return the list of the preset found in the selected BeRTOS Version. """ - def getPresetInfo(preset_dir): - # Find and returns information about the preset - # Keys needed for BBoardPage: - # - "name": - # - "description": - - # NOTE: this is only a test stub. - preset_info = pickle.loads(open(os.path.join(preset_dir, 'info'), "r").read()) - return preset_info abspath = os.path.join(directory, const.PREDEFINED_BOARDS_DIR) preset_list = dict([ - (os.path.join(abspath, preset_dir), getPresetInfo(os.path.join(abspath, preset_dir))) + (os.path.join(abspath, preset_dir), presetInfo(os.path.join(abspath, preset_dir))) for preset_dir in os.listdir(os.path.join(directory, const.PREDEFINED_BOARDS_DIR)) ]) return preset_list +def presetInfo(preset_dir): + """ + Return the preset-relevant info contined into the project_file. + """ + preset_info = pickle.loads(open(os.path.join(preset_dir, "project.bertos"), "r").read()) + try: + description = open(os.path.join(preset_dir, "description"), "r").read() + except IOError: + # No description file found. + description = "" + relevant_info = { + "CPU_NAME": preset_info.get("CPU_NAME"), + "SELECTED_FREQ": preset_info.get("SELECTED_FREQ"), + "WIZARD_VERSION": preset_info.get("WIZARD_VERSION", None), + "PRESET_NAME": preset_info.get("PROJECT_NAME"), + "PRESET_DESCRIPTION": description.decode("utf-8"), + } + return relevant_info + def mergeSources(srcdir, new_sources, old_sources): # The current mergeSources function provide only a raw copy of the sources in the # created project.