aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-12-07 19:27:34 +0000
committerTarmac <>2012-12-07 19:27:34 +0000
commitafd68a34118d1103f4f27fa9a97deaf637cd1530 (patch)
tree432dd6af404b41101959dfdfd7af5c77440c100b /libqmenumodel/src
parent94f07ed93c2a3c3e3d9a3e518868079e49f5ed32 (diff)
parente8b1e404b8b81fb2b4be6cff41925c3276bc7208 (diff)
downloadqmenumodel-afd68a34118d1103f4f27fa9a97deaf637cd1530.tar.gz
qmenumodel-afd68a34118d1103f4f27fa9a97deaf637cd1530.tar.bz2
qmenumodel-afd68a34118d1103f4f27fa9a97deaf637cd1530.zip
Implemented conversion for GVariant and Arrays.
Approved by Lars Uebernickel, PS Jenkins bot.
Diffstat (limited to 'libqmenumodel/src')
-rw-r--r--libqmenumodel/src/converter.cpp14
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