split up qguivariant into two files

Move everything that will end up in QtWidgets
into a qwidgetsvariant.cpp file. Currently
this is QIcon and QSizePolicy only.
This commit is contained in:
Lars Knoll 2011-05-06 23:52:43 +02:00
parent 7ff1d396e7
commit 32ce4fe9e6
8 changed files with 301 additions and 86 deletions

View File

@ -265,19 +265,16 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
QT_ADD_STATIC_METATYPE("QEasingCurve", QMetaType::QEasingCurve), QT_ADD_STATIC_METATYPE("QEasingCurve", QMetaType::QEasingCurve),
/* All GUI types */ /* All GUI types */
QT_ADD_STATIC_METATYPE("QColorGroup", 63),
QT_ADD_STATIC_METATYPE("QFont", QMetaType::QFont), QT_ADD_STATIC_METATYPE("QFont", QMetaType::QFont),
QT_ADD_STATIC_METATYPE("QPixmap", QMetaType::QPixmap), QT_ADD_STATIC_METATYPE("QPixmap", QMetaType::QPixmap),
QT_ADD_STATIC_METATYPE("QBrush", QMetaType::QBrush), QT_ADD_STATIC_METATYPE("QBrush", QMetaType::QBrush),
QT_ADD_STATIC_METATYPE("QColor", QMetaType::QColor), QT_ADD_STATIC_METATYPE("QColor", QMetaType::QColor),
QT_ADD_STATIC_METATYPE("QPalette", QMetaType::QPalette), QT_ADD_STATIC_METATYPE("QPalette", QMetaType::QPalette),
QT_ADD_STATIC_METATYPE("QIcon", QMetaType::QIcon),
QT_ADD_STATIC_METATYPE("QImage", QMetaType::QImage), QT_ADD_STATIC_METATYPE("QImage", QMetaType::QImage),
QT_ADD_STATIC_METATYPE("QPolygon", QMetaType::QPolygon), QT_ADD_STATIC_METATYPE("QPolygon", QMetaType::QPolygon),
QT_ADD_STATIC_METATYPE("QRegion", QMetaType::QRegion), QT_ADD_STATIC_METATYPE("QRegion", QMetaType::QRegion),
QT_ADD_STATIC_METATYPE("QBitmap", QMetaType::QBitmap), QT_ADD_STATIC_METATYPE("QBitmap", QMetaType::QBitmap),
QT_ADD_STATIC_METATYPE("QCursor", QMetaType::QCursor), QT_ADD_STATIC_METATYPE("QCursor", QMetaType::QCursor),
QT_ADD_STATIC_METATYPE("QSizePolicy", QMetaType::QSizePolicy),
QT_ADD_STATIC_METATYPE("QKeySequence", QMetaType::QKeySequence), QT_ADD_STATIC_METATYPE("QKeySequence", QMetaType::QKeySequence),
QT_ADD_STATIC_METATYPE("QPen", QMetaType::QPen), QT_ADD_STATIC_METATYPE("QPen", QMetaType::QPen),
QT_ADD_STATIC_METATYPE("QTextLength", QMetaType::QTextLength), QT_ADD_STATIC_METATYPE("QTextLength", QMetaType::QTextLength),
@ -290,6 +287,10 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
QT_ADD_STATIC_METATYPE("QVector4D", QMetaType::QVector4D), QT_ADD_STATIC_METATYPE("QVector4D", QMetaType::QVector4D),
QT_ADD_STATIC_METATYPE("QQuaternion", QMetaType::QQuaternion), QT_ADD_STATIC_METATYPE("QQuaternion", QMetaType::QQuaternion),
/* All Widgets types */
QT_ADD_STATIC_METATYPE("QIcon", QMetaType::QIcon),
QT_ADD_STATIC_METATYPE("QSizePolicy", QMetaType::QSizePolicy),
/* All Metatype builtins */ /* All Metatype builtins */
QT_ADD_STATIC_METATYPE("void*", QMetaType::VoidStar), QT_ADD_STATIC_METATYPE("void*", QMetaType::VoidStar),
QT_ADD_STATIC_METATYPE("long", QMetaType::Long), QT_ADD_STATIC_METATYPE("long", QMetaType::Long),
@ -338,6 +339,7 @@ struct QMetaTypeGuiHelper
#endif #endif
}; };
Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeGuiHelper = 0; Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeGuiHelper = 0;
Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper = 0;
class QCustomTypeInfo class QCustomTypeInfo
{ {
@ -399,14 +401,17 @@ void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp,
*/ */
const char *QMetaType::typeName(int type) const char *QMetaType::typeName(int type)
{ {
enum { GuiTypeCount = LastGuiType - FirstGuiType }; enum { GuiTypeCount = LastGuiType - FirstGuiType,
WidgetsTypeCount = LastWidgetsType - FirstWidgetsType };
if (type >= 0 && type <= LastCoreType) { if (type >= 0 && type <= LastCoreType) {
return types[type].typeName; return types[type].typeName;
} else if (type >= FirstGuiType && type <= LastGuiType) { } else if (type >= FirstGuiType && type <= LastGuiType) {
return types[type - FirstGuiType + LastCoreType + 1].typeName; return types[type - FirstGuiType + LastCoreType + 1].typeName;
} else if (type >= FirstWidgetsType && type <= LastWidgetsType) {
return types[type - FirstWidgetsType + GuiTypeCount + LastCoreType + 2].typeName;
} else if (type >= FirstCoreExtType && type <= LastCoreExtType) { } else if (type >= FirstCoreExtType && type <= LastCoreExtType) {
return types[type - FirstCoreExtType + GuiTypeCount + LastCoreType + 2].typeName; return types[type - FirstCoreExtType + GuiTypeCount + WidgetsTypeCount + LastCoreType + 3].typeName;
} else if (type >= User) { } else if (type >= User) {
const QVector<QCustomTypeInfo> * const ct = customTypes(); const QVector<QCustomTypeInfo> * const ct = customTypes();
QReadLocker locker(customTypesLock()); QReadLocker locker(customTypesLock());
@ -768,13 +773,11 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::QBrush: case QMetaType::QBrush:
case QMetaType::QColor: case QMetaType::QColor:
case QMetaType::QPalette: case QMetaType::QPalette:
case QMetaType::QIcon:
case QMetaType::QImage: case QMetaType::QImage:
case QMetaType::QPolygon: case QMetaType::QPolygon:
case QMetaType::QRegion: case QMetaType::QRegion:
case QMetaType::QBitmap: case QMetaType::QBitmap:
case QMetaType::QCursor: case QMetaType::QCursor:
case QMetaType::QSizePolicy:
case QMetaType::QKeySequence: case QMetaType::QKeySequence:
case QMetaType::QPen: case QMetaType::QPen:
case QMetaType::QTextLength: case QMetaType::QTextLength:
@ -790,6 +793,12 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
return false; return false;
qMetaTypeGuiHelper[type - FirstGuiType].saveOp(stream, data); qMetaTypeGuiHelper[type - FirstGuiType].saveOp(stream, data);
break; break;
case QMetaType::QIcon:
case QMetaType::QSizePolicy:
if (!qMetaTypeWidgetsHelper)
return false;
qMetaTypeWidgetsHelper[type - FirstWidgetsType].saveOp(stream, data);
break;
default: { default: {
const QVector<QCustomTypeInfo> * const ct = customTypes(); const QVector<QCustomTypeInfo> * const ct = customTypes();
if (!ct) if (!ct)
@ -973,13 +982,11 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::QBrush: case QMetaType::QBrush:
case QMetaType::QColor: case QMetaType::QColor:
case QMetaType::QPalette: case QMetaType::QPalette:
case QMetaType::QIcon:
case QMetaType::QImage: case QMetaType::QImage:
case QMetaType::QPolygon: case QMetaType::QPolygon:
case QMetaType::QRegion: case QMetaType::QRegion:
case QMetaType::QBitmap: case QMetaType::QBitmap:
case QMetaType::QCursor: case QMetaType::QCursor:
case QMetaType::QSizePolicy:
case QMetaType::QKeySequence: case QMetaType::QKeySequence:
case QMetaType::QPen: case QMetaType::QPen:
case QMetaType::QTextLength: case QMetaType::QTextLength:
@ -995,6 +1002,12 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
return false; return false;
qMetaTypeGuiHelper[type - FirstGuiType].loadOp(stream, data); qMetaTypeGuiHelper[type - FirstGuiType].loadOp(stream, data);
break; break;
case QMetaType::QIcon:
case QMetaType::QSizePolicy:
if (!qMetaTypeWidgetsHelper)
return false;
qMetaTypeWidgetsHelper[type - FirstWidgetsType].loadOp(stream, data);
break;
default: { default: {
const QVector<QCustomTypeInfo> * const ct = customTypes(); const QVector<QCustomTypeInfo> * const ct = customTypes();
if (!ct) if (!ct)
@ -1224,6 +1237,10 @@ void *QMetaType::construct(int type, const void *copy)
if (!qMetaTypeGuiHelper) if (!qMetaTypeGuiHelper)
return 0; return 0;
constr = qMetaTypeGuiHelper[type - FirstGuiType].constr; constr = qMetaTypeGuiHelper[type - FirstGuiType].constr;
} else if (type >= FirstWidgetsType && type <= LastWidgetsType) {
if (!qMetaTypeWidgetsHelper)
return 0;
constr = qMetaTypeWidgetsHelper[type - FirstWidgetsType].constr;
} else { } else {
const QVector<QCustomTypeInfo> * const ct = customTypes(); const QVector<QCustomTypeInfo> * const ct = customTypes();
QReadLocker locker(customTypesLock()); QReadLocker locker(customTypesLock());
@ -1386,6 +1403,12 @@ void QMetaType::destroy(int type, void *data)
if (!qMetaTypeGuiHelper) if (!qMetaTypeGuiHelper)
return; return;
destr = qMetaTypeGuiHelper[type - FirstGuiType].destr; destr = qMetaTypeGuiHelper[type - FirstGuiType].destr;
} else if (type >= FirstWidgetsType && type <= LastWidgetsType) {
Q_ASSERT(qMetaTypeWidgetsHelper);
if (!qMetaTypeWidgetsHelper)
return;
destr = qMetaTypeWidgetsHelper[type - FirstWidgetsType].destr;
} else { } else {
QReadLocker locker(customTypesLock()); QReadLocker locker(customTypesLock());
if (type < User || !ct || ct->count() <= type - User) if (type < User || !ct || ct->count() <= type - User)

View File

@ -71,18 +71,19 @@ public:
QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27, QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27,
QVariantHash = 28, QEasingCurve = 29, LastCoreType = QEasingCurve, QVariantHash = 28, QEasingCurve = 29, LastCoreType = QEasingCurve,
FirstGuiType = 63 /* QColorGroup */, FirstGuiType = 64 /* QFont */,
#ifdef QT3_SUPPORT
QColorGroup = 63,
#endif
QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68, QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68,
QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73, QImage = 69, QPolygon = 70, QRegion = 71, QBitmap = 72,
QCursor = 74, QSizePolicy = 75, QKeySequence = 76, QPen = 77, QCursor = 73, QKeySequence = 74, QPen = 75,
QTextLength = 78, QTextFormat = 79, QMatrix = 80, QTransform = 81, QTextLength = 76, QTextFormat = 77, QMatrix = 78, QTransform = 79,
QMatrix4x4 = 82, QVector2D = 83, QVector3D = 84, QVector4D = 85, QMatrix4x4 = 80, QVector2D = 81, QVector3D = 82, QVector4D = 83,
QQuaternion = 86, QQuaternion = 84,
LastGuiType = QQuaternion, LastGuiType = QQuaternion,
FirstWidgetsType = 120, /* QIcon */
QIcon = 120, QSizePolicy = 121,
LastWidgetsType = QSizePolicy,
FirstCoreExtType = 128 /* VoidStar */, FirstCoreExtType = 128 /* VoidStar */,
VoidStar = 128, Long = 129, Short = 130, Char = 131, ULong = 132, VoidStar = 128, Long = 129, Short = 130, Char = 131, ULong = 132,
UShort = 133, UChar = 134, Float = 135, QObjectStar = 136, QWidgetStar = 137, UShort = 133, UChar = 134, Float = 135, QObjectStar = 136, QWidgetStar = 137,

View File

@ -127,40 +127,33 @@ class Q_CORE_EXPORT QVariant
LastCoreType = EasingCurve, LastCoreType = EasingCurve,
// value 62 is internally reserved // value 62 is internally reserved
#ifdef QT3_SUPPORT
ColorGroup = 63,
#endif
Font = 64, Font = 64,
Pixmap = 65, Pixmap = 65,
Brush = 66, Brush = 66,
Color = 67, Color = 67,
Palette = 68, Palette = 68,
Icon = 69, Image = 69,
Image = 70, Polygon = 70,
Polygon = 71, Region = 71,
Region = 72, Bitmap = 72,
Bitmap = 73, Cursor = 73,
Cursor = 74, KeySequence = 74,
SizePolicy = 75, Pen = 75,
KeySequence = 76, TextLength = 76,
Pen = 77, TextFormat = 77,
TextLength = 78, Matrix = 78,
TextFormat = 79, Transform = 79,
Matrix = 80, Matrix4x4 = 80,
Transform = 81, Vector2D = 81,
Matrix4x4 = 82, Vector3D = 82,
Vector2D = 83, Vector4D = 83,
Vector3D = 84, Quaternion = 84,
Vector4D = 85,
Quaternion = 86,
LastGuiType = Quaternion, LastGuiType = Quaternion,
Icon = 120,
SizePolicy = 121,
UserType = 127, UserType = 127,
#ifdef QT3_SUPPORT
IconSet = Icon,
CString = ByteArray,
PointArray = Polygon,
#endif
LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type
}; };

View File

@ -48,7 +48,6 @@
#include "qdatastream.h" #include "qdatastream.h"
#include "qdebug.h" #include "qdebug.h"
#include "qfont.h" #include "qfont.h"
#include "qicon.h"
#include "qimage.h" #include "qimage.h"
#include "qkeysequence.h" #include "qkeysequence.h"
#include "qtransform.h" #include "qtransform.h"
@ -58,7 +57,6 @@
#include "qpixmap.h" #include "qpixmap.h"
#include "qpolygon.h" #include "qpolygon.h"
#include "qregion.h" #include "qregion.h"
#include "qsizepolicy.h"
#include "qtextformat.h" #include "qtextformat.h"
#include "qmatrix4x4.h" #include "qmatrix4x4.h"
#include "qvector2d.h" #include "qvector2d.h"
@ -70,6 +68,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
Q_GUI_EXPORT const QVariant::Handler *qt_widgets_variant_handler = 0;
Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler(); Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler();
@ -103,11 +102,6 @@ static void construct(QVariant::Private *x, const void *copy)
case QVariant::Palette: case QVariant::Palette:
v_construct<QPalette>(x, copy); v_construct<QPalette>(x, copy);
break; break;
#ifndef QT_NO_ICON
case QVariant::Icon:
v_construct<QIcon>(x, copy);
break;
#endif
case QVariant::Matrix: case QVariant::Matrix:
v_construct<QMatrix>(x, copy); v_construct<QMatrix>(x, copy);
break; break;
@ -128,9 +122,6 @@ static void construct(QVariant::Private *x, const void *copy)
case QVariant::Pen: case QVariant::Pen:
v_construct<QPen>(x, copy); v_construct<QPen>(x, copy);
break; break;
case QVariant::SizePolicy:
v_construct<QSizePolicy>(x, copy);
break;
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
case QVariant::Cursor: case QVariant::Cursor:
v_construct<QCursor>(x, copy); v_construct<QCursor>(x, copy);
@ -169,6 +160,13 @@ static void construct(QVariant::Private *x, const void *copy)
v_construct<QQuaternion>(x, copy); v_construct<QQuaternion>(x, copy);
break; break;
#endif #endif
case QVariant::SizePolicy:
case QVariant::Icon:
if (qt_widgets_variant_handler) {
qt_widgets_variant_handler->construct(x, copy);
return;
}
break;
default: default:
qcoreVariantHandler()->construct(x, copy); qcoreVariantHandler()->construct(x, copy);
return; return;
@ -209,11 +207,6 @@ static void clear(QVariant::Private *d)
case QVariant::Palette: case QVariant::Palette:
v_clear<QPalette>(d); v_clear<QPalette>(d);
break; break;
#ifndef QT_NO_ICON
case QVariant::Icon:
v_clear<QIcon>(d);
break;
#endif
case QVariant::Matrix: case QVariant::Matrix:
v_clear<QMatrix>(d); v_clear<QMatrix>(d);
break; break;
@ -226,9 +219,6 @@ static void clear(QVariant::Private *d)
case QVariant::TextLength: case QVariant::TextLength:
v_clear<QTextLength>(d); v_clear<QTextLength>(d);
break; break;
case QVariant::SizePolicy:
v_clear<QSizePolicy>(d);
break;
#ifndef QT_NO_SHORTCUT #ifndef QT_NO_SHORTCUT
case QVariant::KeySequence: case QVariant::KeySequence:
v_clear<QKeySequence>(d); v_clear<QKeySequence>(d);
@ -262,6 +252,13 @@ static void clear(QVariant::Private *d)
v_clear<QVector4D>(d); v_clear<QVector4D>(d);
break; break;
#endif #endif
case QVariant::SizePolicy:
case QVariant::Icon:
if (qt_widgets_variant_handler) {
qt_widgets_variant_handler->clear(d);
return;
}
break;
default: default:
qcoreVariantHandler()->clear(d); qcoreVariantHandler()->clear(d);
return; return;
@ -286,10 +283,6 @@ static bool isNull(const QVariant::Private *d)
return v_cast<QPixmap>(d)->isNull(); return v_cast<QPixmap>(d)->isNull();
case QVariant::Image: case QVariant::Image:
return v_cast<QImage>(d)->isNull(); return v_cast<QImage>(d)->isNull();
#ifndef QT_NO_ICON
case QVariant::Icon:
return v_cast<QIcon>(d)->isNull();
#endif
case QVariant::Matrix: case QVariant::Matrix:
case QVariant::TextFormat: case QVariant::TextFormat:
case QVariant::TextLength: case QVariant::TextLength:
@ -324,6 +317,10 @@ static bool isNull(const QVariant::Private *d)
case QVariant::Quaternion: case QVariant::Quaternion:
return v_cast<QQuaternion>(d)->isNull(); return v_cast<QQuaternion>(d)->isNull();
#endif #endif
case QVariant::Icon:
if (qt_widgets_variant_handler)
return qt_widgets_variant_handler->isNull(d);
break;
default: default:
return qcoreVariantHandler()->isNull(d); return qcoreVariantHandler()->isNull(d);
} }
@ -371,8 +368,6 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
return *v_cast<QTextFormat>(a) == *v_cast<QTextFormat>(b); return *v_cast<QTextFormat>(a) == *v_cast<QTextFormat>(b);
case QVariant::TextLength: case QVariant::TextLength:
return *v_cast<QTextLength>(a) == *v_cast<QTextLength>(b); return *v_cast<QTextLength>(a) == *v_cast<QTextLength>(b);
case QVariant::SizePolicy:
return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
#ifndef QT_NO_SHORTCUT #ifndef QT_NO_SHORTCUT
case QVariant::KeySequence: case QVariant::KeySequence:
return *v_cast<QKeySequence>(a) == *v_cast<QKeySequence>(b); return *v_cast<QKeySequence>(a) == *v_cast<QKeySequence>(b);
@ -399,6 +394,10 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
case QVariant::Quaternion: case QVariant::Quaternion:
return *v_cast<QQuaternion>(a) == *v_cast<QQuaternion>(b); return *v_cast<QQuaternion>(a) == *v_cast<QQuaternion>(b);
#endif #endif
case QVariant::SizePolicy:
if (qt_widgets_variant_handler)
return qt_widgets_variant_handler->compare(a, b);
break;
default: default:
break; break;
} }
@ -672,9 +671,6 @@ Q_DECL_METATYPE_HELPER(QPixmap)
Q_DECL_METATYPE_HELPER(QBrush) Q_DECL_METATYPE_HELPER(QBrush)
Q_DECL_METATYPE_HELPER(QColor) Q_DECL_METATYPE_HELPER(QColor)
Q_DECL_METATYPE_HELPER(QPalette) Q_DECL_METATYPE_HELPER(QPalette)
#ifndef QT_NO_ICON
Q_DECL_METATYPE_HELPER(QIcon)
#endif
Q_DECL_METATYPE_HELPER(QImage) Q_DECL_METATYPE_HELPER(QImage)
Q_DECL_METATYPE_HELPER(QPolygon) Q_DECL_METATYPE_HELPER(QPolygon)
Q_DECL_METATYPE_HELPER(QRegion) Q_DECL_METATYPE_HELPER(QRegion)
@ -682,7 +678,6 @@ Q_DECL_METATYPE_HELPER(QBitmap)
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
Q_DECL_METATYPE_HELPER(QCursor) Q_DECL_METATYPE_HELPER(QCursor)
#endif #endif
Q_DECL_METATYPE_HELPER(QSizePolicy)
#ifndef QT_NO_SHORTCUT #ifndef QT_NO_SHORTCUT
Q_DECL_METATYPE_HELPER(QKeySequence) Q_DECL_METATYPE_HELPER(QKeySequence)
#endif #endif
@ -721,17 +716,11 @@ Q_DECL_METATYPE_HELPER(QQuaternion)
#endif #endif
static const QMetaTypeGuiHelper qVariantGuiHelper[] = { static const QMetaTypeGuiHelper qVariantGuiHelper[] = {
{0, 0, 0, 0},
Q_IMPL_METATYPE_HELPER(QFont), Q_IMPL_METATYPE_HELPER(QFont),
Q_IMPL_METATYPE_HELPER(QPixmap), Q_IMPL_METATYPE_HELPER(QPixmap),
Q_IMPL_METATYPE_HELPER(QBrush), Q_IMPL_METATYPE_HELPER(QBrush),
Q_IMPL_METATYPE_HELPER(QColor), Q_IMPL_METATYPE_HELPER(QColor),
Q_IMPL_METATYPE_HELPER(QPalette), Q_IMPL_METATYPE_HELPER(QPalette),
#ifdef QT_NO_ICON
{0, 0, 0, 0},
#else
Q_IMPL_METATYPE_HELPER(QIcon),
#endif
Q_IMPL_METATYPE_HELPER(QImage), Q_IMPL_METATYPE_HELPER(QImage),
Q_IMPL_METATYPE_HELPER(QPolygon), Q_IMPL_METATYPE_HELPER(QPolygon),
Q_IMPL_METATYPE_HELPER(QRegion), Q_IMPL_METATYPE_HELPER(QRegion),
@ -741,7 +730,6 @@ static const QMetaTypeGuiHelper qVariantGuiHelper[] = {
#else #else
Q_IMPL_METATYPE_HELPER(QCursor), Q_IMPL_METATYPE_HELPER(QCursor),
#endif #endif
Q_IMPL_METATYPE_HELPER(QSizePolicy),
#ifdef QT_NO_SHORTCUT #ifdef QT_NO_SHORTCUT
{0, 0, 0, 0}, {0, 0, 0, 0},
#else #else
@ -797,4 +785,5 @@ int qUnregisterGuiVariant()
} }
Q_DESTRUCTOR_FUNCTION(qUnregisterGuiVariant) Q_DESTRUCTOR_FUNCTION(qUnregisterGuiVariant)
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -68,7 +68,8 @@ SOURCES += \
kernel/qgesturemanager.cpp \ kernel/qgesturemanager.cpp \
kernel/qsoftkeymanager.cpp \ kernel/qsoftkeymanager.cpp \
kernel/qdesktopwidget.cpp \ kernel/qdesktopwidget.cpp \
kernel/qguiplatformplugin.cpp kernel/qguiplatformplugin.cpp \
kernel/qwidgetsvariant.cpp
win32 { win32 {
DEFINES += QT_NO_DIRECTDRAW DEFINES += QT_NO_DIRECTDRAW

View File

@ -0,0 +1,213 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qvariant.h"
#include "qicon.h"
#include "qsizepolicy.h"
#include "private/qvariant_p.h"
QT_BEGIN_NAMESPACE
static void construct(QVariant::Private *x, const void *copy)
{
switch (x->type) {
#ifndef QT_NO_ICON
case QVariant::Icon:
v_construct<QIcon>(x, copy);
break;
#endif
case QVariant::SizePolicy:
v_construct<QSizePolicy>(x, copy);
break;
default:
Q_ASSERT(false);
return;
}
x->is_null = !copy;
}
static void clear(QVariant::Private *d)
{
switch (d->type) {
#ifndef QT_NO_ICON
case QVariant::Icon:
v_clear<QIcon>(d);
break;
#endif
case QVariant::SizePolicy:
v_clear<QSizePolicy>(d);
break;
default:
Q_ASSERT(false);
return;
}
d->type = QVariant::Invalid;
d->is_null = true;
d->is_shared = false;
}
static bool isNull(const QVariant::Private *d)
{
switch(d->type) {
#ifndef QT_NO_ICON
case QVariant::Icon:
return v_cast<QIcon>(d)->isNull();
#endif
default:
Q_ASSERT(false);
}
return true;
}
static bool compare(const QVariant::Private *a, const QVariant::Private *b)
{
Q_ASSERT(a->type == b->type);
switch(a->type) {
case QVariant::SizePolicy:
return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
default:
Q_ASSERT(false);
}
return false;
}
static const QVariant::Handler widgets_handler = {
construct,
clear,
isNull,
#ifndef QT_NO_DATASTREAM
0,
0,
#endif
compare,
0,
0,
#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
0
#else
0
#endif
};
struct QMetaTypeGuiHelper
{
QMetaType::Constructor constr;
QMetaType::Destructor destr;
#ifndef QT_NO_DATASTREAM
QMetaType::SaveOperator saveOp;
QMetaType::LoadOperator loadOp;
#endif
};
extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper;
#ifdef QT_NO_DATASTREAM
# define Q_DECL_METATYPE_HELPER(TYPE) \
typedef void *(*QConstruct##TYPE)(const TYPE *); \
static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
typedef void (*QDestruct##TYPE)(TYPE *); \
static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>;
#else
# define Q_DECL_METATYPE_HELPER(TYPE) \
typedef void *(*QConstruct##TYPE)(const TYPE *); \
static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
typedef void (*QDestruct##TYPE)(TYPE *); \
static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \
typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
static const QLoad##TYPE qLoad##TYPE = qMetaTypeLoadHelper<TYPE>;
#endif
#ifndef QT_NO_ICON
Q_DECL_METATYPE_HELPER(QIcon)
#endif
Q_DECL_METATYPE_HELPER(QSizePolicy)
#ifdef QT_NO_DATASTREAM
# define Q_IMPL_METATYPE_HELPER(TYPE) \
{ reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) }
#else
# define Q_IMPL_METATYPE_HELPER(TYPE) \
{ reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
}
#endif
static const QMetaTypeGuiHelper qVariantWidgetsHelper[] = {
#ifdef QT_NO_ICON
{0, 0, 0, 0},
#else
Q_IMPL_METATYPE_HELPER(QIcon),
#endif
Q_IMPL_METATYPE_HELPER(QSizePolicy),
};
extern Q_GUI_EXPORT const QVariant::Handler *qt_widgets_variant_handler;
int qRegisterWidgetsVariant()
{
qt_widgets_variant_handler = &widgets_handler;
qMetaTypeWidgetsHelper = qVariantWidgetsHelper;
return 1;
}
Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant)
int qUnregisterWidgetsVariant()
{
qt_widgets_variant_handler = 0;
qMetaTypeWidgetsHelper = 0;
return 1;
}
Q_DESTRUCTOR_FUNCTION(qUnregisterWidgetsVariant)
QT_END_NAMESPACE

View File

@ -224,7 +224,6 @@ void tst_QMetaType::typeName_data()
QTest::newRow("double") << QMetaType::Double << "double"; QTest::newRow("double") << QMetaType::Double << "double";
QTest::newRow("qlonglong") << QMetaType::LongLong << "qlonglong"; QTest::newRow("qlonglong") << QMetaType::LongLong << "qlonglong";
QTest::newRow("QRegExp") << QMetaType::QRegExp << "QRegExp"; QTest::newRow("QRegExp") << QMetaType::QRegExp << "QRegExp";
QTest::newRow("QColorGroup") << QMetaType::Type(63) << "QColorGroup";
QTest::newRow("void*") << QMetaType::VoidStar << "void*"; QTest::newRow("void*") << QMetaType::VoidStar << "void*";
QTest::newRow("ulong") << QMetaType::ULong << "ulong"; QTest::newRow("ulong") << QMetaType::ULong << "ulong";
QTest::newRow("QWidget*") << QMetaType::QWidgetStar << "QWidget*"; QTest::newRow("QWidget*") << QMetaType::QWidgetStar << "QWidget*";

View File

@ -2028,10 +2028,6 @@ void tst_QVariant::typeName_data()
QTest::newRow("9") << int(QVariant::Size) << QByteArray("QSize"); QTest::newRow("9") << int(QVariant::Size) << QByteArray("QSize");
QTest::newRow("10") << int(QVariant::Color) << QByteArray("QColor"); QTest::newRow("10") << int(QVariant::Color) << QByteArray("QColor");
QTest::newRow("11") << int(QVariant::Palette) << QByteArray("QPalette"); QTest::newRow("11") << int(QVariant::Palette) << QByteArray("QPalette");
#ifdef QT3_SUPPORT
QTest::newRow("12") << int(QVariant::ColorGroup) << QByteArray("QColorGroup");
QTest::newRow("13") << int(QVariant::IconSet) << QByteArray("QIcon");
#endif
QTest::newRow("14") << int(QVariant::Point) << QByteArray("QPoint"); QTest::newRow("14") << int(QVariant::Point) << QByteArray("QPoint");
QTest::newRow("15") << int(QVariant::Image) << QByteArray("QImage"); QTest::newRow("15") << int(QVariant::Image) << QByteArray("QImage");
QTest::newRow("16") << int(QVariant::Int) << QByteArray("int"); QTest::newRow("16") << int(QVariant::Int) << QByteArray("int");