X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fqvariant_converter_old.py;h=67ffb084d460126245ae0acbb78df8dac13d85bd;hb=8d22a2e350167e155a798ae50844e49e8597eb96;hp=dbdeb4b4fb245a41922296fd517891aba29083af;hpb=cd1fd445e865636294a8c0438eb6584bedd2abff;p=bertos.git diff --git a/wizard/qvariant_converter_old.py b/wizard/qvariant_converter_old.py index dbdeb4b4..67ffb084 100644 --- a/wizard/qvariant_converter_old.py +++ b/wizard/qvariant_converter_old.py @@ -9,11 +9,18 @@ # Author: Lorenzo Berni # +""" +Awful module for the conversion from python types to qvariant, for make the wizard compatible with older version of pyqt (<= 4.4.3) +""" + from PyQt4.QtCore import * import pickle def getString(qvariant): - string = unicode(qvariant.toString()) + if type(qvariant) == str or type(qvariant) == unicode: + string = qvariant + else: + string = unicode(qvariant.toString()) return string def convertString(string): @@ -35,13 +42,14 @@ def convertStringList(string_list): return QVariant(QStringList(result)) def getStringDict(qvariant): + a = str(qvariant.toByteArray()) if len(a) == 0: - dict_str_bool = {} + dict_str_str = {} else: - dict_str_bool = pickle.loads(a) - return dict_str_bool + dict_str_str = pickle.loads(a) + return dict_str_str -def convertStringDict(string_dict): +def convertStringDict(dict_str_str): a = pickle.dumps(dict_str_str) return QVariant(QByteArray(a))