From 73f1c621ec1c4054d533cdad5bb066b407b829e6 Mon Sep 17 00:00:00 2001 From: duplo Date: Fri, 2 Jan 2009 11:11:15 +0000 Subject: [PATCH] Separate toolchain search from toolchain selection git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2127 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BStartPage.py | 2 +- wizard/BToolchainPage.py | 94 +------- wizard/BToolchainSearch.py | 76 +++++++ wizard/toolchain_search.ui | 141 ++++++++++++ wizard/toolchain_select.ui | 451 ++++++++++--------------------------- 5 files changed, 350 insertions(+), 414 deletions(-) create mode 100644 wizard/BToolchainSearch.py create mode 100644 wizard/toolchain_search.ui diff --git a/wizard/BStartPage.py b/wizard/BStartPage.py index 38198bae..72bffd65 100644 --- a/wizard/BStartPage.py +++ b/wizard/BStartPage.py @@ -13,7 +13,7 @@ from PyQt4.QtCore import * from PyQt4.QtGui import * import PyQt4.uic as uic -class BStartPage(QWidget): +class BStartPage(QDialog): def __init__(self): QDialog.__init__(self) diff --git a/wizard/BToolchainPage.py b/wizard/BToolchainPage.py index c3756261..bce7471f 100644 --- a/wizard/BToolchainPage.py +++ b/wizard/BToolchainPage.py @@ -10,6 +10,7 @@ # from BWizardPage import * +import BToolchainSearch import bertos_utils class BToolchainPage(BWizardPage): @@ -17,24 +18,9 @@ class BToolchainPage(BWizardPage): def __init__(self): BWizardPage.__init__(self, "toolchain_select.ui") self.setTitle(self.tr("Select toolchain")) - self._setupUi() self._populateToolchainList() - self._populateDirList() self._connectSignals() - def _setupUi(self): - path = self._settingsRetrieve("path_search").toBool() - if not path is None: - self.pageContent.pathBox.setChecked(path) - else: - self.pageContent.pathBox.setChecked(False) - customPath = self._settingsRetrieve("custom_dir").toBool() - if not customPath is None: - self.pageContent.customDirBox.setChecked(customPath) - else: - self.pageContent.customDirBox.setChecked(False) - self._updateUi() - def _updateUi(self): if self.pageContent.customDirBox.isChecked(): self._enableCustomDir() @@ -51,67 +37,22 @@ class BToolchainPage(BWizardPage): item = QListWidgetItem(element.toString()) item.setData(Qt.UserRole, element) self.pageContent.toolchainList.addItem(item) - - 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) - self.pageContent.addDirButton.setEnabled(False) - self.pageContent.removeDirButton.setEnabled(False) - - def _enableCustomDir(self): - self.pageContent.customDirList.setEnabled(True) - self.pageContent.addDirButton.setEnabled(True) - self.pageContent.removeDirButton.setEnabled(True) - + def _clearList(self): self.pageContent.toolchainList.clear() def _selectionChanged(self): self.emit(SIGNAL("completeChanged()")) + def _search(self): + pass + + 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) - 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) 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) - - 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) - toolchains_stored = self._settingsRetrieve("toolchains").toList() - toolchains += [unicode(toolchain.toString()) for toolchain in toolchains_stored] - toolchains = set(toolchains) - toolchains = list(toolchains) - self._clearList() - for toolchain in toolchains: - item = QListWidgetItem(toolchain) - item.setData(Qt.UserRole, QVariant(toolchain)) - self.pageContent.toolchainList.addItem(item) - self._settingsStore("toolchains", toolchains) - self.toSelectionSubpage() + self.connect(self.pageContent.searchButton, SIGNAL("clicked()"), self.searchToolchain) def addToolchain(self): sel_toolchain = QFileDialog.getOpenFileName(self, self.tr("Choose the toolchain"), "") @@ -132,23 +73,10 @@ class BToolchainPage(BWizardPage): toolchains.remove(unicode(item)) self._settingsStore("toolchains", toolchains) - 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): - if self.pageContent.customDirList.currentRow() != -1: - 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)) + def searchToolchain(self): + search = BToolchainSearch.BToolchainSearch() + self.connect(search, SIGNAL("accepted()"), self._search) + search.exec_() def isComplete(self): if self.pageContent.toolchainList.currentRow() != -1: diff --git a/wizard/BToolchainSearch.py b/wizard/BToolchainSearch.py new file mode 100644 index 00000000..614eddff --- /dev/null +++ b/wizard/BToolchainSearch.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# encoding: utf-8 +# +# Copyright 2008 Develer S.r.l. (http://www.develer.com/) +# All rights reserved. +# +# $Id:$ +# +# Author: Lorenzo Berni +# + +from PyQt4.QtCore import * +from PyQt4.QtGui import * +import PyQt4.uic as uic + +class BToolchainSearch(QDialog): + + def __init__(self): + QDialog.__init__(self) + self._setupUi() + self._connectSignals() + self.setWindowTitle(self.tr("Toolchain search page")) + + def _setupUi(self): + self.content = uic.loadUi("toolchain_search.ui", None) + layout = QVBoxLayout() + layout.addWidget(self.content) + self.setLayout(layout) + self._populateDirList() + self._setPathSearch() + self._setSearchButton() + + def _connectSignals(self): + self.connect(self.content.pathBox, SIGNAL("stateChanged(int)"), self._stateChanged) + self.connect(self.content.addButton, SIGNAL("clicked()"), self._addDir) + self.connect(self.content.removeButton, SIGNAL("clicked()"), self._removeDir) + self.connect(self.content.cancelButton, SIGNAL("clicked()"), self.reject) + self.connect(self.content.searchButton, SIGNAL("clicked()"), self.accept) + + def _setSearchButton(self): + self.content.searchButton.setDefault(True) + self.content.searchButton.setEnabled(self.content.pathBox.isChecked() or self.content.customDirList.count() != 0) + + def _populateDirList(self): + search_dir_list = QApplication.instance().settings.value(QString("search_dir_list")).toList() + for element in search_dir_list: + item = QListWidgetItem(unicode(element.toString())) + self.content.customDirList.addItem(item) + + def _setPathSearch(self): + pathSearch = QApplication.instance().settings.value(QString("path_search")).toBool() + self.content.pathBox.setChecked(pathSearch) + + def _stateChanged(self, state): + QApplication.instance().settings.setValue(QString("path_search"), QVariant(state != 0)) + self._setSearchButton() + + def _addDir(self): + directory = QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly) + if not directory.isEmpty(): + item = QListWidgetItem(directory) + self.content.customDirList.addItem(item) + search_dir_list = QApplication.instance().settings.value(QString("search_dir_list")).toList() + search_dir_list = set([d.toString() for d in search_dir_list] + [directory]) + QApplication.instance().settings.setValue(QString("search_dir_list"), QVariant(list(search_dir_list))) + self._setSearchButton() + + def _removeDir(self): + if self.content.customDirList.currentRow() != -1: + item = self.content.customDirList.takeItem(self.content.customDirList.currentRow()) + search_dir_list = QApplication.instance().settings.value(QString("search_dir_list")).toList() + search_dir_list = set([d.toString() for d in search_dir_list]) + search_dir_list.remove(item.text()) + QApplication.instance().settings.setValue(QString("search_dir_list"), QVariant(list(search_dir_list))) + self._setSearchButton() + \ No newline at end of file diff --git a/wizard/toolchain_search.ui b/wizard/toolchain_search.ui new file mode 100644 index 00000000..bb166502 --- /dev/null +++ b/wizard/toolchain_search.ui @@ -0,0 +1,141 @@ + + Form + + + + 0 + 0 + 350 + 290 + + + + Form + + + + + + + 0 + 0 + + + + Search in PATH + + + + + + + Custom directories + + + + + + + + + + + + 26 + 26 + + + + + 26 + 26 + + + + + + + + :/images/listadd.png:/images/listadd.png + + + + + + + + 26 + 26 + + + + + 26 + 26 + + + + + + + + :/images/listremove.png:/images/listremove.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Cancel + + + + + + + Search + + + + + + + + + + + + diff --git a/wizard/toolchain_select.ui b/wizard/toolchain_select.ui index 3ccde9b2..2a052026 100644 --- a/wizard/toolchain_select.ui +++ b/wizard/toolchain_select.ui @@ -5,342 +5,133 @@ 0 0 - 428 - 369 + 321 + 298 - - - 0 - 0 - - Form - + + + + - - - - 0 - 0 - - - - 0 - - - - - - - - - - - - - 26 - 26 - - - - - 26 - 26 - - - - - - - - :/images/listadd.png:/images/listadd.png - - - - 16 - 16 - - - - - - - - - 26 - 26 - - - - - 26 - 26 - - - - - - - - :/images/listremove.png:/images/listremove.png - - - - 16 - 16 - - - - - - - - - 26 - 26 - - - - - 26 - 26 - - - - - - - - :/images/ok.png:/images/ok.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 26 - 26 - - - - - 16777215 - 26 - - - - Search - - - - - - - - - - - - - - - - - - 0 - 0 - - - - Search in PATH - - - - - - - Search in custom directories - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 26 - - - - - 16777215 - 26 - - - - Cancel - - - - - - - - 0 - 26 - - - - - 16777215 - 26 - - - - Search - - - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - - - - - - - - - - - - - 26 - 26 - - - - - 26 - 26 - - - - - - - - :/images/listadd.png:/images/listadd.png - - - - - - - - 26 - 26 - - - - - 26 - 26 - - - - - - - - :/images/listremove.png:/images/listremove.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - + + + + + + 26 + 26 + + + + + 26 + 26 + + + + + + + + :/images/listadd.png:/images/listadd.png + + + + 16 + 16 + + + + + + + + + 26 + 26 + + + + + 26 + 26 + + + + + + + + :/images/listremove.png:/images/listremove.png + + + + 16 + 16 + + + + + + + + + 26 + 26 + + + + + 26 + 26 + + + + + + + + :/images/ok.png:/images/ok.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 26 + 26 + + + + + 16777215 + 26 + + + + Search + + + + -- 2.25.1