summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2018-05-11 10:24:06 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2018-05-11 11:11:13 +0200
commit8e31fc8bccb7e231df71a1e2009bb0d2849b68b2 (patch)
treeed6ea432f93408a3e764db469fc927f03ce02851 /src/corelib/kernel
parent6a0648c88b2ece97fd23f527e3d0e5911b46b5ed (diff)
parenta7863a58545a6c59eaf16f36905efcbf0e4f94f9 (diff)
Merge remote-tracking branch 'origin/5.11.0' into wip/webassembly
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm12
-rw-r--r--src/corelib/kernel/qcoreevent.cpp2
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp2
-rw-r--r--src/corelib/kernel/qmetatype.cpp26
-rw-r--r--src/corelib/kernel/qmetatype.h37
-rw-r--r--src/corelib/kernel/qmetatype_p.h4
-rw-r--r--src/corelib/kernel/qobject.cpp8
-rw-r--r--src/corelib/kernel/qobject.h6
-rw-r--r--src/corelib/kernel/qvariant.cpp161
-rw-r--r--src/corelib/kernel/qvariant.h32
10 files changed, 168 insertions, 122 deletions
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index 24d73fa8be..5ecd86a30e 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -346,15 +346,15 @@ Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode)
void qt_apple_check_os_version()
{
-#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
- const char *os = "iOS";
- const int version = __IPHONE_OS_VERSION_MIN_REQUIRED;
+#if defined(__WATCH_OS_VERSION_MIN_REQUIRED)
+ const char *os = "watchOS";
+ const int version = __WATCH_OS_VERSION_MIN_REQUIRED;
#elif defined(__TV_OS_VERSION_MIN_REQUIRED)
const char *os = "tvOS";
const int version = __TV_OS_VERSION_MIN_REQUIRED;
-#elif defined(__WATCH_OS_VERSION_MIN_REQUIRED)
- const char *os = "watchOS";
- const int version = __WATCH_OS_VERSION_MIN_REQUIRED;
+#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
+ const char *os = "iOS";
+ const int version = __IPHONE_OS_VERSION_MIN_REQUIRED;
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
const char *os = "macOS";
const int version = __MAC_OS_X_VERSION_MIN_REQUIRED;
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index 1e6b328c75..58ca8279ea 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -194,7 +194,7 @@ QT_BEGIN_NAMESPACE
\omitvalue Pointer
\value Polish The widget is polished.
\value PolishRequest The widget should be polished.
- \value QueryWhatsThis The widget should accept the event if it has "What's This?" help.
+ \value QueryWhatsThis The widget should accept the event if it has "What's This?" help (QHelpEvent).
\value ReadOnlyChange Widget's read-only state has changed (since Qt 5.4).
\value RequestSoftwareInputPanel A widget wants to open a software input panel (SIP).
\value Resize Widget's size changed (QResizeEvent).
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index 04c9a9bcba..712e8bbcab 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -599,7 +599,7 @@ void QtAndroidPrivate::setOnBindListener(QtAndroidPrivate::OnBindListener *liste
jobject QtAndroidPrivate::callOnBindListener(jobject intent)
{
QMutexLocker lock(g_onBindListenerMutex);
- if (g_onBindListener)
+ if (*g_onBindListener)
return (*g_onBindListener)->onBind(intent);
return nullptr;
}
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 5abc2ebd70..fc40668c9a 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -53,12 +53,14 @@
#include "qdatastream.h"
#include "qmetatypeswitcher_p.h"
+#if QT_CONFIG(regularexpression)
+# include "qregularexpression.h"
+#endif
+
#ifndef QT_BOOTSTRAPPED
# include "qbitarray.h"
# include "qurl.h"
# include "qvariant.h"
-# include "qabstractitemmodel.h"
-# include "qregularexpression.h"
# include "qjsonvalue.h"
# include "qjsonobject.h"
# include "qjsonarray.h"
@@ -66,6 +68,10 @@
# include "qbytearraylist.h"
#endif
+#if QT_CONFIG(itemmodel)
+# include "qabstractitemmodel.h"
+#endif
+
#ifndef QT_NO_GEOM_VARIANT
# include "qsize.h"
# include "qpoint.h"
@@ -1346,8 +1352,10 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::Void:
case QMetaType::VoidStar:
case QMetaType::QObjectStar:
+#if QT_CONFIG(itemmodel)
case QMetaType::QModelIndex:
case QMetaType::QPersistentModelIndex:
+#endif
case QMetaType::QJsonValue:
case QMetaType::QJsonObject:
case QMetaType::QJsonArray:
@@ -1481,12 +1489,12 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
stream << *static_cast<const NS(QRegExp)*>(data);
break;
#endif
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
case QMetaType::QRegularExpression:
stream << *static_cast<const NS(QRegularExpression)*>(data);
break;
-#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_CONFIG(regularexpression)
+#ifndef QT_BOOTSTRAPPED
case QMetaType::QEasingCurve:
stream << *static_cast<const NS(QEasingCurve)*>(data);
break;
@@ -1570,8 +1578,10 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::Void:
case QMetaType::VoidStar:
case QMetaType::QObjectStar:
+#if QT_CONFIG(itemmodel)
case QMetaType::QModelIndex:
case QMetaType::QPersistentModelIndex:
+#endif
case QMetaType::QJsonValue:
case QMetaType::QJsonObject:
case QMetaType::QJsonArray:
@@ -1711,12 +1721,12 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
stream >> *static_cast< NS(QRegExp)*>(data);
break;
#endif
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
case QMetaType::QRegularExpression:
stream >> *static_cast< NS(QRegularExpression)*>(data);
break;
-#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_CONFIG(regularexpression)
+#ifndef QT_BOOTSTRAPPED
case QMetaType::QEasingCurve:
stream >> *static_cast< NS(QEasingCurve)*>(data);
break;
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 455d0350e0..a0969ee908 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -89,6 +89,14 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
#define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)\
F(VoidStar, 31, void*) \
+#if QT_CONFIG(itemmodel)
+#define QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F)\
+ F(QModelIndex, 42, QModelIndex) \
+ F(QPersistentModelIndex, 50, QPersistentModelIndex)
+#else
+#define QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F)
+#endif
+
#define QT_FOR_EACH_STATIC_CORE_CLASS(F)\
F(QChar, 7, QChar) \
F(QString, 10, QString) \
@@ -112,13 +120,12 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(QEasingCurve, 29, QEasingCurve) \
F(QUuid, 30, QUuid) \
F(QVariant, 41, QVariant) \
- F(QModelIndex, 42, QModelIndex) \
F(QRegularExpression, 44, QRegularExpression) \
F(QJsonValue, 45, QJsonValue) \
F(QJsonObject, 46, QJsonObject) \
F(QJsonArray, 47, QJsonArray) \
F(QJsonDocument, 48, QJsonDocument) \
- F(QPersistentModelIndex, 50, QPersistentModelIndex) \
+ QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F)
#define QT_FOR_EACH_STATIC_CORE_POINTER(F)\
F(QObjectStar, 39, QObject*)
@@ -1381,7 +1388,7 @@ namespace QtPrivate
};
template<typename T, typename Enable = void>
- struct IsGadgetHelper { enum { Value = false }; };
+ struct IsGadgetHelper { enum { IsRealGadget = false, IsGadgetOrDerivedFrom = false }; };
template<typename T>
struct IsGadgetHelper<T, typename T::QtGadgetHelper>
@@ -1389,11 +1396,14 @@ namespace QtPrivate
template <typename X>
static char checkType(void (X::*)());
static void *checkType(void (T::*)());
- enum { Value = sizeof(checkType(&T::qt_check_for_QGADGET_macro)) == sizeof(void *) };
+ enum {
+ IsRealGadget = sizeof(checkType(&T::qt_check_for_QGADGET_macro)) == sizeof(void *),
+ IsGadgetOrDerivedFrom = true
+ };
};
template<typename T, typename Enable = void>
- struct IsPointerToGadgetHelper { enum { Value = false }; };
+ struct IsPointerToGadgetHelper { enum { IsRealGadget = false, IsGadgetOrDerivedFrom = false }; };
template<typename T>
struct IsPointerToGadgetHelper<T*, typename T::QtGadgetHelper>
@@ -1402,7 +1412,10 @@ namespace QtPrivate
template <typename X>
static char checkType(void (X::*)());
static void *checkType(void (T::*)());
- enum { Value = sizeof(checkType(&T::qt_check_for_QGADGET_macro)) == sizeof(void *) };
+ enum {
+ IsRealGadget = sizeof(checkType(&T::qt_check_for_QGADGET_macro)) == sizeof(void *),
+ IsGadgetOrDerivedFrom = true
+ };
};
@@ -1435,12 +1448,12 @@ namespace QtPrivate
static inline const QMetaObject *value() { return &T::staticMetaObject; }
};
template<typename T>
- struct MetaObjectForType<T, typename std::enable_if<IsGadgetHelper<T>::Value>::type>
+ struct MetaObjectForType<T, typename std::enable_if<IsGadgetHelper<T>::IsGadgetOrDerivedFrom>::type>
{
static inline const QMetaObject *value() { return &T::staticMetaObject; }
};
template<typename T>
- struct MetaObjectForType<T, typename QEnableIf<IsPointerToGadgetHelper<T>::Value>::Type>
+ struct MetaObjectForType<T, typename std::enable_if<IsPointerToGadgetHelper<T>::IsGadgetOrDerivedFrom>::type>
{
static inline const QMetaObject *value() { return &IsPointerToGadgetHelper<T>::BaseType::staticMetaObject; }
};
@@ -1599,8 +1612,8 @@ namespace QtPrivate
template <typename T, int =
QtPrivate::IsPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::PointerToQObject :
- QtPrivate::IsGadgetHelper<T>::Value ? QMetaType::IsGadget :
- QtPrivate::IsPointerToGadgetHelper<T>::Value ? QMetaType::PointerToGadget :
+ QtPrivate::IsGadgetHelper<T>::IsRealGadget ? QMetaType::IsGadget :
+ QtPrivate::IsPointerToGadgetHelper<T>::IsRealGadget ? QMetaType::PointerToGadget :
QtPrivate::IsQEnumHelper<T>::Value ? QMetaType::IsEnumeration : 0>
struct QMetaTypeIdQObject
{
@@ -1653,8 +1666,8 @@ namespace QtPrivate {
| (IsWeakPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::WeakPointerToQObject : 0)
| (IsTrackingPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::TrackingPointerToQObject : 0)
| (std::is_enum<T>::value ? QMetaType::IsEnumeration : 0)
- | (IsGadgetHelper<T>::Value ? QMetaType::IsGadget : 0)
- | (IsPointerToGadgetHelper<T>::Value ? QMetaType::PointerToGadget : 0)
+ | (IsGadgetHelper<T>::IsGadgetOrDerivedFrom ? QMetaType::IsGadget : 0)
+ | (IsPointerToGadgetHelper<T>::IsGadgetOrDerivedFrom ? QMetaType::PointerToGadget : 0)
};
};
diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h
index 6f1334d082..cef20a5d12 100644
--- a/src/corelib/kernel/qmetatype_p.h
+++ b/src/corelib/kernel/qmetatype_p.h
@@ -201,8 +201,6 @@ template<> struct TypeDefinition<QJsonArray> { static const bool IsAvailable = f
template<> struct TypeDefinition<QJsonDocument> { static const bool IsAvailable = false; };
template<> struct TypeDefinition<QJsonObject> { static const bool IsAvailable = false; };
template<> struct TypeDefinition<QJsonValue> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QModelIndex> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QPersistentModelIndex> { static const bool IsAvailable = false; };
template<> struct TypeDefinition<QUrl> { static const bool IsAvailable = false; };
template<> struct TypeDefinition<QByteArrayList> { static const bool IsAvailable = false; };
#endif
@@ -219,7 +217,7 @@ template<> struct TypeDefinition<QPointF> { static const bool IsAvailable = fals
#ifdef QT_NO_REGEXP
template<> struct TypeDefinition<QRegExp> { static const bool IsAvailable = false; };
#endif
-#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_REGULAREXPRESSION)
+#if !QT_CONFIG(regularexpression)
template<> struct TypeDefinition<QRegularExpression> { static const bool IsAvailable = false; };
#endif
#ifdef QT_NO_SHORTCUT
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index dcbf0f83d4..6747864db4 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -50,7 +50,9 @@
#include "qvariant.h"
#include "qmetaobject.h"
#include <qregexp.h>
-#include <qregularexpression.h>
+#if QT_CONFIG(regularexpression)
+# include <qregularexpression.h>
+#endif
#include <qthread.h>
#include <private/qthread_p.h>
#include <qdebug.h>
@@ -1926,7 +1928,7 @@ void qt_qFindChildren_helper(const QObject *parent, const QRegExp &re,
}
#endif // QT_NO_REGEXP
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
/*!
\internal
*/
@@ -1948,7 +1950,7 @@ void qt_qFindChildren_helper(const QObject *parent, const QRegularExpression &re
qt_qFindChildren_helper(obj, re, mo, list, options);
}
}
-#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_CONFIG(regularexpression)
/*!
\internal
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 0e608a3208..aac9bcdee9 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -74,7 +74,7 @@ class QWidget;
#ifndef QT_NO_REGEXP
class QRegExp;
#endif
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
class QRegularExpression;
#endif
#ifndef QT_NO_USERDATA
@@ -187,7 +187,7 @@ public:
}
#endif
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
template<typename T>
inline QList<T> findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
@@ -197,7 +197,7 @@ public:
reinterpret_cast<QList<void *> *>(&list), options);
return list;
}
-#endif
+#endif // QT_CONFIG(regularexpression)
inline const QObjectList &children() const { return d_ptr->children; }
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 96299b9eaf..6192b66487 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -48,14 +48,18 @@
#include "qdatetime.h"
#include "qeasingcurve.h"
#include "qlist.h"
+#if QT_CONFIG(regularexpression)
#include "qregularexpression.h"
+#endif
#include "qstring.h"
#include "qstringlist.h"
#include "qurl.h"
#include "qlocale.h"
#include "quuid.h"
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(itemmodel)
#include "qabstractitemmodel.h"
+#endif
+#ifndef QT_BOOTSTRAPPED
#include "qjsonvalue.h"
#include "qjsonobject.h"
#include "qjsonarray.h"
@@ -391,6 +395,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return false;
}
break;
+#endif // QT_BOOTSTRAPPED
+#if QT_CONFIG(itemmodel)
case QVariant::ModelIndex:
switch (d->type) {
case QVariant::PersistentModelIndex:
@@ -409,7 +415,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return false;
}
break;
-#endif // QT_BOOTSTRAPPED
+#endif // QT_CONFIG(itemmodel)
case QVariant::String: {
QString *str = static_cast<QString *>(result);
switch (d->type) {
@@ -1941,21 +1947,15 @@ QVariant::QVariant(const QRegExp &regExp)
: d(RegExp)
{ v_construct<QRegExp>(&d, regExp); }
#endif // QT_NO_REGEXP
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
QVariant::QVariant(const QRegularExpression &re)
: d(RegularExpression)
{ v_construct<QRegularExpression>(&d, re); }
-#endif
+#endif // QT_CONFIG(regularexpression)
+#ifndef QT_BOOTSTRAPPED
QVariant::QVariant(const QUuid &uuid)
: d(Uuid)
{ v_construct<QUuid>(&d, uuid); }
-QVariant::QVariant(const QModelIndex &modelIndex)
- : d(ModelIndex)
-{ v_construct<QModelIndex>(&d, modelIndex); }
-QVariant::QVariant(const QPersistentModelIndex &modelIndex)
- : d(PersistentModelIndex)
-{ v_construct<QPersistentModelIndex>(&d, modelIndex); }
QVariant::QVariant(const QJsonValue &jsonValue)
: d(QMetaType::QJsonValue)
{ v_construct<QJsonValue>(&d, jsonValue); }
@@ -1969,6 +1969,14 @@ QVariant::QVariant(const QJsonDocument &jsonDocument)
: d(QMetaType::QJsonDocument)
{ v_construct<QJsonDocument>(&d, jsonDocument); }
#endif // QT_BOOTSTRAPPED
+#if QT_CONFIG(itemmodel)
+QVariant::QVariant(const QModelIndex &modelIndex)
+ : d(ModelIndex)
+{ v_construct<QModelIndex>(&d, modelIndex); }
+QVariant::QVariant(const QPersistentModelIndex &modelIndex)
+ : d(PersistentModelIndex)
+{ v_construct<QPersistentModelIndex>(&d, modelIndex); }
+#endif
/*!
Returns the storage type of the value stored in the variant.
@@ -2371,7 +2379,7 @@ inline T qVariantToHelper(const QVariant::Private &d, const HandlersManager &han
\l QMetaType::QVariantList of a type that can be converted to QString;
otherwise returns an empty list.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QStringList QVariant::toStringList() const
{
@@ -2379,14 +2387,19 @@ QStringList QVariant::toStringList() const
}
/*!
- Returns the variant as a QString if the variant has userType() \l
- QMetaType::QString, \l QMetaType::Bool, \l QMetaType::QByteArray,
+ Returns the variant as a QString if the variant has a userType()
+ including, but not limited to:
+
+ \l QMetaType::QString, \l QMetaType::Bool, \l QMetaType::QByteArray,
\l QMetaType::QChar, \l QMetaType::QDate, \l QMetaType::QDateTime,
\l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong,
\l QMetaType::QStringList, \l QMetaType::QTime, \l QMetaType::UInt, or
- \l QMetaType::ULongLong; otherwise returns an empty string.
+ \l QMetaType::ULongLong.
- \sa canConvert(), convert()
+ Calling QVariant::toString() on an unsupported variant returns an empty
+ string.
+
+ \sa canConvert(int targetTypeId), convert()
*/
QString QVariant::toString() const
{
@@ -2397,7 +2410,7 @@ QString QVariant::toString() const
Returns the variant as a QMap<QString, QVariant> if the variant
has type() \l QMetaType::QVariantMap; otherwise returns an empty map.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QVariantMap QVariant::toMap() const
{
@@ -2408,7 +2421,7 @@ QVariantMap QVariant::toMap() const
Returns the variant as a QHash<QString, QVariant> if the variant
has type() \l QMetaType::QVariantHash; otherwise returns an empty map.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QVariantHash QVariant::toHash() const
{
@@ -2425,7 +2438,7 @@ QVariantHash QVariant::toHash() const
If the type() is \l QMetaType::QString, an invalid date will be returned if
the string cannot be parsed as a Qt::ISODate format date.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QDate QVariant::toDate() const
{
@@ -2442,7 +2455,7 @@ QDate QVariant::toDate() const
If the type() is \l QMetaType::QString, an invalid time will be returned if
the string cannot be parsed as a Qt::ISODate format time.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QTime QVariant::toTime() const
{
@@ -2459,7 +2472,7 @@ QTime QVariant::toTime() const
If the type() is \l QMetaType::QString, an invalid date/time will be
returned if the string cannot be parsed as a Qt::ISODate format date/time.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QDateTime QVariant::toDateTime() const
{
@@ -2473,7 +2486,7 @@ QDateTime QVariant::toDateTime() const
Returns the variant as a QEasingCurve if the variant has userType()
\l QMetaType::QEasingCurve; otherwise returns a default easing curve.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
#ifndef QT_BOOTSTRAPPED
QEasingCurve QVariant::toEasingCurve() const
@@ -2489,7 +2502,7 @@ QEasingCurve QVariant::toEasingCurve() const
\l QMetaType::QByteArray or \l QMetaType::QString (converted using
QString::fromUtf8()); otherwise returns an empty byte array.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QByteArray QVariant::toByteArray() const
{
@@ -2504,7 +2517,7 @@ QByteArray QVariant::toByteArray() const
\l QMetaType::QPoint or \l QMetaType::QPointF; otherwise returns a null
QPoint.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QPoint QVariant::toPoint() const
{
@@ -2517,7 +2530,7 @@ QPoint QVariant::toPoint() const
Returns the variant as a QRect if the variant has userType()
\l QMetaType::QRect; otherwise returns an invalid QRect.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QRect QVariant::toRect() const
{
@@ -2530,7 +2543,7 @@ QRect QVariant::toRect() const
Returns the variant as a QSize if the variant has userType()
\l QMetaType::QSize; otherwise returns an invalid QSize.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QSize QVariant::toSize() const
{
@@ -2543,7 +2556,7 @@ QSize QVariant::toSize() const
Returns the variant as a QSizeF if the variant has userType() \l
QMetaType::QSizeF; otherwise returns an invalid QSizeF.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QSizeF QVariant::toSizeF() const
{
@@ -2557,7 +2570,7 @@ QSizeF QVariant::toSizeF() const
\l QMetaType::QRect or \l QMetaType::QRectF; otherwise returns an invalid
QRectF.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QRectF QVariant::toRectF() const
{
@@ -2570,7 +2583,7 @@ QRectF QVariant::toRectF() const
Returns the variant as a QLineF if the variant has userType()
\l QMetaType::QLineF; otherwise returns an invalid QLineF.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QLineF QVariant::toLineF() const
{
@@ -2583,7 +2596,7 @@ QLineF QVariant::toLineF() const
Returns the variant as a QLine if the variant has userType()
\l QMetaType::QLine; otherwise returns an invalid QLine.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QLine QVariant::toLine() const
{
@@ -2597,7 +2610,7 @@ QLine QVariant::toLine() const
QMetaType::QPoint or \l QMetaType::QPointF; otherwise returns a null
QPointF.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QPointF QVariant::toPointF() const
{
@@ -2613,7 +2626,7 @@ QPointF QVariant::toPointF() const
Returns the variant as a QUrl if the variant has userType()
\l QMetaType::QUrl; otherwise returns an invalid QUrl.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QUrl QVariant::toUrl() const
{
@@ -2627,7 +2640,7 @@ QUrl QVariant::toUrl() const
Returns the variant as a QLocale if the variant has userType()
\l QMetaType::QLocale; otherwise returns an invalid QLocale.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QLocale QVariant::toLocale() const
{
@@ -2641,7 +2654,7 @@ QLocale QVariant::toLocale() const
Returns the variant as a QRegExp if the variant has userType()
\l QMetaType::QRegExp; otherwise returns an empty QRegExp.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
#ifndef QT_NO_REGEXP
QRegExp QVariant::toRegExp() const
@@ -2650,7 +2663,7 @@ QRegExp QVariant::toRegExp() const
}
#endif
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(regularexpression)
/*!
\fn QRegularExpression QVariant::toRegularExpression() const
\since 5.0
@@ -2658,36 +2671,22 @@ QRegExp QVariant::toRegExp() const
Returns the variant as a QRegularExpression if the variant has userType() \l
QRegularExpression; otherwise returns an empty QRegularExpression.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
-#ifndef QT_NO_REGULAREXPRESSION
QRegularExpression QVariant::toRegularExpression() const
{
return qVariantToHelper<QRegularExpression>(d, handlerManager);
}
-#endif // QT_NO_REGULAREXPRESSION
-
-/*!
- \since 5.0
-
- Returns the variant as a QUuid if the variant has type()
- \l QMetaType::QUuid, \l QMetaType::QByteArray or \l QMetaType::QString;
- otherwise returns a default-constructed QUuid.
-
- \sa canConvert(), convert()
-*/
-QUuid QVariant::toUuid() const
-{
- return qVariantToHelper<QUuid>(d, handlerManager);
-}
+#endif // QT_CONFIG(regularexpression)
+#if QT_CONFIG(itemmodel)
/*!
\since 5.0
Returns the variant as a QModelIndex if the variant has userType() \l
QModelIndex; otherwise returns a default constructed QModelIndex.
- \sa canConvert(), convert(), toPersistentModelIndex()
+ \sa canConvert(int targetTypeId), convert(), toPersistentModelIndex()
*/
QModelIndex QVariant::toModelIndex() const
{
@@ -2700,12 +2699,28 @@ QModelIndex QVariant::toModelIndex() const
Returns the variant as a QPersistentModelIndex if the variant has userType() \l
QPersistentModelIndex; otherwise returns a default constructed QPersistentModelIndex.
- \sa canConvert(), convert(), toModelIndex()
+ \sa canConvert(int targetTypeId), convert(), toModelIndex()
*/
QPersistentModelIndex QVariant::toPersistentModelIndex() const
{
return qVariantToHelper<QPersistentModelIndex>(d, handlerManager);
}
+#endif // QT_CONFIG(itemmodel)
+
+#ifndef QT_BOOTSTRAPPED
+/*!
+ \since 5.0
+
+ Returns the variant as a QUuid if the variant has type()
+ \l QMetaType::QUuid, \l QMetaType::QByteArray or \l QMetaType::QString;
+ otherwise returns a default-constructed QUuid.
+
+ \sa canConvert(int targetTypeId), convert()
+*/
+QUuid QVariant::toUuid() const
+{
+ return qVariantToHelper<QUuid>(d, handlerManager);
+}
/*!
\since 5.0
@@ -2713,7 +2728,7 @@ QPersistentModelIndex QVariant::toPersistentModelIndex() const
Returns the variant as a QJsonValue if the variant has userType() \l
QJsonValue; otherwise returns a default constructed QJsonValue.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QJsonValue QVariant::toJsonValue() const
{
@@ -2726,7 +2741,7 @@ QJsonValue QVariant::toJsonValue() const
Returns the variant as a QJsonObject if the variant has userType() \l
QJsonObject; otherwise returns a default constructed QJsonObject.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QJsonObject QVariant::toJsonObject() const
{
@@ -2739,7 +2754,7 @@ QJsonObject QVariant::toJsonObject() const
Returns the variant as a QJsonArray if the variant has userType() \l
QJsonArray; otherwise returns a default constructed QJsonArray.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QJsonArray QVariant::toJsonArray() const
{
@@ -2752,13 +2767,13 @@ QJsonArray QVariant::toJsonArray() const
Returns the variant as a QJsonDocument if the variant has userType() \l
QJsonDocument; otherwise returns a default constructed QJsonDocument.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QJsonDocument QVariant::toJsonDocument() const
{
return qVariantToHelper<QJsonDocument>(d, handlerManager);
}
-#endif
+#endif // QT_BOOTSTRAPPED
/*!
\fn QChar QVariant::toChar() const
@@ -2767,7 +2782,7 @@ QJsonDocument QVariant::toJsonDocument() const
\l QMetaType::QChar, \l QMetaType::Int, or \l QMetaType::UInt; otherwise
returns an invalid QChar.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QChar QVariant::toChar() const
{
@@ -2778,7 +2793,7 @@ QChar QVariant::toChar() const
Returns the variant as a QBitArray if the variant has userType()
\l QMetaType::QBitArray; otherwise returns an empty bit array.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QBitArray QVariant::toBitArray() const
{
@@ -2821,7 +2836,7 @@ inline T qNumVariantToHelper(const QVariant::Private &d,
will not be reflected in \a ok. A simple workaround is to use
QString::toInt().
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
int QVariant::toInt(bool *ok) const
{
@@ -2843,7 +2858,7 @@ int QVariant::toInt(bool *ok) const
overflow will not be reflected in \a ok. A simple workaround is to use
QString::toUInt().
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
uint QVariant::toUInt(bool *ok) const
{
@@ -2860,7 +2875,7 @@ uint QVariant::toUInt(bool *ok) const
If \a ok is non-null: \c{*}\c{ok} is set to true if the value could be
converted to an int; otherwise \c{*}\c{ok} is set to false.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
qlonglong QVariant::toLongLong(bool *ok) const
{
@@ -2877,7 +2892,7 @@ qlonglong QVariant::toLongLong(bool *ok) const
If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be
converted to an int; otherwise \c{*}\a{ok} is set to false.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
qulonglong QVariant::toULongLong(bool *ok) const
{
@@ -2894,7 +2909,7 @@ qulonglong QVariant::toULongLong(bool *ok) const
\l QMetaType::QByteArray and its lower-case content is not one of the
following: empty, "0" or "false"; otherwise returns \c false.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
bool QVariant::toBool() const
{
@@ -2917,7 +2932,7 @@ bool QVariant::toBool() const
If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be
converted to a double; otherwise \c{*}\a{ok} is set to false.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
double QVariant::toDouble(bool *ok) const
{
@@ -2936,7 +2951,7 @@ double QVariant::toDouble(bool *ok) const
If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be
converted to a double; otherwise \c{*}\a{ok} is set to false.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
float QVariant::toFloat(bool *ok) const
{
@@ -2955,7 +2970,7 @@ float QVariant::toFloat(bool *ok) const
If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be
converted to a double; otherwise \c{*}\a{ok} is set to false.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
qreal QVariant::toReal(bool *ok) const
{
@@ -2967,7 +2982,7 @@ qreal QVariant::toReal(bool *ok) const
\l QMetaType::QVariantList or \l QMetaType::QStringList; otherwise returns
an empty list.
- \sa canConvert(), convert()
+ \sa canConvert(int targetTypeId), convert()
*/
QVariantList QVariant::toList() const
{
@@ -3180,9 +3195,11 @@ bool QVariant::canConvert(int targetTypeId) const
if (d.type == targetTypeId)
return true;
+#if QT_CONFIG(itemmodel)
if ((targetTypeId == QMetaType::QModelIndex && d.type == QMetaType::QPersistentModelIndex)
|| (targetTypeId == QMetaType::QPersistentModelIndex && d.type == QMetaType::QModelIndex))
return true;
+#endif
if (targetTypeId == QMetaType::QVariantList
&& (d.type == QMetaType::QVariantList
@@ -3347,7 +3364,7 @@ bool QVariant::canConvert(int targetTypeId) const
failed a previous conversion will always fail, changing the type, remaining null,
and returning \c false.
- \sa canConvert(), clear()
+ \sa canConvert(int targetTypeId), clear()
*/
bool QVariant::convert(int targetTypeId)
@@ -3896,7 +3913,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\sa setValue(), value()
*/
-/*! \fn static inline QVariant fromStdVariant(const std::variant<T, Types...> &value)
+/*! \fn template<typename... Types> QVariant QVariant::fromStdVariant(const std::variant<Types...> &value)
\since 5.11
Returns a QVariant with the type and value of the active variant of \a value. If
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index fe1ef1bdfc..9a5fc63d03 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -81,9 +81,9 @@ class QRectF;
#ifndef QT_NO_REGEXP
class QRegExp;
#endif // QT_NO_REGEXP
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
class QRegularExpression;
-#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_CONFIG(regularexpression)
class QTextFormat;
class QTextLength;
class QUrl;
@@ -165,8 +165,10 @@ class Q_CORE_EXPORT QVariant
Hash = QMetaType::QVariantHash,
EasingCurve = QMetaType::QEasingCurve,
Uuid = QMetaType::QUuid,
+#if QT_CONFIG(itemmodel)
ModelIndex = QMetaType::QModelIndex,
PersistentModelIndex = QMetaType::QPersistentModelIndex,
+#endif
LastCoreType = QMetaType::LastCoreType,
Font = QMetaType::QFont,
@@ -248,20 +250,22 @@ class Q_CORE_EXPORT QVariant
#ifndef QT_NO_REGEXP
QVariant(const QRegExp &regExp);
#endif // QT_NO_REGEXP
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
QVariant(const QRegularExpression &re);
-#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_CONFIG(regularexpression)
+#ifndef QT_BOOTSTRAPPED
QVariant(const QUrl &url);
QVariant(const QEasingCurve &easing);
QVariant(const QUuid &uuid);
- QVariant(const QModelIndex &modelIndex);
- QVariant(const QPersistentModelIndex &modelIndex);
QVariant(const QJsonValue &jsonValue);
QVariant(const QJsonObject &jsonObject);
QVariant(const QJsonArray &jsonArray);
QVariant(const QJsonDocument &jsonDocument);
#endif // QT_BOOTSTRAPPED
+#if QT_CONFIG(itemmodel)
+ QVariant(const QModelIndex &modelIndex);
+ QVariant(const QPersistentModelIndex &modelIndex);
+#endif
QVariant& operator=(const QVariant &other);
#ifdef Q_COMPILER_RVALUE_REFS
@@ -322,20 +326,22 @@ class Q_CORE_EXPORT QVariant
#ifndef QT_NO_REGEXP
QRegExp toRegExp() const;
#endif // QT_NO_REGEXP
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
QRegularExpression toRegularExpression() const;
-#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_CONFIG(regularexpression)
+#ifndef QT_BOOTSTRAPPED
QUrl toUrl() const;
QEasingCurve toEasingCurve() const;
QUuid toUuid() const;
- QModelIndex toModelIndex() const;
- QPersistentModelIndex toPersistentModelIndex() const;
QJsonValue toJsonValue() const;
QJsonObject toJsonObject() const;
QJsonArray toJsonArray() const;
QJsonDocument toJsonDocument() const;
#endif // QT_BOOTSTRAPPED
+#if QT_CONFIG(itemmodel)
+ QModelIndex toModelIndex() const;
+ QPersistentModelIndex toPersistentModelIndex() const;
+#endif
#ifndef QT_NO_DATASTREAM
void load(QDataStream &ds);
@@ -359,7 +365,7 @@ class Q_CORE_EXPORT QVariant
static inline QVariant fromValue(const T &value)
{ return qVariantFromValue(value); }
-#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
+#if defined(Q_CLANG_QDOC) || (QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L)
template<typename... Types>
static inline QVariant fromStdVariant(const std::variant<Types...> &value)
{