base qt: Fixed an incompatibility with PyQt 4.5.1 (lists of non Q values couldn't be sent directly to QVariant anymore).

--HG--
extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%4070
This commit is contained in:
hsoft 2009-06-17 12:12:02 +00:00
parent cda0cdf542
commit ede178b3ff
1 changed files with 7 additions and 2 deletions

View File

@ -30,9 +30,14 @@ def variant_to_py(v):
elif t in (QVariant.List, QVariant.StringList):
value, ok = map(variant_to_py, v.toList()), True
if not ok:
raise TypeError()
raise TypeError(u"Can't convert {0} of type {1}".format(repr(v), v.type()))
return value
def py_to_variant(v):
if isinstance(v, (list, tuple)):
return QVariant(map(py_to_variant, v))
return QVariant(v)
class Preferences(object):
# (width, is_visible)
COLUMNS_DEFAULT_ATTRS = []
@ -94,7 +99,7 @@ class Preferences(object):
def save(self):
settings = QSettings()
def set_(name, value):
settings.setValue(name, QVariant(value))
settings.setValue(name, py_to_variant(value))
set_('FilterHardness', self.filter_hardness)
set_('MixFileKind', self.mix_file_kind)