From fea9d2e39d8694ff5f6e542fe4eb641a3a56aa33 Mon Sep 17 00:00:00 2001 From: duplo Date: Thu, 8 Jan 2009 17:56:07 +0000 Subject: [PATCH] Hide the settings storing api git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2144 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BToolchainPage.py | 18 +++++++++--------- wizard/BVersionPage.py | 10 +++++----- wizard/BWizardPage.py | 28 +++++++++++++++++++++++++++- wizard/qvariant_converter.py | 4 ++-- 4 files changed, 43 insertions(+), 17 deletions(-) diff --git a/wizard/BToolchainPage.py b/wizard/BToolchainPage.py index 346eb648..2afcf1be 100644 --- a/wizard/BToolchainPage.py +++ b/wizard/BToolchainPage.py @@ -36,7 +36,7 @@ class BToolchainPage(BWizardPage): self.pageContent.doSearchButton.setEnabled(False) def _populateToolchainList(self): - toolchains = qvariant_converter.getStringList(self._settingsRetrieve("toolchains")) + toolchains = self.toolchains() for element in toolchains: item = QListWidgetItem(element) item.setData(Qt.UserRole, QVariant(element)) @@ -49,17 +49,17 @@ 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")) + storedToolchainList = self.toolchains() toolchainList = set(toolchainList) - set(storedToolchainList) 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))) + self.setToolchains(list(toolchainList.union(storedToolchainList))) def _connectSignals(self): self.connect(self.pageContent.toolchainList, SIGNAL("itemSelectionChanged()"), self._selectionChanged) @@ -87,17 +87,17 @@ class BToolchainPage(BWizardPage): item = QListWidgetItem(sel_toolchain) item.setData(Qt.UserRole, QVariant(sel_toolchain)) self.pageContent.toolchainList.addItem(item) - toolchains = qvariant_convert.getStringList(self._settingsRetrieve("toolchains")) + toolchains = self.toolchains() toolchains = set(toolchains + [sel_toolchain]) - self._settingsStore("toolchains", list(toolchains)) + self.setToolchains(list(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 = self.toolchains() toolchains.remove(toolchain) - self._settingsStore("toolchains", toolchains) + self.setToolchains(toolchains) def searchToolchain(self): search = BToolchainSearch.BToolchainSearch() diff --git a/wizard/BVersionPage.py b/wizard/BVersionPage.py index 129a5bf1..e9ebb54b 100644 --- a/wizard/BVersionPage.py +++ b/wizard/BVersionPage.py @@ -34,14 +34,14 @@ class BVersionPage(BWizardPage): self.pageContent.versionList.setCurrentRow(-1) def _storeVersion(self, directory): - versions = qvariant_converter.getStringList(self._settingsRetrieve("versions")) + versions = self.versions() versions = set(versions + [directory]) - self._settingsStore("versions", list(versions)) + self.setVersions(list(versions)) def _deleteVersion(self, directory): - versions = qvariant_converter.getStringList(self._settingsRetrieve("versions")) + versions = self.versions() versions.remove(directory) - self._settingsStore("versions", versions) + self.setVersions(versions) def _insertListElement(self, directory): if bertos_utils.isBertosDir(directory): @@ -54,7 +54,7 @@ class BVersionPage(BWizardPage): self.pageContent.versionList.addItem(item) def _fillVersionList(self): - versions = qvariant_converter.getStringList(self._settingsRetrieve("versions")) + versions = self.versions() for directory in versions: self._insertListElement(directory) diff --git a/wizard/BWizardPage.py b/wizard/BWizardPage.py index d33c9cba..5e5569ab 100644 --- a/wizard/BWizardPage.py +++ b/wizard/BWizardPage.py @@ -13,6 +13,8 @@ from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4 import uic +import qvariant_converter + class BWizardPage(QWizardPage): def __init__(self, wizardGui, parent = None): @@ -23,7 +25,7 @@ class BWizardPage(QWizardPage): self.setLayout(layout) def _settingsStore(self, key, value): - QApplication.instance().settings.setValue(QString(key), QVariant(value)) + QApplication.instance().settings.setValue(QString(key), value) def _settingsRetrieve(self, key): return QApplication.instance().settings.value(QString(key), QVariant()) @@ -33,6 +35,30 @@ class BWizardPage(QWizardPage): def _projectInfoRetrieve(self, key): return QApplication.instance().project.info(key) + + def versions(self): + return qvariant_converter.getStringList(self._settingsRetrieve("versions")) + + def setVersions(self, versions): + self._settingsStore("versions", qvariant_converter.convertStringList(versions)) + + def searchDirList(self): + return qvariant_converter.getStringList(self._settingsRetrieve("search_dir_list")) + + def setSearchDirList(self, search_dir_list): + self._settingsStore("search_dir_list", qvariant_converter.convertStringList(search_dir_list)) + + def pathSearch(self): + return qvariant_converter.getBool(self._settingsRetrieve("path_search")) + + def setPathSearch(self, path_search): + self._settingsStore("path_search", qvariant_converter.convertBool(path_search)) + + def toolchains(self): + return qvariant_converter.getStringList(self._settingsRetrieve("toolchains")) + + def setToolchains(self, toolchains): + self._settingsStore("toolchains", qvariant_converter.convertStringList(toolchains)) def reloadData(self): pass \ No newline at end of file diff --git a/wizard/qvariant_converter.py b/wizard/qvariant_converter.py index d1854bff..2e66ee56 100644 --- a/wizard/qvariant_converter.py +++ b/wizard/qvariant_converter.py @@ -34,7 +34,7 @@ def getStringDict(qvariant): def convertStringDict(string_dict): result_dict = {} for key, value in string_dict.items(): - result_dict[QString(key)] = QVariant(value) + result_dict[QString(key)] = QString(value) return QVariant(result_dict) def getBool(qvariant): @@ -53,4 +53,4 @@ def convertDict(dict_str_variant): result_dict = {} for key, value in dict_str_variant.items(): result_dict[QString(key)] = QVariant(value) - return result_dict \ No newline at end of file + return QVariant(result_dict) \ No newline at end of file -- 2.25.1