Move QIcon metatype handlers back to QtGui
QIcon has been moved back from QWidget to QtGui, so the QIcon QVariant and QMetaType handler can now be moved back to QtGui. Also we can give back QIcon its old number, allowing to get rid of some compatibility hack when unstreaming QVariant Change-Id: I439d5c2987c06ecd619f394407850f678164afb8 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
This commit is contained in:
parent
6c06e14a49
commit
8df298665a
@ -845,11 +845,11 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
|
||||
case QMetaType::QVector3D:
|
||||
case QMetaType::QVector4D:
|
||||
case QMetaType::QQuaternion:
|
||||
case QMetaType::QIcon:
|
||||
if (!qMetaTypeGuiHelper)
|
||||
return false;
|
||||
qMetaTypeGuiHelper[type - FirstGuiType].saveOp(stream, data);
|
||||
break;
|
||||
case QMetaType::QIcon:
|
||||
case QMetaType::QSizePolicy:
|
||||
if (!qMetaTypeWidgetsHelper)
|
||||
return false;
|
||||
@ -1069,11 +1069,11 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
|
||||
case QMetaType::QVector3D:
|
||||
case QMetaType::QVector4D:
|
||||
case QMetaType::QQuaternion:
|
||||
case QMetaType::QIcon:
|
||||
if (!qMetaTypeGuiHelper)
|
||||
return false;
|
||||
qMetaTypeGuiHelper[type - FirstGuiType].loadOp(stream, data);
|
||||
break;
|
||||
case QMetaType::QIcon:
|
||||
case QMetaType::QSizePolicy:
|
||||
if (!qMetaTypeWidgetsHelper)
|
||||
return false;
|
||||
|
@ -127,26 +127,27 @@ QT_BEGIN_NAMESPACE
|
||||
F(QBrush, 66, QBrush) \
|
||||
F(QColor, 67, QColor) \
|
||||
F(QPalette, 68, QPalette) \
|
||||
F(QImage, 69, QImage) \
|
||||
F(QPolygon, 70, QPolygon) \
|
||||
F(QRegion, 71, QRegion) \
|
||||
F(QBitmap, 72, QBitmap) \
|
||||
F(QCursor, 73, QCursor) \
|
||||
F(QKeySequence, 74, QKeySequence) \
|
||||
F(QPen, 75, QPen) \
|
||||
F(QTextLength, 76, QTextLength) \
|
||||
F(QTextFormat, 77, QTextFormat) \
|
||||
F(QMatrix, 78, QMatrix) \
|
||||
F(QTransform, 79, QTransform) \
|
||||
F(QMatrix4x4, 80, QMatrix4x4) \
|
||||
F(QVector2D, 81, QVector2D) \
|
||||
F(QVector3D, 82, QVector3D) \
|
||||
F(QVector4D, 83, QVector4D) \
|
||||
F(QQuaternion, 84, QQuaternion) \
|
||||
F(QPolygonF, 85, QPolygonF) \
|
||||
F(QIcon, 69, QIcon) \
|
||||
F(QImage, 70, QImage) \
|
||||
F(QPolygon, 71, QPolygon) \
|
||||
F(QRegion, 72, QRegion) \
|
||||
F(QBitmap, 73, QBitmap) \
|
||||
F(QCursor, 74, QCursor) \
|
||||
F(QKeySequence, 75, QKeySequence) \
|
||||
F(QPen, 76, QPen) \
|
||||
F(QTextLength, 77, QTextLength) \
|
||||
F(QTextFormat, 78, QTextFormat) \
|
||||
F(QMatrix, 79, QMatrix) \
|
||||
F(QTransform, 80, QTransform) \
|
||||
F(QMatrix4x4, 81, QMatrix4x4) \
|
||||
F(QVector2D, 82, QVector2D) \
|
||||
F(QVector3D, 83, QVector3D) \
|
||||
F(QVector4D, 84, QVector4D) \
|
||||
F(QQuaternion, 85, QQuaternion) \
|
||||
F(QPolygonF, 86, QPolygonF) \
|
||||
|
||||
|
||||
#define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)\
|
||||
F(QIcon, 120, QIcon) \
|
||||
F(QSizePolicy, 121, QSizePolicy) \
|
||||
|
||||
// ### FIXME kill that set
|
||||
@ -208,7 +209,7 @@ public:
|
||||
LastCoreType = SChar,
|
||||
FirstGuiType = QFont,
|
||||
LastGuiType = QPolygonF,
|
||||
FirstWidgetsType = QIcon,
|
||||
FirstWidgetsType = QSizePolicy,
|
||||
LastWidgetsType = QSizePolicy,
|
||||
HighestInternalId = LastWidgetsType,
|
||||
|
||||
@ -232,11 +233,11 @@ public:
|
||||
QObjectStar = 39, QWidgetStar = 40,
|
||||
QVariantMap = 8, QVariantList = 9, QVariantHash = 28,
|
||||
QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68,
|
||||
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, QPolygonF = 85,
|
||||
QIcon = 120, QSizePolicy = 121,
|
||||
QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73,
|
||||
QCursor = 74, QKeySequence = 75, QPen = 76, QTextLength = 77, QTextFormat = 78,
|
||||
QMatrix = 79, QTransform = 80, QMatrix4x4 = 81, QVector2D = 82,
|
||||
QVector3D = 83, QVector4D = 84, QQuaternion = 85, QPolygonF = 86,
|
||||
QSizePolicy = 121,
|
||||
User = 256
|
||||
};
|
||||
#endif
|
||||
|
@ -236,6 +236,9 @@ template<> struct TypeDefinition<QVector4D> { static const bool IsAvailable = fa
|
||||
#ifdef QT_NO_QUATERNION
|
||||
template<> struct TypeDefinition<QQuaternion> { static const bool IsAvailable = false; };
|
||||
#endif
|
||||
#ifdef QT_NO_ICON
|
||||
template<> struct TypeDefinition<QIcon> { static const bool IsAvailable = false; };
|
||||
#endif
|
||||
} //namespace QtMetaTypePrivate
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -1669,18 +1669,12 @@ void QVariant::load(QDataStream &s)
|
||||
// In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes
|
||||
// by moving all ids down by 97.
|
||||
typeId -= 97;
|
||||
} else if (typeId == 69 /* QIcon */) {
|
||||
// In Qt5 after modularization project these types where moved to a separate module (and ids were downgraded)
|
||||
typeId = QMetaType::QIcon;
|
||||
} else if (typeId == 75 /* QSizePolicy */) {
|
||||
typeId = QMetaType::QSizePolicy;
|
||||
} else if (typeId >= 70) {
|
||||
} else if (typeId > 75 && typeId <= 86) {
|
||||
// and as a result these types received lower ids too
|
||||
if (typeId <= 74) { // QImage QPolygon QRegion QBitmap QCursor
|
||||
typeId -=1;
|
||||
} else if (typeId <= 86) { // QKeySequence QPen QTextLength QTextFormat QMatrix QTransform QMatrix4x4 QVector2D QVector3D QVector4D QQuaternion
|
||||
typeId -=2;
|
||||
}
|
||||
// QKeySequence QPen QTextLength QTextFormat QMatrix QTransform QMatrix4x4 QVector2D QVector3D QVector4D QQuaternion
|
||||
typeId -=1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1744,18 +1738,11 @@ void QVariant::save(QDataStream &s) const
|
||||
// In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes
|
||||
// by moving all ids down by 97.
|
||||
typeId += 97;
|
||||
} else if (typeId == QMetaType::QIcon) {
|
||||
// In Qt5 after modularization project these types where moved to a separate module (and ids were downgraded)
|
||||
typeId = 69;
|
||||
} else if (typeId == QMetaType::QSizePolicy) {
|
||||
typeId = 75;
|
||||
} else if (typeId >= QMetaType::QImage) {
|
||||
} else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) {
|
||||
// and as a result these types received lower ids too
|
||||
if (typeId <= QMetaType::QCursor) {
|
||||
typeId +=1;
|
||||
} else if (typeId <= QMetaType::QQuaternion) {
|
||||
typeId +=2;
|
||||
}
|
||||
typeId +=1;
|
||||
}
|
||||
}
|
||||
s << typeId;
|
||||
|
@ -184,9 +184,9 @@ class Q_CORE_EXPORT QVariant
|
||||
Vector4D = QMetaType::QVector4D,
|
||||
Quaternion = QMetaType::QQuaternion,
|
||||
PolygonF = QMetaType::QPolygonF,
|
||||
Icon = QMetaType::QIcon,
|
||||
LastGuiType = QMetaType::LastGuiType,
|
||||
|
||||
Icon = QMetaType::QIcon,
|
||||
SizePolicy = QMetaType::QSizePolicy,
|
||||
|
||||
UserType = QMetaType::User,
|
||||
|
@ -64,6 +64,7 @@
|
||||
#include "qvector3d.h"
|
||||
#include "qvector4d.h"
|
||||
#include "qquaternion.h"
|
||||
#include "qicon.h"
|
||||
|
||||
// Core types
|
||||
#include "qvariant.h"
|
||||
@ -137,7 +138,7 @@ static bool isNull(const QVariant::Private *d)
|
||||
return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0);
|
||||
}
|
||||
|
||||
// This class is a hack that customizes access to QPixmap, QBitmap and QCursor
|
||||
// This class is a hack that customizes access to QPixmap, QBitmap, QCursor and QIcon
|
||||
template<class Filter>
|
||||
class QGuiVariantComparator : public QVariantComparator<Filter> {
|
||||
typedef QVariantComparator<Filter> Base;
|
||||
@ -163,6 +164,12 @@ public:
|
||||
{
|
||||
return v_cast<QCursor>(Base::m_a)->shape() == v_cast<QCursor>(Base::m_b)->shape();
|
||||
}
|
||||
#endif
|
||||
#ifndef QT_NO_ICON
|
||||
bool delegate(const QIcon *)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
bool delegate(const void *p) { return Base::delegate(p); }
|
||||
};
|
||||
@ -288,6 +295,13 @@ static bool convert(const QVariant::Private *d, int t,
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef QT_NO_ICON
|
||||
case QVariant::Icon: {
|
||||
if (ok)
|
||||
*ok = false;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
|
@ -41,7 +41,6 @@
|
||||
|
||||
#include "qvariant.h"
|
||||
|
||||
#include "qicon.h"
|
||||
#include "qsizepolicy.h"
|
||||
|
||||
#include "private/qvariant_p.h"
|
||||
@ -53,11 +52,6 @@ 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;
|
||||
@ -72,11 +66,6 @@ static void construct(QVariant::Private *x, const void *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;
|
||||
@ -93,12 +82,6 @@ static void clear(QVariant::Private *d)
|
||||
|
||||
static bool isNull(const QVariant::Private *d)
|
||||
{
|
||||
switch(d->type) {
|
||||
#ifndef QT_NO_ICON
|
||||
case QVariant::Icon:
|
||||
return v_cast<QIcon>(d)->isNull();
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -106,10 +89,6 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
|
||||
{
|
||||
Q_ASSERT(a->type == b->type);
|
||||
switch(a->type) {
|
||||
#ifndef QT_NO_ICON
|
||||
case QVariant::Icon:
|
||||
return false;
|
||||
#endif
|
||||
case QVariant::SizePolicy:
|
||||
return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
|
||||
default:
|
||||
@ -133,11 +112,6 @@ static void streamDebug(QDebug dbg, const QVariant &v)
|
||||
{
|
||||
QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr());
|
||||
switch (d->type) {
|
||||
#ifndef QT_NO_ICON
|
||||
case QVariant::Icon:
|
||||
dbg.nospace() << *v_cast<QIcon>(d);
|
||||
break;
|
||||
#endif
|
||||
case QVariant::SizePolicy:
|
||||
dbg.nospace() << *v_cast<QSizePolicy>(d);
|
||||
break;
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user