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):
45 a = str(qvariant.toByteArray())
49 dict_str_str = pickle.loads(a)
52 def convertStringDict(dict_str_str):
53 a = pickle.dumps(dict_str_str)
54 return QVariant(QByteArray(a))
56 def getBool(qvariant):
57 return qvariant.toBool()
59 def convertBool(boolean):
60 return QVariant(boolean)
62 def getBoolDict(qvariant):
63 a = str(qvariant.toByteArray())
67 dict_str_bool = pickle.loads(a)
70 def convertBoolDict(dict_str_bool):
71 a = pickle.dumps(dict_str_bool)
72 return QVariant(QByteArray(a))
74 def getDict(qvariant):
75 a = str(qvariant.toByteArray())
79 dict_str_bool = pickle.loads(a)
82 def convertDict(dict_str_variant):
83 a = pickle.dumps(dict_str_variant)
84 return QVariant(QByteArray(a))