Add an experimental conversion module from QVariant to the needed python types
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 8 Jan 2009 14:14:51 +0000 (14:14 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 8 Jan 2009 14:14:51 +0000 (14:14 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2138 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/qvariant_converter.py [new file with mode: 0644]

diff --git a/wizard/qvariant_converter.py b/wizard/qvariant_converter.py
new file mode 100644 (file)
index 0000000..256b4fc
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# Copyright 2009 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# $Id:$
+#
+# Author: Lorenzo Berni <duplo@develer.com>
+#
+
+from PyQt4.QtCore import *
+
+def getString(qvariant):
+    string = unicode(qvariant.toString())
+    return string
+
+def getStringList(qvariant):
+    string_list = [unicode(string) for string in qvariant.toStringList()]
+    return string_list
+
+def getStringDict(qvariant):
+    dict_str_str = {}
+    for key, value in qvariant.toMap().items():
+        dict_str_str[unicode(key)] = unicode(value.toString())
+    return dict_str_str
+
+def getBool(qvariant):
+    return qvariant.toBool()
+
+def getDict(qvariant):
+    dict_str_variant = {}
+    for key, value in qvariant.toMap().items():
+        dict_str_variant[unicode(key)] = value
+    return dict_str_variant
\ No newline at end of file