aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-11-23 12:22:57 +0000
committerTarmac <>2012-11-23 12:22:57 +0000
commit374e999b82edf8ac36bf88521102bc87c30c596c (patch)
tree26ab85ce6b8a25344d9f500844c681b5b23ba24d /libqmenumodel
parent04391e9723278f8bb0a0985abd50aa9c3455980d (diff)
parent2b54bfb285ab5b2571808bfc9233da4847b27017 (diff)
downloadqmenumodel-374e999b82edf8ac36bf88521102bc87c30c596c.tar.gz
qmenumodel-374e999b82edf8ac36bf88521102bc87c30c596c.tar.bz2
qmenumodel-374e999b82edf8ac36bf88521102bc87c30c596c.zip
Implemented support to tuple conversions.
Approved by PS Jenkins bot.
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..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);
}