4 # Copyright 2009 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
13 Awful module for the conversion from python types to qvariant, for make the wizard compatible with older version of pyqt (<= 4.4.3)
16 from PyQt4.QtCore import *
19 def getString(qvariant):
20 if type(qvariant) == str or type(qvariant) == unicode:
23 string = unicode(qvariant.toString())
26 def convertString(string):
27 return QVariant(string)
29 def getStringList(qvariant):
31 if type(qvariant) == list:
32 string_list = qvariant
34 for element in qvariant.toStringList():
35 string_list.append(unicode(element))
38 def convertStringList(string_list):
40 for element in string_list:
41 result.append(QString(element))
42 return QVariant(QStringList(result))
44 def getStringDict(qvariant):
48 dict_str_bool = pickle.loads(a)
51 def convertStringDict(string_dict):
52 a = pickle.dumps(dict_str_str)
53 return QVariant(QByteArray(a))
55 def getBool(qvariant):
56 return qvariant.toBool()
58 def convertBool(boolean):
59 return QVariant(boolean)
61 def getBoolDict(qvariant):
62 a = str(qvariant.toByteArray())
66 dict_str_bool = pickle.loads(a)
69 def convertBoolDict(dict_str_bool):
70 a = pickle.dumps(dict_str_bool)
71 return QVariant(QByteArray(a))
73 def getDict(qvariant):
74 a = str(qvariant.toByteArray())
78 dict_str_bool = pickle.loads(a)
81 def convertDict(dict_str_variant):
82 a = pickle.dumps(dict_str_variant)
83 return QVariant(QByteArray(a))