aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2016-10-18 15:39:20 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2016-10-18 15:39:20 +0200
commitc42bc210a32f06b2850fbe010be9356d477330b0 (patch)
treec6b02b386ab026be9ec6bfa488c3c13d8e383e68 /libqmenumodel/src
parente87701e0f2d5f3b7dd291c7b8c62e407b5abf4c7 (diff)
downloadqmenumodel-c42bc210a32f06b2850fbe010be9356d477330b0.tar.gz
qmenumodel-c42bc210a32f06b2850fbe010be9356d477330b0.tar.bz2
qmenumodel-c42bc210a32f06b2850fbe010be9356d477330b0.zip
Converter: add support for ByteArrayList
Diffstat (limited to 'libqmenumodel/src')
-rw-r--r--libqmenumodel/src/converter.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp
index 91cafab..9fd65ed 100644
--- a/libqmenumodel/src/converter.cpp
+++ b/libqmenumodel/src/converter.cpp
@@ -63,6 +63,15 @@ QVariant Converter::toQVariant(GVariant *value)
gchar *bs = g_variant_dup_bytestring(value, &size);
result.setValue(QByteArray::fromRawData(bs, size));
g_free(bs);
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTESTRING_ARRAY)) {
+ gsize size = 0;
+ const gchar **bsa = g_variant_get_bytestring_array(value, &size);
+ QByteArrayList list;
+ for (gsize i = 0; i < size; ++i) {
+ list << bsa[i];
+ }
+ result.setValue(list);
+ g_free(bsa);
} else if (g_variant_type_equal(type, G_VARIANT_TYPE_VARIANT)) {
GVariant *var = g_variant_get_variant(value);
result = toQVariant(var);
@@ -117,7 +126,6 @@ QVariant Converter::toQVariant(GVariant *value)
* G_VARIANT_TYPE_DICTIONARY
* G_VARIANT_TYPE_STRING_ARRAY
* G_VARIANT_TYPE_OBJECT_PATH_ARRAY
- * G_VARIANT_TYPE_BYTESTRING_ARRAY
*/
return result;
@@ -211,6 +219,18 @@ GVariant* Converter::toGVariant(const QVariant &value)
g_variant_builder_unref(b);
break;
}
+ case QMetaType::QByteArrayList:
+ {
+ const QByteArrayList &list = qvariant_cast<QByteArrayList>(value);
+ GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_BYTESTRING_ARRAY);
+
+ for (const QByteArray &ba : list) {
+ g_variant_builder_add_value(b, g_variant_new_bytestring(ba));
+ }
+ result = g_variant_builder_end(b);
+ g_variant_builder_unref(b);
+ break;
+ }
case QVariant::List:
{
QVariantList lst = value.toList();