X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2FBToolchainPage.py;h=2236fcfe3bd463eace52f6670a28ba0390a4e725;hb=7615ed0ec58864bc2d5e8de82bde7ee36a998b17;hp=346eb6480051c346ac31e966ff03b6e2a259c64b;hpb=191efa49c6a346b6170231ece92d451ffea15248;p=bertos.git diff --git a/wizard/BToolchainPage.py b/wizard/BToolchainPage.py index 346eb648..2236fcfe 100644 --- a/wizard/BToolchainPage.py +++ b/wizard/BToolchainPage.py @@ -22,7 +22,7 @@ class BToolchainPage(BWizardPage): BWizardPage.__init__(self, "toolchain_select.ui") self.setTitle(self.tr("Select toolchain")) self._validationProcess = None - self._populateToolchainList() + #self._populateToolchainList() self._connectSignals() def _updateUi(self): @@ -36,12 +36,14 @@ class BToolchainPage(BWizardPage): self.pageContent.doSearchButton.setEnabled(False) def _populateToolchainList(self): - toolchains = qvariant_converter.getStringList(self._settingsRetrieve("toolchains")) - for element in toolchains: - item = QListWidgetItem(element) - item.setData(Qt.UserRole, QVariant(element)) + toolchains = self.toolchains() + for key, value in toolchains.items(): + item = QListWidgetItem(key) + item.setData(Qt.UserRole, qvariant_converter.convertString(key)) self.pageContent.toolchainList.addItem(item) - + if value: + self.validateToolchain(self.pageContent.toolchainList.row(item)) + def _clearList(self): self.pageContent.toolchainList.clear() @@ -49,33 +51,34 @@ class BToolchainPage(BWizardPage): self.emit(SIGNAL("completeChanged()")) def _search(self): - dirList = qvariant_converter.getStringList(self._settingsRetrieve("search_dir_list")) - if(qvariant_converter.getBool(self._settingsRetrieve("path_search"))): + dirList = self.searchDirList() + if(self.pathSearch()): dirList += [element for element in bertos_utils.getSystemPath()] toolchainList = bertos_utils.findToolchains(dirList) - storedToolchainList = qvariant_converter.getStringList(self._settingsRetrieve("toolchains")) - toolchainList = set(toolchainList) - set(storedToolchainList) + storedToolchains = self.toolchains() for element in toolchainList: - item = QListWidgetItem(element) - item.setData(Qt.UserRole, QVariant(element)) - self.pageContent.toolchainList.addItem(item) - self._settingsStore("toolchains", list(toolchainList.union(storedToolchainList))) + if not element in storedToolchains.keys(): + item = QListWidgetItem(element) + item.setData(Qt.UserRole, qvariant_converter.convertString(element)) + self.pageContent.toolchainList.addItem(item) + storedToolchains[element] = False + self.setToolchains(storedToolchains) def _connectSignals(self): self.connect(self.pageContent.toolchainList, SIGNAL("itemSelectionChanged()"), self._selectionChanged) self.connect(self.pageContent.addButton, SIGNAL("clicked()"), self.addToolchain) self.connect(self.pageContent.removeButton, SIGNAL("clicked()"), self.removeToolchain) self.connect(self.pageContent.searchButton, SIGNAL("clicked()"), self.searchToolchain) - self.connect(self.pageContent.checkButton, SIGNAL("clicked()"), self.validateToolchains) + self.connect(self.pageContent.checkButton, SIGNAL("clicked()"), self.validateAllToolchains) def _validItem(self, index, infos): item = self.pageContent.toolchainList.item(index) needed = self._projectInfoRetrieve("CPU_INFOS") - if infos["target"].find(needed["TOOLCHAIN"]) != -1: + if infos["target"].find(qvariant_converter.getString(needed["TOOLCHAIN"])) != -1: item.setIcon(QIcon(":/images/ok.png")) else: item.setIcon(QIcon(":/images/warning.png")) - item.setText(infos["version"] + " " + infos["target"]) + item.setText("GCC " + infos["version"] + " - " + infos["target"]) def _invalidItem(self, index): item = self.pageContent.toolchainList.item(index) @@ -85,41 +88,47 @@ class BToolchainPage(BWizardPage): sel_toolchain = QFileDialog.getOpenFileName(self, self.tr("Choose the toolchain"), "") if not sel_toolchain.isEmpty(): item = QListWidgetItem(sel_toolchain) - item.setData(Qt.UserRole, QVariant(sel_toolchain)) + item.setData(Qt.UserRole, qvariant_converter.convertString(sel_toolchain)) self.pageContent.toolchainList.addItem(item) - toolchains = qvariant_convert.getStringList(self._settingsRetrieve("toolchains")) - toolchains = set(toolchains + [sel_toolchain]) - self._settingsStore("toolchains", list(toolchains)) + toolchains = self.toolchains() + toolchains[sel_toolchain] = False + self.setToolchains(toolchains) def removeToolchain(self): if self.pageContent.toolchainList.currentRow() != -1: item = self.pageContent.toolchainList.takeItem(self.pageContent.toolchainList.currentRow()) toolchain = qvariant_converter.getString(item.data(Qt.UserRole)) - toolchains = qvariant_converter.getStringList(self._settingsRetrieve("toolchains")) - toolchains.remove(toolchain) - self._settingsStore("toolchains", toolchains) + toolchains = self.toolchains() + del toolchains[toolchain] + self.setToolchains(toolchains) def searchToolchain(self): search = BToolchainSearch.BToolchainSearch() self.connect(search, SIGNAL("accepted()"), self._search) search.exec_() - def validateToolchains(self): + def validateAllToolchains(self): for i in range(self.pageContent.toolchainList.count()): - filename = qvariant_converter.getString(self.pageContent.toolchainList.item(i).data(Qt.UserRole)) - self._validationProcess = QProcess() - self._validationProcess.start(filename, ["-v"]) - self._validationProcess.waitForStarted(1000) - if self._validationProcess.waitForFinished(200): - description = str(self._validationProcess.readAllStandardError()) - infos = bertos_utils.getToolchainInfo(description) - if len(infos.keys()) == 4: - self._validItem(i, infos) - else: - self._invalidItem(i) + self.validateToolchain(i) + + def validateToolchain(self, i): + filename = qvariant_converter.getString(self.pageContent.toolchainList.item(i).data(Qt.UserRole)) + self._validationProcess = QProcess() + self._validationProcess.start(filename, ["-v"]) + self._validationProcess.waitForStarted(1000) + if self._validationProcess.waitForFinished(200): + description = str(self._validationProcess.readAllStandardError()) + infos = bertos_utils.getToolchainInfo(description) + if len(infos.keys()) >= 4: + self._validItem(i, infos) else: - self._validationProcess.kill() self._invalidItem(i) + else: + self._validationProcess.kill() + self._invalidItem(i) + toolchains = self.toolchains() + toolchains[filename] = True + self.setToolchains(toolchains) def isComplete(self): if self.pageContent.toolchainList.currentRow() != -1: @@ -127,4 +136,8 @@ class BToolchainPage(BWizardPage): qvariant_converter.getString(self.pageContent.toolchainList.item(self.pageContent.toolchainList.currentRow()).data(Qt.UserRole))) return True else: - return False \ No newline at end of file + return False + + def reloadData(self): + self._clearList() + self._populateToolchainList() \ No newline at end of file