From 73d1476fb1397948a4d806bd921fce372bd8d63b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Dec 2019 17:54:48 +0100 Subject: Replace most use of QVariant::type and occurrences of QVariant::Type I made a clazy automated check that replaced the use of QVariant::Type by the equivalent in QMetaType. This has been deprecated since Qt 5.0, but many uses were not yet removed. In addition, there was some manual changes to fix the compilation errors. Adapted the Private API of QDateTimeParser and QMimeDataPrivate and adjust QDateTimeEdit and QSpinBox. QVariant(QVariant::Invalid) in qstylesheet made no sense. But note that in QVariant::save, we actually wanted to use the non-user type. In the SQL module, many changes were actually reverted because the API still expects QVarient::Type. Change-Id: I98c368490e4ee465ed3a3b63bda8b8eaa50ea67e Reviewed-by: Lars Knoll --- src/corelib/kernel/qmetaobject.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib/kernel/qmetaobject.cpp') diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index fad47eee13..347fb1eb87 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -2982,7 +2982,7 @@ int QMetaProperty::userType() const if (type == QMetaType::UnknownType) { type = registerPropertyType(); if (type == QMetaType::UnknownType) - return QVariant::Int; // Match behavior of QMetaType::type() + return QMetaType::Int; // Match behavior of QMetaType::type() } return type; } @@ -3100,7 +3100,7 @@ QVariant QMetaProperty::read(const QObject *object) const if (!object || !mobj) return QVariant(); - uint t = QVariant::Int; + uint t = QMetaType::Int; if (isEnumType()) { /* try to create a QVariant that can be converted to this enum @@ -3177,9 +3177,9 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const return false; QVariant v = value; - uint t = QVariant::Invalid; + uint t = QMetaType::UnknownType; if (isEnumType()) { - if (v.type() == QVariant::String) { + if (v.userType() == QMetaType::QString) { bool ok; if (isFlagType()) v = QVariant(menum.keysToValue(value.toByteArray(), &ok)); @@ -3187,13 +3187,13 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const v = QVariant(menum.keyToValue(value.toByteArray(), &ok)); if (!ok) return false; - } else if (v.type() != QVariant::Int && v.type() != QVariant::UInt) { + } else if (v.userType() != QMetaType::Int && v.userType() != QMetaType::UInt) { int enumMetaTypeId = QMetaType::type(qualifiedName(menum)); if ((enumMetaTypeId == QMetaType::UnknownType) || (v.userType() != enumMetaTypeId) || !v.constData()) return false; v = QVariant(*reinterpret_cast(v.constData())); } - v.convert(QVariant::Int); + v.convert(QMetaType::Int); } else { int handle = priv(mobj->d.data)->propertyData + 3*idx; const char *typeName = nullptr; -- cgit v1.2.3 From cb3152086c61e7c51ed1c5f8c5946364e19abc4d Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 21 Jan 2020 15:33:11 +0100 Subject: Introduce Q_PROPERTY attribute REQUIRED This is meant to correspond to required properties in QML. Change-Id: I2645981e13f7423bc86b48370c165b3cfe2aaa62 Task-number: QTBUG-81561 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qmetaobject.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/corelib/kernel/qmetaobject.cpp') diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 347fb1eb87..37f5acc5c5 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -3572,6 +3572,21 @@ bool QMetaProperty::isFinal() const return flags & Final; } +/*! + \since 5.15 + Returns \c true if the property is required; otherwise returns \c false. + + A property is final if the \c{Q_PROPERTY()}'s \c REQUIRED attribute + is set. +*/ +bool QMetaProperty::isRequired() const +{ + if (!mobj) + return false; + int flags = mobj->d.data[handle + 2]; + return flags & Required; +} + /*! \obsolete -- cgit v1.2.3 From 582311d1224cb196d8149bdfd8f178d5239c6b28 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Mon, 27 Jan 2020 17:11:51 +0800 Subject: Doc: Replace some usages of 0/zero/null with \nullptr Change-Id: Ibe7de11fc6fc41477c35e7d653c6a911855deabb Reviewed-by: Paul Wicking --- src/corelib/kernel/qmetaobject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel/qmetaobject.cpp') diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 37f5acc5c5..1661520b78 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -599,7 +599,7 @@ static bool methodMatch(const QMetaObject *m, int handle, * \internal * helper function for indexOf{Method,Slot,Signal}, returns the relative index of the method within * the baseObject -* \a MethodType might be MethodSignal or MethodSlot, or 0 to match everything. +* \a MethodType might be MethodSignal or MethodSlot, or \nullptr to match everything. */ template static inline int indexOfMethodRelative(const QMetaObject **baseObject, @@ -731,7 +731,7 @@ int QMetaObject::indexOfSignal(const char *signal) const \internal Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object. - \a baseObject will be adjusted to the enclosing QMetaObject, or 0 if the signal is not found + \a baseObject will be adjusted to the enclosing QMetaObject, or \nullptr if the signal is not found */ int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, const QByteArray &name, int argc, -- cgit v1.2.3