From cd1fd445e865636294a8c0438eb6584bedd2abff Mon Sep 17 00:00:00 2001 From: duplo Date: Mon, 12 Jan 2009 19:25:22 +0000 Subject: [PATCH] Modify orribly the conversion module and the bertos_utils module for make it compatible with pyqt <= 4.4.3 ... git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2161 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/bertos_utils.py | 3 +- wizard/qvariant_converter_old.py | 67 +++++++++++++------------------- 2 files changed, 30 insertions(+), 40 deletions(-) diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 89998949..2f755c38 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -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 diff --git a/wizard/qvariant_converter_old.py b/wizard/qvariant_converter_old.py index 7d3afe0f..dbdeb4b4 100644 --- a/wizard/qvariant_converter_old.py +++ b/wizard/qvariant_converter_old.py @@ -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)) -- 2.25.1