summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qobject.cpp14
-rw-r--r--src/corelib/kernel/qobject.h10
2 files changed, 24 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index be6441933f..0a8369acbf 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4105,6 +4105,20 @@ QDebug operator<<(QDebug dbg, const QObject *o)
dbg << ')';
return dbg;
}
+
+QDebug qt_QMetaEnum_debugOperator(QDebug &dbg, int value, const QMetaObject *meta, const char *name)
+{
+ QDebugStateSaver saver(dbg);
+ QMetaEnum me = meta->enumerator(meta->indexOfEnumerator(name));
+ const char *key = me.valueToKey(value);
+ dbg.nospace() << meta->className() << "::" << name << '(';
+ if (key)
+ dbg << key;
+ else
+ dbg << value;
+ dbg << ')';
+ return dbg;
+}
#endif
/*!
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 78f913acf8..20ff9981b1 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -547,6 +547,16 @@ template <class T> inline const char * qobject_interface_iid()
#ifndef QT_NO_DEBUG_STREAM
Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *);
+Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaObject *meta, const char *name);
+
+template<typename T>
+typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value , QDebug>::Type
+operator<<(QDebug &dbg, T value)
+{
+ const QMetaObject *obj = qt_getEnumMetaObject(value);
+ const char *name = qt_getEnumName(value);
+ return qt_QMetaEnum_debugOperator(dbg, typename QFlags<T>::Int(value), obj, name);
+}
#endif
class QSignalBlocker