4 # This file is part of BeRTOS.
6 # Bertos is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 # As a special exception, you may use this file as part of a free software
21 # library without restriction. Specifically, if other files instantiate
22 # templates or use macros or inline functions from this file, or you compile
23 # this file and link it with other files to produce an executable, this
24 # file does not by itself cause the resulting executable to be covered by
25 # the GNU General Public License. This exception does not however
26 # invalidate any other reasons why the executable file might be covered by
27 # the GNU General Public License.
29 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
33 # Author: Lorenzo Berni <duplo@develer.com>
37 Awful module for the conversion from python types to qvariant, for make the wizard compatible with older version of pyqt (<= 4.4.3)
40 from PyQt4.QtCore import *
43 def getString(qvariant):
44 if type(qvariant) == str or type(qvariant) == unicode:
47 string = unicode(qvariant.toString())
50 def convertString(string):
51 return QVariant(string)
53 def getStringList(qvariant):
55 if type(qvariant) == list:
56 string_list = qvariant
58 for element in qvariant.toStringList():
59 string_list.append(unicode(element))
62 def convertStringList(string_list):
64 for element in string_list:
65 result.append(QString(element))
66 return QVariant(QStringList(result))
68 def getStringDict(qvariant):
69 a = str(qvariant.toByteArray())
73 dict_str_str = pickle.loads(a)
76 def convertStringDict(dict_str_str):
77 a = pickle.dumps(dict_str_str)
78 return QVariant(QByteArray(a))
80 def getBool(qvariant):
81 return qvariant.toBool()
83 def convertBool(boolean):
84 return QVariant(boolean)
86 def getBoolDict(qvariant):
87 a = str(qvariant.toByteArray())
91 dict_str_bool = pickle.loads(a)
94 def convertBoolDict(dict_str_bool):
95 a = pickle.dumps(dict_str_bool)
96 return QVariant(QByteArray(a))
98 def getDict(qvariant):
99 a = str(qvariant.toByteArray())
103 dict_str_bool = pickle.loads(a)
106 def convertDict(dict_str_variant):
107 a = pickle.dumps(dict_str_variant)
108 return QVariant(QByteArray(a))