diff options
Diffstat (limited to 'src/corelib/kernel/qmetatype.cpp')
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 87 |
1 files changed, 72 insertions, 15 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index ae56de118c..1c2665e53c 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -5,7 +5,6 @@ #include "qmetatype.h" #include "qmetatype_p.h" -#include "qobject.h" #include "qobjectdefs.h" #include "qdatetime.h" #include "qbytearray.h" @@ -43,6 +42,7 @@ # include "qmetaobject.h" # include "qsequentialiterable.h" # include "qassociativeiterable.h" +# include "qobject.h" #endif #if QT_CONFIG(itemmodel) @@ -56,7 +56,6 @@ # include "qline.h" #endif -#include <bitset> #include <new> #include <cstring> @@ -151,13 +150,7 @@ struct QMetaTypeCustomRegistry auto &ti = registry[idx]; // We must unregister all names. - auto it = aliases.begin(); - while (it != aliases.end()) { - if (it.value() == ti) - it = aliases.erase(it); - else - ++it; - } + aliases.removeIf([ti] (const auto &kv) { return kv.value() == ti; }); ti = nullptr; @@ -481,6 +474,7 @@ const char *QtMetaTypePrivate::typedefNameForType(const QtPrivate::QMetaTypeInte \ingroup objectmodel \threadsafe + \compares equality The class is used as a helper to marshall types in QVariant and in queued signals and slots connections. It associates a type @@ -932,20 +926,20 @@ void QMetaType::unregisterMetaType(QMetaType type) Returns the QMetaType corresponding to the type in the template parameter. */ -/*! \fn bool QMetaType::operator==(QMetaType a, QMetaType b) +/*! \fn bool QMetaType::operator==(const QMetaType &lhs, const QMetaType &rhs) \since 5.15 \overload - Returns \c true if the QMetaType \a a represents the same type - as the QMetaType \a b, otherwise returns \c false. + Returns \c true if the QMetaType \a lhs represents the same type + as the QMetaType \a rhs, otherwise returns \c false. */ -/*! \fn bool QMetaType::operator!=(QMetaType a, QMetaType b) +/*! \fn bool QMetaType::operator!=(const QMetaType &lhs, const QMetaType &rhs) \since 5.15 \overload - Returns \c true if the QMetaType \a a represents a different type - than the QMetaType \a b, otherwise returns \c false. + Returns \c true if the QMetaType \a lhs represents a different type + than the QMetaType \a rhs, otherwise returns \c false. */ /*! \internal */ @@ -1017,6 +1011,8 @@ static constexpr struct : QMetaTypeModuleHelper using Double = double; using Bool = bool; using Nullptr = std::nullptr_t; + using Char16 = char16_t; + using Char32 = char32_t; #define QMETATYPE_CONVERTER_ASSIGN_DOUBLE(To, From) \ QMETATYPE_CONVERTER(To, From, result = double(source); return true;) @@ -1171,6 +1167,9 @@ static constexpr struct : QMetaTypeModuleHelper QMETATYPE_CONVERTER_ASSIGN_QCHAR(ULong); QMETATYPE_CONVERTER_ASSIGN_QCHAR(UInt); QMETATYPE_CONVERTER_ASSIGN_QCHAR(ULongLong); + QMETATYPE_CONVERTER_ASSIGN_QCHAR(Char16); + + QMETATYPE_CONVERTER(Char16, QChar, result = source.unicode(); return true;) // conversions to QString QMETATYPE_CONVERTER_ASSIGN(QString, QChar); @@ -1208,6 +1207,14 @@ static constexpr struct : QMetaTypeModuleHelper result = QString::fromLatin1(&s, 1); return true; ); + QMETATYPE_CONVERTER(QString, Char16, + result = QChar(source); + return true; + ); + QMETATYPE_CONVERTER(QString, Char32, + result = QChar::fromUcs4(source).operator QStringView().toString(); + return true; + ); #if QT_CONFIG(datestring) QMETATYPE_CONVERTER(QString, QDate, result = source.toString(Qt::ISODate); return true;); QMETATYPE_CONVERTER(QString, QTime, result = source.toString(Qt::ISODateWithMs); return true;); @@ -2653,6 +2660,36 @@ bool QMetaType::hasRegisteredConverterFunction(QMetaType fromType, QMetaType toT } /*! + \internal + Non-template helper ("SCARY") for IsMetaTypePair::registerConverter(). +*/ +bool QtPrivate::hasRegisteredConverterFunctionToPairVariantInterface(QMetaType m) +{ + const QMetaType to = QMetaType::fromType<QtMetaTypePrivate::QPairVariantInterfaceImpl>(); + return QMetaType::hasRegisteredConverterFunction(m, to); +} + +/*! + \internal + Non-template helper ("SCARY") for SequentialValueTypeIsMetaType::registerConverter(). +*/ +bool QtPrivate::hasRegisteredConverterFunctionToIterableMetaSequence(QMetaType m) +{ + const QMetaType to = QMetaType::fromType<QIterable<QMetaSequence>>(); + return QMetaType::hasRegisteredConverterFunction(m, to); +} + +/*! + \internal + Non-template helper ("SCARY") for AssociativeKeyTypeIsMetaType::registerConverter(). +*/ +bool QtPrivate::hasRegisteredConverterFunctionToIterableMetaAssociation(QMetaType m) +{ + const QMetaType to = QMetaType::fromType<QIterable<QMetaAssociation>>(); + return QMetaType::hasRegisteredConverterFunction(m, to); +} + +/*! \fn template<typename From, typename To> bool QMetaType::hasRegisteredMutableViewFunction() Returns \c true, if the meta type system has a registered mutable view on type From of type To. \since 6.0 @@ -2670,6 +2707,26 @@ bool QMetaType::hasRegisteredMutableViewFunction(QMetaType fromType, QMetaType t } /*! + \internal + Non-template helper ("SCARY") for SequentialValueTypeIsMetaType::registerMutableView(). +*/ +bool QtPrivate::hasRegisteredMutableViewFunctionToIterableMetaSequence(QMetaType m) +{ + const QMetaType to = QMetaType::fromType<QIterable<QMetaSequence>>(); + return QMetaType::hasRegisteredMutableViewFunction(m, to); +} + +/*! + \internal + Non-template helper ("SCARY") for AssociativeKeyTypeIsMetaType::registerMutableView(). +*/ +bool QtPrivate::hasRegisteredMutableViewFunctionToIterableMetaAssociation(QMetaType m) +{ + const QMetaType to = QMetaType::fromType<QIterable<QMetaAssociation>>(); + return QMetaType::hasRegisteredMutableViewFunction(m, to); +} + +/*! \fn const char *QMetaType::typeName(int typeId) \deprecated |