From d1105d225fe2850221644a554babbfe2cc2fe94f Mon Sep 17 00:00:00 2001 From: duplo Date: Tue, 20 Apr 2010 10:12:07 +0000 Subject: [PATCH] Add implementation for the isComplete method override. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3475 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BBoardPage.py | 29 ++++++++++++++++++++++------- wizard/BProject.py | 5 +++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/wizard/BBoardPage.py b/wizard/BBoardPage.py index 4553da77..35fc9bc4 100644 --- a/wizard/BBoardPage.py +++ b/wizard/BBoardPage.py @@ -65,7 +65,12 @@ class BBoardPage(BWizardPage): """ Overload of the QWizardPage isComplete method. """ - return False + if self.selected: + _type = qvariant_converter.getDict(self.selected.data(0, Qt.UserRole))["type"] + type = qvariant_converter.getString(_type) + return type == "project" + else: + return False def nextId(self): """ @@ -87,7 +92,7 @@ class BBoardPage(BWizardPage): """ Overload of the BWizardPage connectSignals method. """ - pass + self.connect(self.pageContent.boardTree, SIGNAL("itemSelectionChanged()"), self, SIGNAL("completeChanged()")) def reloadData(self): """ @@ -102,26 +107,36 @@ class BBoardPage(BWizardPage): #### + @property + def selected(self): + # We can only take the selected item list (not the single item) + _selected_items = self.pageContent.boardTree.selectedItems() + if _selected_items: + return _selected_items[0] + else: + return None + def _fillPresetTree(self): self.pageContent.boardTree.clear() self.project.loadProjectPresets() preset_tree = self.project.info("PRESET_TREE") - for obj in preset_tree['children']: + 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_name = obj["info"].get("name", obj["info"]["filename"]) item = QTreeWidgetItem(parent, [item_name]) item.setIcon(0, QIcon(self._getNodeIcon(obj))) - children_dict = obj['children'] + children_dict = obj["children"] + item.setData(0, Qt.UserRole, qvariant_converter.convertDict(obj["info"])) for child in children_dict: self._createPresetNode(item, child) def _getNodeIcon(self, obj): - icon_file = os.path.join(obj['info']['path'], const.PREDEFINED_BOARD_ICON_FILE) + icon_file = os.path.join(obj["info"]["path"], const.PREDEFINED_BOARD_ICON_FILE) if os.path.exists(icon_file): return icon_file - elif obj['children']: + elif obj["info"]["type"] == "dir": return const.PREDEFINED_BOARD_DEFAULT_DIR_ICON else: return const.PREDEFINED_BOARD_DEFAULT_PROJECT_ICON diff --git a/wizard/BProject.py b/wizard/BProject.py index 36623e3a..7d866197 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -140,6 +140,11 @@ class BProject(object): sub_entries = set(os.listdir(_path)) if const.PREDEFINED_BOARD_SPEC_FILE in sub_entries: _tree['children'].append(self._loadProjectPresetTree(_path)) + # Add into the info dict the dir type (dir/project) + if _tree['children']: + _tree['info']['type'] = 'dir' + else: + _tree['info']['type'] = 'project' return _tree def _loadPresetInfo(self, preset_spec_file): -- 2.25.1