summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qvariant.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r--src/corelib/kernel/qvariant.cpp154
1 files changed, 17 insertions, 137 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index f3ac3fcdba..888da17a98 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1470,7 +1470,7 @@ static void customConstruct(QVariant::Private *d, const void *copy)
} else {
// Private::Data contains long long, and long double is the biggest standard type.
const size_t maxAlignment =
- qMax(Q_ALIGNOF(QVariant::Private::Data), Q_ALIGNOF(long double));
+ qMax(alignof(QVariant::Private::Data), alignof(long double));
const size_t s = sizeof(QVariant::PrivateShared);
const size_t offset = s + ((s * maxAlignment - s) % maxAlignment);
void *data = operator new(offset + size);
@@ -2469,7 +2469,9 @@ static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] =
QVariant::DateTime,
QVariant::ByteArray,
QVariant::BitArray,
+#if QT_CONFIG(shortcut)
QVariant::KeySequence,
+#endif
QVariant::Pen,
QVariant::LongLong,
QVariant::ULongLong,
@@ -2574,7 +2576,11 @@ void QVariant::save(QDataStream &s) const
typeId += 97;
} else if (typeId == QMetaType::QSizePolicy) {
typeId = 75;
+#if QT_CONFIG(shortcut)
} else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) {
+#else
+ } else if (typeId >= QMetaType::QPen && typeId <= QMetaType::QQuaternion) {
+#endif
// and as a result these types received lower ids too
typeId +=1;
} else if (typeId == QMetaType::QPolygonF || typeId == QMetaType::QUuid) {
@@ -3647,9 +3653,11 @@ bool QVariant::canConvert(int targetTypeId) const
if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) {
switch (uint(targetTypeId)) {
case QVariant::Int:
+#if QT_CONFIG(shortcut)
if (currentType == QVariant::KeySequence)
return true;
Q_FALLTHROUGH();
+#endif
case QVariant::UInt:
case QVariant::LongLong:
case QVariant::ULongLong:
@@ -3672,11 +3680,16 @@ bool QVariant::canConvert(int targetTypeId) const
return currentType == QVariant::Color || currentType == QMetaType::Nullptr
|| ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType));
case QVariant::String:
- return currentType == QVariant::KeySequence || currentType == QVariant::Font
- || currentType == QVariant::Color || currentType == QMetaType::Nullptr
- || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType));
+ return currentType == QVariant::Font
+ || currentType == QVariant::Color || currentType == QMetaType::Nullptr
+#if QT_CONFIG(shortcut)
+ || currentType == QVariant::KeySequence
+#endif
+ || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType));
+#if QT_CONFIG(shortcut)
case QVariant::KeySequence:
return currentType == QVariant::String || currentType == QVariant::Int;
+#endif
case QVariant::Font:
return currentType == QVariant::String;
case QVariant::Color:
@@ -3827,72 +3840,6 @@ bool QVariant::convert(const int type, void *ptr) const
QMetaType::registerComparators().
*/
-/*!
- \fn bool QVariant::operator<(const QVariant &v) const
- \obsolete
-
- Compares this QVariant with \a v and returns \c true if this is less than \a v.
-
- \note Comparability might not be availabe for the type stored in this QVariant
- or in \a v.
-
- \warning To make this function work with a custom type registered with
- qRegisterMetaType(), its comparison operator must be registered using
- QMetaType::registerComparators().
-
- This operator is deprecated as it cannot establish a total order required
- for most use of this operator, which is the reason you cannot use QVariant
- as the key of a QMap.
-*/
-
-/*!
- \fn bool QVariant::operator<=(const QVariant &v) const
- \obsolete
-
- Compares this QVariant with \a v and returns \c true if this is less or equal than \a v.
-
- \note Comparability might not be available for the type stored in this QVariant
- or in \a v.
-
- \warning To make this function work with a custom type registered with
- qRegisterMetaType(), its comparison operator must be registered using
- QMetaType::registerComparators().
-
- This operator is deprecated as it cannot establish a total order.
-*/
-
-/*!
- \fn bool QVariant::operator>(const QVariant &v) const
- \obsolete
-
- Compares this QVariant with \a v and returns \c true if this is larger than \a v.
-
- \note Comparability might not be available for the type stored in this QVariant
- or in \a v.
-
- \warning To make this function work with a custom type registered with
- qRegisterMetaType(), its comparison operator must be registered using
- QMetaType::registerComparators().
-
- This operator is deprecated as it cannot establish a total order.
-*/
-
-/*!
- \fn bool QVariant::operator>=(const QVariant &v) const
- \obsolete
-
- Compares this QVariant with \a v and returns \c true if this is larger or equal than \a v.
-
- \note Comparability might not be available for the type stored in this QVariant
- or in \a v.
-
- \warning To make this function work with a custom type registered with
- qRegisterMetaType(), its comparison operator must be registered using
- QMetaType::registerComparators().
-
- This operator is deprecated as it cannot establish a total order.
-*/
-
static bool qIsNumericType(uint tp)
{
static const qulonglong numericTypeBits =
@@ -4073,73 +4020,6 @@ bool QVariant::cmp(const QVariant &v) const
/*!
\internal
*/
-int QVariant::compare(const QVariant &v) const
-{
- // try numerics first, with C++ type promotion rules (no conversion)
- if (qIsNumericType(d.type) && qIsNumericType(v.d.type))
- return numericCompare(&d, &v.d);
-
- // check for equality next, as more types implement operator== than operator<
- if (cmp(v))
- return 0;
-
- const QVariant *v1 = this;
- const QVariant *v2 = &v;
- QVariant converted1;
- QVariant converted2;
-
- if (d.type != v.d.type) {
- // if both types differ, try to convert
- if (v2->canConvert(v1->d.type)) {
- converted2 = *v2;
- if (converted2.convert(v1->d.type))
- v2 = &converted2;
- }
- if (v1->d.type != v2->d.type && v1->canConvert(v2->d.type)) {
- converted1 = *v1;
- if (converted1.convert(v2->d.type))
- v1 = &converted1;
- }
- if (v1->d.type != v2->d.type) {
- // if conversion fails, default to toString
- int r = v1->toString().compare(v2->toString(), Qt::CaseInsensitive);
- if (r == 0) {
- // cmp(v) returned false, so we should try to agree with it.
- return (v1->d.type < v2->d.type) ? -1 : 1;
- }
- return r;
- }
-
- // did we end up with two numerics? If so, restart
- if (qIsNumericType(v1->d.type) && qIsNumericType(v2->d.type))
- return v1->compare(*v2);
- }
- if (v1->d.type >= QMetaType::User) {
- int result;
- if (QMetaType::compare(QT_PREPEND_NAMESPACE(constData(d)), QT_PREPEND_NAMESPACE(constData(v2->d)), d.type, &result))
- return result;
- }
- switch (v1->d.type) {
- case QVariant::Date:
- return v1->toDate() < v2->toDate() ? -1 : 1;
- case QVariant::Time:
- return v1->toTime() < v2->toTime() ? -1 : 1;
- case QVariant::DateTime:
- return v1->toDateTime() < v2->toDateTime() ? -1 : 1;
- case QVariant::StringList:
- return v1->toStringList() < v2->toStringList() ? -1 : 1;
- }
- int r = v1->toString().compare(v2->toString(), Qt::CaseInsensitive);
- if (r == 0) {
- // cmp(v) returned false, so we should try to agree with it.
- return (d.type < v.d.type) ? -1 : 1;
- }
- return r;
-}
-
-/*!
- \internal
- */
const void *QVariant::constData() const
{