From e97d3f3f571e3cc5f5851ea2e131ac92212802dd Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@nokia.com>
Date: Thu, 3 Feb 2011 19:30:09 +0100
Subject: QtDBus: add support for QVariantHash out of the box

---
 src/dbus/qdbusargument.h   | 15 +++++++++++++++
 src/dbus/qdbusmetatype.cpp |  1 +
 2 files changed, 16 insertions(+)

diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h
index 2c8693b..e331d8f 100644
--- a/src/dbus/qdbusargument.h
+++ b/src/dbus/qdbusargument.h
@@ -376,6 +376,21 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, QHash<Key, T> &
     return arg;
 }
 
+inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map)
+{
+    arg.beginMap(QVariant::String, qMetaTypeId<QDBusVariant>());
+    QVariantHash::ConstIterator it = map.constBegin();
+    QVariantHash::ConstIterator end = map.constEnd();
+    for ( ; it != end; ++it) {
+        arg.beginMapEntry();
+        arg << it.key() << QDBusVariant(it.value());
+        arg.endMapEntry();
+    }
+    arg.endMap();
+    return arg;
+}
+
+
 QT_END_NAMESPACE
 
 Q_DECLARE_METATYPE(QDBusArgument)
diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp
index 6de5d93..9f29205 100644
--- a/src/dbus/qdbusmetatype.cpp
+++ b/src/dbus/qdbusmetatype.cpp
@@ -127,6 +127,7 @@ void QDBusMetaTypeId::init()
         registerHelper<QLineF>();
         registerHelper<QVariantList>();
         registerHelper<QVariantMap>();
+        registerHelper<QVariantHash>();
 
         qDBusRegisterMetaType<QList<bool> >();
         qDBusRegisterMetaType<QList<short> >();
-- 
cgit v0.12

