diff options
author | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2012-11-23 12:03:54 -0300 |
---|---|---|
committer | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2012-11-23 12:03:54 -0300 |
commit | f68764ac84a0aba3c729d4998ca64919bf3375f4 (patch) | |
tree | b0fd94cdaa2df96a70cbdc636fee4cb1878d5dd9 /libqmenumodel | |
parent | 6078bd7ddc6819d2650435313bb824442bbe033d (diff) | |
parent | de8eea63b919b81132895dfe04ed676778c53f6f (diff) | |
download | qmenumodel-f68764ac84a0aba3c729d4998ca64919bf3375f4.tar.gz qmenumodel-f68764ac84a0aba3c729d4998ca64919bf3375f4.tar.bz2 qmenumodel-f68764ac84a0aba3c729d4998ca64919bf3375f4.zip |
Merged mainline.
Diffstat (limited to 'libqmenumodel')
-rw-r--r-- | libqmenumodel/src/converter.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 75733ce..6c2411c 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -51,8 +51,21 @@ QVariant Converter::toQVariant(GVariant *value) } result.setValue(qmap); + } else if (g_variant_type_is_tuple(type)) { + gsize size = g_variant_n_children(value); + QVariantList vlist; + + for (gsize i=0; i < size; i++) { + GVariant *v = g_variant_get_child_value(value, i); + if (v) { + vlist << toQVariant(v); + g_variant_unref(v); + } + } + + result.setValue(vlist); } else { - qWarning() << "Unsupported GVariant value"; + qWarning() << "Unsupported GVariant value" << (char*) type; } /* TODO: implement convertions to others types @@ -64,7 +77,6 @@ QVariant Converter::toQVariant(GVariant *value) * G_VARIANT_TYPE_BASIC * G_VARIANT_TYPE_MAYBE * G_VARIANT_TYPE_ARRAY - * G_VARIANT_TYPE_TUPLE * G_VARIANT_TYPE_UNIT * G_VARIANT_TYPE_DICT_ENTRY * G_VARIANT_TYPE_DICTIONARY @@ -72,7 +84,6 @@ QVariant Converter::toQVariant(GVariant *value) * G_VARIANT_TYPE_BYTESTRING * G_VARIANT_TYPE_OBJECT_PATH_ARRAY * G_VARIANT_TYPE_BYTESTRING_ARRAY - * G_VARIANT_TYPE_VARDICT */ return result; @@ -137,6 +148,17 @@ GVariant* Converter::toGVariant(const QVariant &value) g_variant_builder_unref(b); break; } + case QVariant::List: + { + QVariantList lst = value.toList(); + GVariant **vars = g_new(GVariant*, lst.size()); + for (int i=0; i < lst.size(); i++) { + vars[i] = toGVariant(lst[i]); + } + result = g_variant_new_tuple(vars, lst.size()); + g_free(vars); + break; + } default: result = ::toGVariant(value.typeName(), value); } |