diff options
author | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2012-12-07 18:20:53 +0000 |
---|---|---|
committer | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2012-12-07 18:20:53 +0000 |
commit | e8b1e404b8b81fb2b4be6cff41925c3276bc7208 (patch) | |
tree | 432dd6af404b41101959dfdfd7af5c77440c100b /libqmenumodel | |
parent | 94f07ed93c2a3c3e3d9a3e518868079e49f5ed32 (diff) | |
download | qmenumodel-e8b1e404b8b81fb2b4be6cff41925c3276bc7208.tar.gz qmenumodel-e8b1e404b8b81fb2b4be6cff41925c3276bc7208.tar.bz2 qmenumodel-e8b1e404b8b81fb2b4be6cff41925c3276bc7208.zip |
Implemented conversion for GVariant and Arrays.
Diffstat (limited to 'libqmenumodel')
-rw-r--r-- | libqmenumodel/src/converter.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 6c2411c..526faba 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -38,6 +38,10 @@ QVariant Converter::toQVariant(GVariant *value) gsize size = 0; const gchar *v = g_variant_get_string(value, &size); result.setValue(QString::fromUtf8(v, size)); + } else if (g_variant_type_equal(type, G_VARIANT_TYPE_VARIANT)) { + GVariant *var = g_variant_get_variant(value); + result = toQVariant(var); + g_variant_unref(var); } else if (g_variant_type_equal(type, G_VARIANT_TYPE_VARDICT)) { GVariantIter iter; GVariant *vvalue; @@ -51,6 +55,14 @@ QVariant Converter::toQVariant(GVariant *value) } result.setValue(qmap); + } else if (g_variant_type_is_array(type)) { + QVariantList lst; + for (int i = 0, iMax = g_variant_n_children(value); i < iMax; i++) { + GVariant *child = g_variant_get_child_value(value, i); + lst << toQVariant(child); + g_variant_unref(child); + } + result.setValue(lst); } else if (g_variant_type_is_tuple(type)) { gsize size = g_variant_n_children(value); QVariantList vlist; @@ -72,11 +84,9 @@ QVariant Converter::toQVariant(GVariant *value) * G_VARIANT_TYPE_HANDLE * G_VARIANT_TYPE_OBJECT_PATH * G_VARIANT_TYPE_SIGNATURE - * G_VARIANT_TYPE_VARIANT * G_VARIANT_TYPE_ANY * G_VARIANT_TYPE_BASIC * G_VARIANT_TYPE_MAYBE - * G_VARIANT_TYPE_ARRAY * G_VARIANT_TYPE_UNIT * G_VARIANT_TYPE_DICT_ENTRY * G_VARIANT_TYPE_DICTIONARY |