summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dbus/qdbusargument.h31
-rw-r--r--src/dbus/qdbusmetatype.cpp10
2 files changed, 40 insertions, 1 deletions
diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h
index b4e46eb1c6..85469fbc3d 100644
--- a/src/dbus/qdbusargument.h
+++ b/src/dbus/qdbusargument.h
@@ -261,6 +261,35 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &l
return arg;
}
+// QList specializations
+template<typename T>
+inline QDBusArgument &operator<<(QDBusArgument &arg, const QList<T> &list)
+{
+ int id = qMetaTypeId<T>();
+ arg.beginArray(id);
+ typename QList<T>::ConstIterator it = list.constBegin();
+ typename QList<T>::ConstIterator end = list.constEnd();
+ for ( ; it != end; ++it)
+ arg << *it;
+ arg.endArray();
+ return arg;
+}
+
+template<typename T>
+inline const QDBusArgument &operator>>(const QDBusArgument &arg, QList<T> &list)
+{
+ arg.beginArray();
+ list.clear();
+ while (!arg.atEnd()) {
+ T item;
+ arg >> item;
+ list.push_back(item);
+ }
+ arg.endArray();
+
+ return arg;
+}
+
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantList &list)
{
int id = qMetaTypeId<QDBusVariant>();
@@ -273,6 +302,7 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantList &list)
return arg;
}
+// QMap specializations
template<typename Key, typename T>
inline QDBusArgument &operator<<(QDBusArgument &arg, const QMap<Key, T> &map)
{
@@ -321,6 +351,7 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantMap &map)
return arg;
}
+// QHash specializations
template<typename Key, typename T>
inline QDBusArgument &operator<<(QDBusArgument &arg, const QHash<Key, T> &map)
{
diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp
index 5696290ed3..59a71ade3e 100644
--- a/src/dbus/qdbusmetatype.cpp
+++ b/src/dbus/qdbusmetatype.cpp
@@ -177,7 +177,7 @@ Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock)
\snippet code/src_qdbus_qdbusmetatype.cpp 0
- If \c{T} isn't a type derived from one of
+ If \c{T} isn't one of
Qt's \l{container classes}, the \c{operator<<} and
\c{operator>>} streaming operators between \c{T} and QDBusArgument
must be already declared. See the \l {qdbustypesystem.html}{Qt D-Bus
@@ -187,6 +187,14 @@ Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock)
This function returns the Qt meta type id for the type (the same
value that is returned from qRegisterMetaType()).
+ \note The feature that a \c{T} inheriting a streamable type (including
+ the containers QList, QHash or QMap) can be streamed without providing
+ custom \c{operator<<} and \c{operator>>} is deprecated as of Qt 5.7,
+ because it ignores everything in \c{T} except the base class. There is
+ no diagnostic. You should always provide these operators for all types
+ you wish to stream and not rely on Qt-provided stream operators for
+ base classes.
+
\sa {qdbustypesystem.html}{Qt D-Bus Type System}, qRegisterMetaType(), QMetaType
*/