From 32ce4fe9e6a94e77828e976776cf08da85254ff2 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 6 May 2011 23:52:43 +0200 Subject: 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. --- src/corelib/kernel/qmetatype.cpp | 41 ++++++++++++++++++++++++++++-------- src/corelib/kernel/qmetatype.h | 19 +++++++++-------- src/corelib/kernel/qvariant.h | 45 +++++++++++++++++----------------------- 3 files changed, 61 insertions(+), 44 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index bdc96c638b..97afe5965a 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -265,19 +265,16 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ QT_ADD_STATIC_METATYPE("QEasingCurve", QMetaType::QEasingCurve), /* All GUI types */ - QT_ADD_STATIC_METATYPE("QColorGroup", 63), QT_ADD_STATIC_METATYPE("QFont", QMetaType::QFont), QT_ADD_STATIC_METATYPE("QPixmap", QMetaType::QPixmap), QT_ADD_STATIC_METATYPE("QBrush", QMetaType::QBrush), QT_ADD_STATIC_METATYPE("QColor", QMetaType::QColor), 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("QPolygon", QMetaType::QPolygon), QT_ADD_STATIC_METATYPE("QRegion", QMetaType::QRegion), QT_ADD_STATIC_METATYPE("QBitmap", QMetaType::QBitmap), 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("QPen", QMetaType::QPen), 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("QQuaternion", QMetaType::QQuaternion), + /* All Widgets types */ + QT_ADD_STATIC_METATYPE("QIcon", QMetaType::QIcon), + QT_ADD_STATIC_METATYPE("QSizePolicy", QMetaType::QSizePolicy), + /* All Metatype builtins */ QT_ADD_STATIC_METATYPE("void*", QMetaType::VoidStar), QT_ADD_STATIC_METATYPE("long", QMetaType::Long), @@ -338,6 +339,7 @@ struct QMetaTypeGuiHelper #endif }; Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeGuiHelper = 0; +Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper = 0; class QCustomTypeInfo { @@ -399,14 +401,17 @@ void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp, */ const char *QMetaType::typeName(int type) { - enum { GuiTypeCount = LastGuiType - FirstGuiType }; + enum { GuiTypeCount = LastGuiType - FirstGuiType, + WidgetsTypeCount = LastWidgetsType - FirstWidgetsType }; if (type >= 0 && type <= LastCoreType) { return types[type].typeName; } else if (type >= FirstGuiType && type <= LastGuiType) { 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) { - return types[type - FirstCoreExtType + GuiTypeCount + LastCoreType + 2].typeName; + return types[type - FirstCoreExtType + GuiTypeCount + WidgetsTypeCount + LastCoreType + 3].typeName; } else if (type >= User) { const QVector * const ct = customTypes(); QReadLocker locker(customTypesLock()); @@ -768,13 +773,11 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data) case QMetaType::QBrush: case QMetaType::QColor: case QMetaType::QPalette: - case QMetaType::QIcon: case QMetaType::QImage: case QMetaType::QPolygon: case QMetaType::QRegion: case QMetaType::QBitmap: case QMetaType::QCursor: - case QMetaType::QSizePolicy: case QMetaType::QKeySequence: case QMetaType::QPen: case QMetaType::QTextLength: @@ -790,6 +793,12 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data) return false; qMetaTypeGuiHelper[type - FirstGuiType].saveOp(stream, data); break; + case QMetaType::QIcon: + case QMetaType::QSizePolicy: + if (!qMetaTypeWidgetsHelper) + return false; + qMetaTypeWidgetsHelper[type - FirstWidgetsType].saveOp(stream, data); + break; default: { const QVector * const ct = customTypes(); if (!ct) @@ -973,13 +982,11 @@ bool QMetaType::load(QDataStream &stream, int type, void *data) case QMetaType::QBrush: case QMetaType::QColor: case QMetaType::QPalette: - case QMetaType::QIcon: case QMetaType::QImage: case QMetaType::QPolygon: case QMetaType::QRegion: case QMetaType::QBitmap: case QMetaType::QCursor: - case QMetaType::QSizePolicy: case QMetaType::QKeySequence: case QMetaType::QPen: case QMetaType::QTextLength: @@ -995,6 +1002,12 @@ bool QMetaType::load(QDataStream &stream, int type, void *data) return false; qMetaTypeGuiHelper[type - FirstGuiType].loadOp(stream, data); break; + case QMetaType::QIcon: + case QMetaType::QSizePolicy: + if (!qMetaTypeWidgetsHelper) + return false; + qMetaTypeWidgetsHelper[type - FirstWidgetsType].loadOp(stream, data); + break; default: { const QVector * const ct = customTypes(); if (!ct) @@ -1224,6 +1237,10 @@ void *QMetaType::construct(int type, const void *copy) if (!qMetaTypeGuiHelper) return 0; constr = qMetaTypeGuiHelper[type - FirstGuiType].constr; + } else if (type >= FirstWidgetsType && type <= LastWidgetsType) { + if (!qMetaTypeWidgetsHelper) + return 0; + constr = qMetaTypeWidgetsHelper[type - FirstWidgetsType].constr; } else { const QVector * const ct = customTypes(); QReadLocker locker(customTypesLock()); @@ -1386,6 +1403,12 @@ void QMetaType::destroy(int type, void *data) if (!qMetaTypeGuiHelper) return; destr = qMetaTypeGuiHelper[type - FirstGuiType].destr; + } else if (type >= FirstWidgetsType && type <= LastWidgetsType) { + Q_ASSERT(qMetaTypeWidgetsHelper); + + if (!qMetaTypeWidgetsHelper) + return; + destr = qMetaTypeWidgetsHelper[type - FirstWidgetsType].destr; } else { QReadLocker locker(customTypesLock()); if (type < User || !ct || ct->count() <= type - User) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index a2bb7d1597..8e7848aef0 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -71,18 +71,19 @@ public: QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27, QVariantHash = 28, QEasingCurve = 29, LastCoreType = QEasingCurve, - FirstGuiType = 63 /* QColorGroup */, -#ifdef QT3_SUPPORT - QColorGroup = 63, -#endif + FirstGuiType = 64 /* QFont */, QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68, - QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73, - QCursor = 74, QSizePolicy = 75, QKeySequence = 76, QPen = 77, - QTextLength = 78, QTextFormat = 79, QMatrix = 80, QTransform = 81, - QMatrix4x4 = 82, QVector2D = 83, QVector3D = 84, QVector4D = 85, - QQuaternion = 86, + QImage = 69, QPolygon = 70, QRegion = 71, QBitmap = 72, + QCursor = 73, QKeySequence = 74, QPen = 75, + QTextLength = 76, QTextFormat = 77, QMatrix = 78, QTransform = 79, + QMatrix4x4 = 80, QVector2D = 81, QVector3D = 82, QVector4D = 83, + QQuaternion = 84, LastGuiType = QQuaternion, + FirstWidgetsType = 120, /* QIcon */ + QIcon = 120, QSizePolicy = 121, + LastWidgetsType = QSizePolicy, + FirstCoreExtType = 128 /* VoidStar */, VoidStar = 128, Long = 129, Short = 130, Char = 131, ULong = 132, UShort = 133, UChar = 134, Float = 135, QObjectStar = 136, QWidgetStar = 137, diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 1b8cb7fd0b..345272ee36 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -127,40 +127,33 @@ class Q_CORE_EXPORT QVariant LastCoreType = EasingCurve, // value 62 is internally reserved -#ifdef QT3_SUPPORT - ColorGroup = 63, -#endif Font = 64, Pixmap = 65, Brush = 66, Color = 67, Palette = 68, - Icon = 69, - Image = 70, - Polygon = 71, - Region = 72, - Bitmap = 73, - Cursor = 74, - SizePolicy = 75, - KeySequence = 76, - Pen = 77, - TextLength = 78, - TextFormat = 79, - Matrix = 80, - Transform = 81, - Matrix4x4 = 82, - Vector2D = 83, - Vector3D = 84, - Vector4D = 85, - Quaternion = 86, + Image = 69, + Polygon = 70, + Region = 71, + Bitmap = 72, + Cursor = 73, + KeySequence = 74, + Pen = 75, + TextLength = 76, + TextFormat = 77, + Matrix = 78, + Transform = 79, + Matrix4x4 = 80, + Vector2D = 81, + Vector3D = 82, + Vector4D = 83, + Quaternion = 84, LastGuiType = Quaternion, + Icon = 120, + SizePolicy = 121, + 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 }; -- cgit v1.2.3