From c8a8c7750d7246eae233d4567b35bf98d59cca38 Mon Sep 17 00:00:00 2001 From: duplo Date: Thu, 8 Jan 2009 14:14:51 +0000 Subject: [PATCH] Add an experimental conversion module from QVariant to the needed python types git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2138 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/qvariant_converter.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 wizard/qvariant_converter.py diff --git a/wizard/qvariant_converter.py b/wizard/qvariant_converter.py new file mode 100644 index 00000000..256b4fc3 --- /dev/null +++ b/wizard/qvariant_converter.py @@ -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 +# + +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 -- 2.25.1