From 5423f0cee8fe3413d7e2f756e66a111c4dd8eb2a Mon Sep 17 00:00:00 2001 From: duplo Date: Tue, 23 Dec 2008 08:56:56 +0000 Subject: [PATCH] Add the toolchain search function git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2123 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BToolchainPage.py | 59 +++++++++++++++++++++++++++++++++----- wizard/toolchain_select.ui | 2 +- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/wizard/BToolchainPage.py b/wizard/BToolchainPage.py index e052db27..4b2b4c5e 100644 --- a/wizard/BToolchainPage.py +++ b/wizard/BToolchainPage.py @@ -10,6 +10,7 @@ # from BWizardPage import * +import bertos_utils class BToolchainPage(BWizardPage): @@ -17,6 +18,7 @@ class BToolchainPage(BWizardPage): BWizardPage.__init__(self, "toolchain_select.ui") self.setTitle(self.tr("Select toolchain")) self._setupUi() + self._populateDirList() self._connectSignals() def _setupUi(self): @@ -41,6 +43,13 @@ class BToolchainPage(BWizardPage): self.pageContent.doSearchButton.setEnabled(True) else: self.pageContent.doSearchButton.setEnabled(False) + + def _populateDirList(self): + search_dir_list = self._settingsRetrieve("search_dir_list").toList() + for element in search_dir_list: + item = QListWidgetItem(element.toString()) + item.setData(Qt.UserRole, element) + self.pageContent.customDirList.addItem(item) def _disableCustomDir(self): self.pageContent.customDirList.setEnabled(False) @@ -52,14 +61,50 @@ class BToolchainPage(BWizardPage): self.pageContent.addDirButton.setEnabled(True) self.pageContent.removeDirButton.setEnabled(True) - def _toSearchSubpage(self): - self.pageContent.pageSelector.setCurrentIndex(1) - - def _toSelectionSubpage(self): - self.pageContent.pageSelector.setCurrentIndex(0) + def _clearList(self): + self.pageContent.toolchainList.clear() def _connectSignals(self): self.connect(self.pageContent.pathBox, SIGNAL("clicked()"), self._updateUi) self.connect(self.pageContent.customDirBox, SIGNAL("clicked()"), self._updateUi) - self.connect(self.pageContent.searchButton, SIGNAL("clicked()"), self._toSearchSubpage) - self.connect(self.pageContent.cancelButton, SIGNAL("clicked()"), self._toSelectionSubpage) \ No newline at end of file + self.connect(self.pageContent.searchButton, SIGNAL("clicked()"), self.toSearchSubpage) + self.connect(self.pageContent.cancelButton, SIGNAL("clicked()"), self.toSelectionSubpage) + self.connect(self.pageContent.doSearchButton, SIGNAL("clicked()"), self.doSearch) + self.connect(self.pageContent.addDirButton, SIGNAL("clicked()"), self.addDir) + self.connect(self.pageContent.removeDirButton, SIGNAL("clicked()"), self.removeDir) + + def toSearchSubpage(self): + self.pageContent.pageSelector.setCurrentIndex(1) + + def toSelectionSubpage(self): + self.pageContent.pageSelector.setCurrentIndex(0) + + def doSearch(self): + path = [] + if self.pageContent.pathBox.isChecked(): + path += bertos_utils.getSystemPath() + if self.pageContent.customDirBox.isChecked(): + for element in range(self.pageContent.customDirList.count()): + path += [unicode(self.pageContent.customDirList.item(element).data(Qt.UserRole).toString())] + toolchains = bertos_utils.findToolchains(path) + self._clearList() + for toolchain in toolchains: + self.pageContent.toolchainList.addItem(QListWidgetItem(toolchain)) + self.toSelectionSubpage() + + def addDir(self): + directory = QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly) + if not directory.isEmpty(): + item = QListWidgetItem(directory) + item.setData(Qt.UserRole, QVariant(directory)) + self.pageContent.customDirList.addItem(item) + search_dir_list = self._settingsRetrieve("search_dir_list").toList() + search_dir_list = set([d.toString() for d in search_dir_list] + [directory]) + self._settingsStore("search_dir_list", list(search_dir_list)) + + def removeDir(self): + item = self.pageContent.customDirList.takeItem(self.pageContent.customDirList.currentRow()) + search_dir_list = self._settingsRetrieve("search_dir_list").toList() + search_dir_list = set([d.toString() for d in search_dir_list]) + search_dir_list.remove(item.data(Qt.UserRole).toString()) + self._settingsStore("search_dir_list", list(search_dir_list)) \ No newline at end of file diff --git a/wizard/toolchain_select.ui b/wizard/toolchain_select.ui index 79a64b27..8694e623 100644 --- a/wizard/toolchain_select.ui +++ b/wizard/toolchain_select.ui @@ -28,7 +28,7 @@ - 0 + 1 -- 2.25.1