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/)
32 # Author: Lorenzo Berni <duplo@develer.com>
36 Awful module for the conversion from python types to qvariant, for make the wizard compatible with older version of pyqt (<= 4.4.3)
39 from PyQt4.QtCore import *
42 def getString(qvariant):
43 if type(qvariant) == str or type(qvariant) == unicode:
46 string = unicode(qvariant.toString())
49 def convertString(string):
50 return QVariant(string)
52 def getStringList(qvariant):
54 if type(qvariant) == list:
55 string_list = qvariant
57 for element in qvariant.toStringList():
58 string_list.append(unicode(element))
61 def convertStringList(string_list):
63 for element in string_list:
64 result.append(QString(element))
65 return QVariant(QStringList(result))
67 def getStringDict(qvariant):
68 a = str(qvariant.toByteArray())
72 dict_str_str = pickle.loads(a)
75 def convertStringDict(dict_str_str):
76 a = pickle.dumps(dict_str_str)
77 return QVariant(QByteArray(a))
79 def getBool(qvariant):
80 return qvariant.toBool()
82 def convertBool(boolean):
83 return QVariant(boolean)
85 def getBoolDict(qvariant):
86 a = str(qvariant.toByteArray())
90 dict_str_bool = pickle.loads(a)
93 def convertBoolDict(dict_str_bool):
94 a = pickle.dumps(dict_str_bool)
95 return QVariant(QByteArray(a))
97 def getDict(qvariant):
98 a = str(qvariant.toByteArray())
102 dict_str_bool = pickle.loads(a)
105 def convertDict(dict_str_variant):
106 a = pickle.dumps(dict_str_variant)
107 return QVariant(QByteArray(a))