summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidgetsvariant.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel/qwidgetsvariant.cpp')
-rw-r--r--src/widgets/kernel/qwidgetsvariant.cpp73
1 files changed, 30 insertions, 43 deletions
diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp
index edb166e8d5..45a3bb3f7a 100644
--- a/src/widgets/kernel/qwidgetsvariant.cpp
+++ b/src/widgets/kernel/qwidgetsvariant.cpp
@@ -48,36 +48,6 @@
QT_BEGIN_NAMESPACE
namespace {
-static void construct(QVariant::Private *x, const void *copy)
-{
- switch (x->type) {
- case QMetaType::QSizePolicy:
- v_construct<QSizePolicy>(x, copy);
- break;
- default:
- qWarning("Trying to construct an instance of an invalid type, type id: %i", x->type);
- x->type = QMetaType::UnknownType;
- return;
- }
- x->is_null = !copy;
-}
-
-static void clear(QVariant::Private *d)
-{
- switch (d->type) {
- case QMetaType::QSizePolicy:
- v_clear<QSizePolicy>(d);
- break;
- default:
- Q_ASSERT(false);
- return;
- }
-
- d->type = QMetaType::UnknownType;
- d->is_null = true;
- d->is_shared = false;
-}
-
static bool isNull(const QVariant::Private *)
{
@@ -86,8 +56,8 @@ static bool isNull(const QVariant::Private *)
static bool compare(const QVariant::Private *a, const QVariant::Private *b)
{
- Q_ASSERT(a->type == b->type);
- switch(a->type) {
+ Q_ASSERT(a->type() == b->type());
+ switch (a->type().id()) {
case QMetaType::QSizePolicy:
return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
default:
@@ -110,19 +80,17 @@ static bool convert(const QVariant::Private *d, int type, void *result, bool *ok
static void streamDebug(QDebug dbg, const QVariant &v)
{
QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr());
- switch (d->type) {
+ switch (d->type().id()) {
case QMetaType::QSizePolicy:
dbg.nospace() << *v_cast<QSizePolicy>(d);
break;
default:
- dbg.nospace() << "QMetaType::Type(" << d->type << ')';
+ dbg.nospace() << "QMetaType::Type(" << d->type().id() << ')';
}
}
#endif
static const QVariant::Handler widgets_handler = {
- construct,
- clear,
isNull,
#ifndef QT_NO_DATASTREAM
nullptr,
@@ -138,23 +106,42 @@ static const QVariant::Handler widgets_handler = {
#endif
};
-#define QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES(MetaTypeName, MetaTypeId, RealName) \
- QT_METATYPE_INTERFACE_INIT(RealName),
+static const struct : QMetaTypeModuleHelper
+{
+ QtPrivate::QMetaTypeInterface *interfaceForType(int type) const override {
+ switch (type) {
+ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_METATYPE_CONVERT_ID_TO_TYPE)
+ default: return nullptr;
+ }
+ }
+#ifndef QT_NO_DATASTREAM
+ bool save(QDataStream &stream, int type, const void *data) const override {
+ switch (type) {
+ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_METATYPE_DATASTREAM_SAVE)
+ default: return false;
+ }
+ }
+ bool load(QDataStream &stream, int type, void *data) const override {
+ switch (type) {
+ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_METATYPE_DATASTREAM_LOAD)
+ default: return false;
+ }
+ }
+#endif
+
+} qVariantWidgetsHelper;
-static const QMetaTypeInterface qVariantWidgetsHelper[] = {
- QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES)
-};
#undef QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES
} // namespace
-extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeWidgetsHelper;
+extern Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeWidgetsHelper;
void qRegisterWidgetsVariant()
{
qRegisterMetaType<QWidget*>();
- qMetaTypeWidgetsHelper = qVariantWidgetsHelper;
+ qMetaTypeWidgetsHelper = &qVariantWidgetsHelper;
QVariantPrivate::registerHandler(QModulesPrivate::Widgets, &widgets_handler);
}
Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant)