Modify orribly the conversion module and the bertos_utils module for make it compatib...
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 12 Jan 2009 19:25:22 +0000 (19:25 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 12 Jan 2009 19:25:22 +0000 (19:25 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2161 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py
wizard/qvariant_converter_old.py

index 89998949b1952aa7adfaeeccc63dd573a174f8e3..2f755c38af8576c31dbc96c03d5b8032f6d1b0b8 100644 (file)
@@ -91,4 +91,5 @@ def getInfos(definition):
     include(definition[0], D)
     D["CPU_NAME"] = definition[0].split(".")[0]
     D["DEFINITION_PATH"] = definition[1] + "/" + definition[0]
-    return D
\ No newline at end of file
+    del D["include"]
+    return D
index 7d3afe0f117aaa8aae72cc0f4a23e2a0f181a666..dbdeb4b4fb245a41922296fd517891aba29083af 100644 (file)
@@ -10,6 +10,7 @@
 #
 
 from PyQt4.QtCore import *
+import pickle
 
 def getString(qvariant):
     string = unicode(qvariant.toString())
@@ -20,8 +21,11 @@ def convertString(string):
 
 def getStringList(qvariant):
     string_list = []
-    for element in qvariant.toStringList():
-        string_list.append(unicode(element))
+    if type(qvariant) == list:
+        string_list = qvariant
+    else:
+        for element in qvariant.toStringList():
+            string_list.append(unicode(element))
     return string_list
 
 def convertStringList(string_list):
@@ -31,19 +35,15 @@ def convertStringList(string_list):
     return QVariant(QStringList(result))
 
 def getStringDict(qvariant):
-    dict_str_str = {}
-    qvariant_item = qvariant.toPyObject()
-    if qvariant_item == NotImplemented:
-        qvariant_item = {}
-    for key, value in qvariant_item.items():
-        dict_str_str[unicode(key)] = unicode(value.toString())
-    return dict_str_str
+    if len(a) == 0:
+        dict_str_bool = {}
+    else:
+        dict_str_bool = pickle.loads(a)
+    return dict_str_bool
 
 def convertStringDict(string_dict):
-    result = {}
-    for key, value in string_dict.items():
-        result[QString(key)] = QVariant(QString(value))
-    return QVariant(result)
+    a = pickle.dumps(dict_str_str)
+    return QVariant(QByteArray(a))
 
 def getBool(qvariant):
     return qvariant.toBool()
@@ -52,36 +52,25 @@ def convertBool(boolean):
     return QVariant(boolean)
 
 def getBoolDict(qvariant):
-    dict_str_bool = {}
-    qvariant_item = qvariant.toPyObject()
-    if qvariant_item == NotImplemented:
-        qvariant_item = {}
-    for key, value in qvariant_item.items():
-        dict_str_bool[unicode(key)] = value.toBool()
+    a = str(qvariant.toByteArray())
+    if len(a) == 0:
+        dict_str_bool = {}
+    else:
+        dict_str_bool = pickle.loads(a)
     return dict_str_bool
 
 def convertBoolDict(dict_str_bool):
-    result = {}
-    for key, value in dict_str_bool:
-        result[QString(key)] = QVariant(value)
-    return QVariant(result)
+    a = pickle.dumps(dict_str_bool)
+    return QVariant(QByteArray(a))
 
 def getDict(qvariant):
-    dict_str_variant = {}
-    qvariant_item = qvariant.toPyObject()
-    if qvariant_item == NotImplemented:
-        qvariant_item = {}
-    for key, value in qvariant_item.items():
-        dict_str_variant[unicode(key)] = value
-    return dict_str_variant
+    a = str(qvariant.toByteArray())
+    if len(a) == 0:
+        dict_str_bool = {}
+    else:
+        dict_str_bool = pickle.loads(a)
+    return dict_str_bool
 
 def convertDict(dict_str_variant):
-    result = {}
-    for key, value in dict_str_variant.items():
-        if type(value) == str or type(value) == unicode:
-            result[QString(key)] = QVariant(QString(value))
-        elif type(value) == list:
-            result[QString(key)] = QVariant(QStringList(value))
-        elif type(value) == dict:
-            result[QString(key)] = QVariant(convertDict(value))
-    return QVariant(result)
+    a = pickle.dumps(dict_str_variant)
+    return QVariant(QByteArray(a))