Hide the settings storing api
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 8 Jan 2009 17:56:07 +0000 (17:56 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 8 Jan 2009 17:56:07 +0000 (17:56 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2144 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BToolchainPage.py
wizard/BVersionPage.py
wizard/BWizardPage.py
wizard/qvariant_converter.py

index 346eb6480051c346ac31e966ff03b6e2a259c64b..2afcf1be1e94b48c0f2e16a5dbbbf9d2a77ab69a 100644 (file)
@@ -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()
index 129a5bf1dd8e71764405d20453a96df348c3d083..e9ebb54b30918561d3123fb19053180ddf29edb6 100644 (file)
@@ -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)
 
index d33c9cbad4d932c43ab11f681631cf4df2797bbc..5e5569ab8362a5ce8e32df2ab4ae55e51ea4e9c7 100644 (file)
@@ -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
index d1854bfff7b1ed3a675ff2ded0c9158747d2e3af..2e66ee5652f4d72aef7f6996f899f974a1cbbd6e 100644 (file)
@@ -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