aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-11-22 17:39:25 -0300
committerRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-11-22 17:39:25 -0300
commitc37748989142ae4f9ee1e1cab4cbcff605302970 (patch)
treec5dc194b48352dd1902083fccf6c5e4be3189bb8 /libqmenumodel
parent04391e9723278f8bb0a0985abd50aa9c3455980d (diff)
downloadqmenumodel-c37748989142ae4f9ee1e1cab4cbcff605302970.tar.gz
qmenumodel-c37748989142ae4f9ee1e1cab4cbcff605302970.tar.bz2
qmenumodel-c37748989142ae4f9ee1e1cab4cbcff605302970.zip
Implemented support to tuple conversions.
Diffstat (limited to 'libqmenumodel')
-rw-r--r--libqmenumodel/src/converter.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp
index 75733ce..5f5b4d2 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);
}