diff options
author | Glenn Watson <glenn.watson@nokia.com> | 2012-02-07 12:25:07 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-11 23:58:39 +0100 |
commit | 15c13b91e66b0bd0d179f0303bb17c7793f80a07 (patch) | |
tree | 4fef509b602582190351653abd718bee396bd8cc /src/corelib/kernel/qmetatype.h | |
parent | e3429f764b37c3d58faf06c6e1856e66fb8d64b9 (diff) |
Add Q_IS_ENUM(), and provide as flag in QMetaType::typeFlags()
Add Q_IS_ENUM() macro to determine if a given type is an
enumeration. Use information from that in QMetaType::registerType()
to store whether custom registered metatypes are enums or not.
This information can then be accessed by calling
QMetaType::typeFlags(int type). This is used by the declarative
code to determine whether a custom type in a variant can be safely
cast to an integer, which is required to allow passing non-local
enums as signal/slot params.
Change-Id: I9733837f56af201fa3017b4a22b761437a3c0de4
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/kernel/qmetatype.h')
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index eacb8403dc..0010c27beb 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -45,6 +45,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qatomic.h> #include <QtCore/qbytearray.h> +#include <QtCore/qisenum.h> #include <new> @@ -209,7 +210,8 @@ public: NeedsConstruction = 0x1, NeedsDestruction = 0x2, MovableType = 0x4, - PointerToQObject = 0x8 + PointerToQObject = 0x8, + IsEnumeration = 0x10 }; Q_DECLARE_FLAGS(TypeFlags, TypeFlag) @@ -455,6 +457,8 @@ int qRegisterMetaType(const char *typeName } if (QtPrivate::IsPointerToTypeDerivedFromQObject<T>::Value) flags |= QMetaType::PointerToQObject; + if (Q_IS_ENUM(T)) + flags |= QMetaType::IsEnumeration; return QMetaType::registerType(typeName, qMetaTypeDeleteHelper<T>, qMetaTypeCreateHelper<T>, |