From db81129240d1198884b4197857ec5934a5dc33d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 20 Jan 2020 15:07:34 +0100 Subject: macOS: Remove doc references to the Carbon framework Change-Id: I4d496acfc3d810d6334baba99cd697168bef0b75 Reviewed-by: Timur Pocheptsov --- src/corelib/global/qnamespace.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index bebe67be3f..1908fedead 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1017,7 +1017,7 @@ \value WA_MacNoClickThrough This value is obsolete and has no effect. - \value WA_MacOpaqueSizeGrip Indicates that the native Carbon size grip + \value WA_MacOpaqueSizeGrip Indicates that the native size grip should be opaque instead of transparent (the default). This attribute is only applicable to \macos and is set by the widget's author. -- cgit v1.2.3 From d0e9e5a36e3e49ec9fb0fb3f1639c21e7414c615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 21 Jan 2020 14:13:03 +0100 Subject: macOS: Work around CoreFoundation failing to resolve bundle resources When a framework is loaded from a Samba share CoreFoundation will fail to resolve its Resources directory, and hence its Info.plist, which means we can't look up the bundle by id. Until this has been fixed in CoreFoundation and/or the macOS Samba implementation we work around it by manually looking for QtCore. This fixes our particular use-case of finding QtCore so we can resolve the relocatable prefix, but there's still a potential issue if any other code tries to use CF for bundle lookups. We don't seem to have any of those in Qt itself, but this should be kept in mind if we see similar issues in the future. Change-Id: I8fd471e44f6afe33a7459ce550f0fcec9acfefb4 Reviewed-by: Alexandru Croitor --- src/corelib/global/qlibraryinfo.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index f0f77fe68e..7d6beaf9c2 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -535,8 +535,25 @@ static QString getRelocatablePrefix() #if defined(QT_STATIC) prefixPath = prefixFromAppDirHelper(); #elif defined(Q_OS_DARWIN) && QT_CONFIG(framework) - CFBundleRef qtCoreBundle = CFBundleGetBundleWithIdentifier( - CFSTR("org.qt-project.QtCore")); + auto qtCoreBundle = CFBundleGetBundleWithIdentifier(CFSTR("org.qt-project.QtCore")); + if (!qtCoreBundle) { + // When running Qt apps over Samba shares, CoreFoundation will fail to find + // the Resources directory inside the bundle, This directory is a symlink, + // and CF relies on readdir() and dtent.dt_type to detect symlinks, which + // does not work reliably for Samba shares. We work around it by manually + // looking for the QtCore bundle. + auto allBundles = CFBundleGetAllBundles(); + auto bundleCount = CFArrayGetCount(allBundles); + for (int i = 0; i < bundleCount; ++i) { + auto bundle = CFBundleRef(CFArrayGetValueAtIndex(allBundles, i)); + auto url = QCFType(CFBundleCopyBundleURL(bundle)); + auto path = QCFType(CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle)); + if (CFStringHasSuffix(path, CFSTR("/QtCore.framework"))) { + qtCoreBundle = bundle; + break; + } + } + } Q_ASSERT(qtCoreBundle); QCFType qtCorePath = CFBundleCopyBundleURL(qtCoreBundle); -- cgit v1.2.3 From 0b28f1e3bae10def59e7fe8afac29ed5355a3f1e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 21 Jan 2020 15:01:55 +0100 Subject: Fix QLocale::system() and uiLanguages() for the mobile platforms On iOS, it was no longer using the Cocoa specific code needed to get the locale and uiLanguages information so this functionality is brought back as it was accidently lost. In addition, this has a side-effect of fixing a problem with Android versions below API 24 where it has no UiLanguages functionality so it gets the information based on the system locale as a fallback. Fixes: QTBUG-81307 Fixes: QTBUG-81357 Change-Id: I1709675b5bd5e9cedefb99eaec28279f20a347a4 Reviewed-by: Edward Welbourne --- src/corelib/text/qlocale.cpp | 2 ++ src/corelib/text/text.pri | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index e3530eeee1..d8c4b41624 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -4463,6 +4463,8 @@ QStringList QLocale::uiLanguages() const for (const auto entry : qAsConst(uiLanguages)) locales.append(QLocale(entry)); } + if (locales.isEmpty()) + locales.append(systemLocale()->fallbackUiLocale()); } else #endif { diff --git a/src/corelib/text/text.pri b/src/corelib/text/text.pri index 25e281f37a..d2a02059c7 100644 --- a/src/corelib/text/text.pri +++ b/src/corelib/text/text.pri @@ -48,7 +48,7 @@ SOURCES += \ NO_PCH_SOURCES += text/qstring_compat.cpp false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator -!nacl:macos: { +!nacl:darwin: { SOURCES += text/qlocale_mac.mm } else:unix { -- cgit v1.2.3 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/animation/qpropertyanimation.cpp | 6 +- src/corelib/io/qsettings.cpp | 34 +- src/corelib/itemmodels/qabstractitemmodel.cpp | 40 +-- src/corelib/kernel/qmetaobject.cpp | 12 +- src/corelib/kernel/qmimedata.cpp | 72 ++-- src/corelib/kernel/qvariant.cpp | 492 +++++++++++++------------- src/corelib/kernel/qvariant_p.h | 4 +- src/corelib/serialization/qjsoncbor.cpp | 38 +- src/corelib/serialization/qjsondocument.cpp | 10 +- src/corelib/serialization/qjsonvalue.cpp | 26 +- src/corelib/text/qlocale.cpp | 6 +- src/corelib/text/qlocale_unix.cpp | 12 +- src/corelib/time/qdatetime.cpp | 6 +- src/corelib/time/qdatetimeparser.cpp | 24 +- src/corelib/time/qdatetimeparser_p.h | 4 +- 15 files changed, 393 insertions(+), 393 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index c71a77e073..d014b5c441 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE void QPropertyAnimationPrivate::updateMetaProperty() { if (!target || propertyName.isEmpty()) { - propertyType = QVariant::Invalid; + propertyType = QMetaType::UnknownType; propertyIndex = -1; return; } @@ -102,11 +102,11 @@ void QPropertyAnimationPrivate::updateMetaProperty() propertyType = targetValue->property(propertyName).userType(); propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName); - if (propertyType != QVariant::Invalid) + if (propertyType != QMetaType::UnknownType) convertValues(propertyType); if (propertyIndex == -1) { //there is no Q_PROPERTY on the object - propertyType = QVariant::Invalid; + propertyType = QMetaType::UnknownType; if (!targetValue->dynamicPropertyNames().contains(propertyName)) qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); } else if (!targetValue->metaObject()->property(propertyIndex).isWritable()) { diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 9fc45e307d..b191397e7e 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -396,12 +396,12 @@ QString QSettingsPrivate::variantToString(const QVariant &v) { QString result; - switch (v.type()) { - case QVariant::Invalid: + switch (v.userType()) { + case QMetaType::UnknownType: result = QLatin1String("@Invalid()"); break; - case QVariant::ByteArray: { + case QMetaType::QByteArray: { QByteArray a = v.toByteArray(); result = QLatin1String("@ByteArray(") + QLatin1String(a.constData(), a.size()) @@ -409,14 +409,14 @@ QString QSettingsPrivate::variantToString(const QVariant &v) break; } - case QVariant::String: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::Int: - case QVariant::UInt: - case QVariant::Bool: - case QVariant::Double: - case QVariant::KeySequence: { + case QMetaType::QString: + case QMetaType::LongLong: + case QMetaType::ULongLong: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::Bool: + case QMetaType::Double: + case QMetaType::QKeySequence: { result = v.toString(); if (result.contains(QChar::Null)) result = QLatin1String("@String(") + result + QLatin1Char(')'); @@ -425,17 +425,17 @@ QString QSettingsPrivate::variantToString(const QVariant &v) break; } #ifndef QT_NO_GEOM_VARIANT - case QVariant::Rect: { + case QMetaType::QRect: { QRect r = qvariant_cast(v); result = QString::asprintf("@Rect(%d %d %d %d)", r.x(), r.y(), r.width(), r.height()); break; } - case QVariant::Size: { + case QMetaType::QSize: { QSize s = qvariant_cast(v); result = QString::asprintf("@Size(%d %d)", s.width(), s.height()); break; } - case QVariant::Point: { + case QMetaType::QPoint: { QPoint p = qvariant_cast(v); result = QString::asprintf("@Point(%d %d)", p.x(), p.y()); break; @@ -446,7 +446,7 @@ QString QSettingsPrivate::variantToString(const QVariant &v) #ifndef QT_NO_DATASTREAM QDataStream::Version version; const char *typeSpec; - if (v.type() == QVariant::DateTime) { + if (v.userType() == QMetaType::QDateTime) { version = QDataStream::Qt_5_6; typeSpec = "@DateTime("; } else { @@ -1888,8 +1888,8 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti QVariant(QString("foo")).toList() returns an empty list, not a list containing "foo". */ - if (value.type() == QVariant::StringList - || (value.type() == QVariant::List && value.toList().size() != 1)) { + if (value.userType() == QMetaType::QStringList + || (value.userType() == QMetaType::QVariantList && value.toList().size() != 1)) { iniEscapedStringList(variantListToStringList(value.toList()), block, iniCodec); } else { iniEscapedString(variantToString(value), block, iniCodec); diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 46ac703615..608407c136 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -552,32 +552,32 @@ const QHash &QAbstractItemModelPrivate::defaultRoleNames() bool QAbstractItemModelPrivate::isVariantLessThan(const QVariant &left, const QVariant &right, Qt::CaseSensitivity cs, bool isLocaleAware) { - if (left.userType() == QVariant::Invalid) + if (left.userType() == QMetaType::UnknownType) return false; - if (right.userType() == QVariant::Invalid) + if (right.userType() == QMetaType::UnknownType) return true; switch (left.userType()) { - case QVariant::Int: + case QMetaType::Int: return left.toInt() < right.toInt(); - case QVariant::UInt: + case QMetaType::UInt: return left.toUInt() < right.toUInt(); - case QVariant::LongLong: + case QMetaType::LongLong: return left.toLongLong() < right.toLongLong(); - case QVariant::ULongLong: + case QMetaType::ULongLong: return left.toULongLong() < right.toULongLong(); case QMetaType::Float: return left.toFloat() < right.toFloat(); - case QVariant::Double: + case QMetaType::Double: return left.toDouble() < right.toDouble(); - case QVariant::Char: + case QMetaType::QChar: return left.toChar() < right.toChar(); - case QVariant::Date: + case QMetaType::QDate: return left.toDate() < right.toDate(); - case QVariant::Time: + case QMetaType::QTime: return left.toTime() < right.toTime(); - case QVariant::DateTime: + case QMetaType::QDateTime: return left.toDateTime() < right.toDateTime(); - case QVariant::String: + case QMetaType::QString: default: if (isLocaleAware) return left.toString().localeAwareCompare(right.toString()) < 0; @@ -591,19 +591,19 @@ static uint typeOfVariant(const QVariant &value) { //return 0 for integer, 1 for floating point and 2 for other switch (value.userType()) { - case QVariant::Bool: - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::Char: + case QMetaType::Bool: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::LongLong: + case QMetaType::ULongLong: + case QMetaType::QChar: case QMetaType::Short: case QMetaType::UShort: case QMetaType::UChar: case QMetaType::ULong: case QMetaType::Long: return 0; - case QVariant::Double: + case QMetaType::Double: case QMetaType::Float: return 1; default: @@ -2379,7 +2379,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, } else { // QString or regular expression based matching if (matchType == Qt::MatchRegularExpression) { if (rx.pattern().isEmpty()) { - if (value.type() == QVariant::RegularExpression) { + if (value.userType() == QMetaType::QRegularExpression) { rx = value.toRegularExpression(); } else { rx.setPattern(value.toString()); 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; diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp index 00e5183eb1..fca258c9e3 100644 --- a/src/corelib/kernel/qmimedata.cpp +++ b/src/corelib/kernel/qmimedata.cpp @@ -70,7 +70,7 @@ public: void setData(const QString &format, const QVariant &data); QVariant getData(const QString &format) const; - QVariant retrieveTypedData(const QString &format, QVariant::Type type) const; + QVariant retrieveTypedData(const QString &format, QMetaType::Type type) const; QVector dataList; }; @@ -108,23 +108,23 @@ QVariant QMimeDataPrivate::getData(const QString &format) const return data; } -QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Type type) const +QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QMetaType::Type type) const { Q_Q(const QMimeData); - QVariant data = q->retrieveData(format, type); + QVariant data = q->retrieveData(format, QVariant::Type(type)); // Text data requested: fallback to URL data if available if (format == QLatin1String("text/plain") && !data.isValid()) { - data = retrieveTypedData(textUriListLiteral(), QVariant::List); - if (data.type() == QVariant::Url) { + data = retrieveTypedData(textUriListLiteral(), QMetaType::QVariantList); + if (data.userType() == QMetaType::QUrl) { data = QVariant(data.toUrl().toDisplayString()); - } else if (data.type() == QVariant::List) { + } else if (data.userType() == QMetaType::QVariantList) { QString text; int numUrls = 0; const QList list = data.toList(); for (int i = 0; i < list.size(); ++i) { - if (list.at(i).type() == QVariant::Url) { + if (list.at(i).userType() == QMetaType::QUrl) { text += list.at(i).toUrl().toDisplayString() + QLatin1Char('\n'); ++numUrls; } @@ -135,26 +135,26 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty } } - if (data.type() == type || !data.isValid()) + if (data.userType() == type || !data.isValid()) return data; // provide more conversion possiblities than just what QVariant provides // URLs can be lists as well... - if ((type == QVariant::Url && data.type() == QVariant::List) - || (type == QVariant::List && data.type() == QVariant::Url)) + if ((type == QMetaType::QUrl && data.userType() == QMetaType::QVariantList) + || (type == QMetaType::QVariantList && data.userType() == QMetaType::QUrl)) return data; // images and pixmaps are interchangeable - if ((type == QVariant::Pixmap && data.type() == QVariant::Image) - || (type == QVariant::Image && data.type() == QVariant::Pixmap)) + if ((type == QMetaType::QPixmap && data.userType() == QMetaType::QImage) + || (type == QMetaType::QImage && data.userType() == QMetaType::QPixmap)) return data; - if (data.type() == QVariant::ByteArray) { + if (data.userType() == QMetaType::QByteArray) { // see if we can convert to the requested type switch(type) { #if QT_CONFIG(textcodec) - case QVariant::String: { + case QMetaType::QString: { const QByteArray ba = data.toByteArray(); QTextCodec *codec = QTextCodec::codecForName("utf-8"); if (format == QLatin1String("text/html")) @@ -162,17 +162,17 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty return codec->toUnicode(ba); } #endif // textcodec - case QVariant::Color: { + case QMetaType::QColor: { QVariant newData = data; - newData.convert(QVariant::Color); + newData.convert(QMetaType::QColor); return newData; } - case QVariant::List: { + case QMetaType::QVariantList: { if (format != QLatin1String("text/uri-list")) break; Q_FALLTHROUGH(); } - case QVariant::Url: { + case QMetaType::QUrl: { QByteArray ba = data.toByteArray(); // Qt 3.x will send text/uri-list with a trailing // null-terminator (that is *not* sent for any other @@ -193,23 +193,23 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty break; } - } else if (type == QVariant::ByteArray) { + } else if (type == QMetaType::QByteArray) { // try to convert to bytearray - switch(data.type()) { - case QVariant::ByteArray: - case QVariant::Color: + switch (data.userType()) { + case QMetaType::QByteArray: + case QMetaType::QColor: return data.toByteArray(); - case QVariant::String: + case QMetaType::QString: return data.toString().toUtf8(); - case QVariant::Url: + case QMetaType::QUrl: return data.toUrl().toEncoded(); - case QVariant::List: { + case QMetaType::QVariantList: { // has to be list of URLs QByteArray result; QList list = data.toList(); for (int i = 0; i < list.size(); ++i) { - if (list.at(i).type() == QVariant::Url) { + if (list.at(i).userType() == QMetaType::QUrl) { result += list.at(i).toUrl().toEncoded(); result += "\r\n"; } @@ -340,14 +340,14 @@ QMimeData::~QMimeData() QList QMimeData::urls() const { Q_D(const QMimeData); - QVariant data = d->retrieveTypedData(textUriListLiteral(), QVariant::List); + QVariant data = d->retrieveTypedData(textUriListLiteral(), QMetaType::QVariantList); QList urls; - if (data.type() == QVariant::Url) + if (data.userType() == QMetaType::QUrl) urls.append(data.toUrl()); - else if (data.type() == QVariant::List) { + else if (data.userType() == QMetaType::QVariantList) { QList list = data.toList(); for (int i = 0; i < list.size(); ++i) { - if (list.at(i).type() == QVariant::Url) + if (list.at(i).userType() == QMetaType::QUrl) urls.append(list.at(i).toUrl()); } } @@ -400,11 +400,11 @@ bool QMimeData::hasUrls() const QString QMimeData::text() const { Q_D(const QMimeData); - QVariant utf8Text = d->retrieveTypedData(textPlainUtf8Literal(), QVariant::String); + QVariant utf8Text = d->retrieveTypedData(textPlainUtf8Literal(), QMetaType::QString); if (!utf8Text.isNull()) return utf8Text.toString(); - QVariant data = d->retrieveTypedData(textPlainLiteral(), QVariant::String); + QVariant data = d->retrieveTypedData(textPlainLiteral(), QMetaType::QString); return data.toString(); } @@ -440,7 +440,7 @@ bool QMimeData::hasText() const QString QMimeData::html() const { Q_D(const QMimeData); - QVariant data = d->retrieveTypedData(textHtmlLiteral(), QVariant::String); + QVariant data = d->retrieveTypedData(textHtmlLiteral(), QMetaType::QString); return data.toString(); } @@ -482,7 +482,7 @@ bool QMimeData::hasHtml() const QVariant QMimeData::imageData() const { Q_D(const QMimeData); - return d->retrieveTypedData(applicationXQtImageLiteral(), QVariant::Image); + return d->retrieveTypedData(applicationXQtImageLiteral(), QMetaType::QImage); } /*! @@ -529,7 +529,7 @@ bool QMimeData::hasImage() const QVariant QMimeData::colorData() const { Q_D(const QMimeData); - return d->retrieveTypedData(applicationXColorLiteral(), QVariant::Color); + return d->retrieveTypedData(applicationXColorLiteral(), QMetaType::QColor); } /*! @@ -564,7 +564,7 @@ bool QMimeData::hasColor() const QByteArray QMimeData::data(const QString &mimeType) const { Q_D(const QMimeData); - QVariant data = d->retrieveTypedData(mimeType, QVariant::ByteArray); + QVariant data = d->retrieveTypedData(mimeType, QMetaType::QByteArray); return data.toByteArray(); } diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index f3ac3fcdba..b417683d2a 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -168,7 +168,7 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d) return qlonglong(d->data.l); case QMetaType::Float: return qRound64(d->data.f); - case QVariant::Double: + case QMetaType::Double: return qRound64(d->data.d); #ifndef QT_BOOTSTRAPPED case QMetaType::QJsonValue: @@ -184,9 +184,9 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d) static qulonglong qMetaTypeUNumber(const QVariant::Private *d) { switch (d->type) { - case QVariant::UInt: + case QMetaType::UInt: return d->data.u; - case QVariant::ULongLong: + case QMetaType::ULongLong: return d->data.ull; case QMetaType::UChar: return d->data.uc; @@ -204,13 +204,13 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) *ok = true; switch (uint(d->type)) { - case QVariant::String: + case QMetaType::QString: return v_cast(d)->toLongLong(ok); - case QVariant::Char: + case QMetaType::QChar: return v_cast(d)->unicode(); - case QVariant::ByteArray: + case QMetaType::QByteArray: return v_cast(d)->toLongLong(ok); - case QVariant::Bool: + case QMetaType::Bool: return qlonglong(d->data.b); #ifndef QT_BOOTSTRAPPED case QMetaType::QCborValue: @@ -222,8 +222,8 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) break; Q_FALLTHROUGH(); #endif - case QVariant::Double: - case QVariant::Int: + case QMetaType::Double: + case QMetaType::Int: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: @@ -231,8 +231,8 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) case QMetaType::Float: case QMetaType::LongLong: return qMetaTypeNumber(d); - case QVariant::ULongLong: - case QVariant::UInt: + case QMetaType::ULongLong: + case QMetaType::UInt: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -262,12 +262,12 @@ static qreal qConvertToRealNumber(const QVariant::Private *d, bool *ok) { *ok = true; switch (uint(d->type)) { - case QVariant::Double: + case QMetaType::Double: return qreal(d->data.d); case QMetaType::Float: return qreal(d->data.f); - case QVariant::ULongLong: - case QVariant::UInt: + case QMetaType::ULongLong: + case QMetaType::UInt: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -289,13 +289,13 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) *ok = true; switch (uint(d->type)) { - case QVariant::String: + case QMetaType::QString: return v_cast(d)->toULongLong(ok); - case QVariant::Char: + case QMetaType::QChar: return v_cast(d)->unicode(); - case QVariant::ByteArray: + case QMetaType::QByteArray: return v_cast(d)->toULongLong(ok); - case QVariant::Bool: + case QMetaType::Bool: return qulonglong(d->data.b); #ifndef QT_BOOTSTRAPPED case QMetaType::QCborValue: @@ -309,8 +309,8 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) break; Q_FALLTHROUGH(); #endif - case QVariant::Double: - case QVariant::Int: + case QMetaType::Double: + case QMetaType::Int: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: @@ -318,8 +318,8 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) case QMetaType::Float: case QMetaType::LongLong: return qulonglong(qMetaTypeNumber(d)); - case QVariant::ULongLong: - case QVariant::UInt: + case QMetaType::ULongLong: + case QMetaType::UInt: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -406,9 +406,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) switch (uint(t)) { #ifndef QT_BOOTSTRAPPED - case QVariant::Url: + case QMetaType::QUrl: switch (d->type) { - case QVariant::String: + case QMetaType::QString: *static_cast(result) = QUrl(*v_cast(d)); break; case QMetaType::QCborValue: @@ -423,18 +423,18 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; #endif // QT_BOOTSTRAPPED #if QT_CONFIG(itemmodel) - case QVariant::ModelIndex: + case QMetaType::QModelIndex: switch (d->type) { - case QVariant::PersistentModelIndex: + case QMetaType::QPersistentModelIndex: *static_cast(result) = QModelIndex(*v_cast(d)); break; default: return false; } break; - case QVariant::PersistentModelIndex: + case QMetaType::QPersistentModelIndex: switch (d->type) { - case QVariant::ModelIndex: + case QMetaType::QModelIndex: *static_cast(result) = QPersistentModelIndex(*v_cast(d)); break; default: @@ -442,10 +442,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } break; #endif // QT_CONFIG(itemmodel) - case QVariant::String: { + case QMetaType::QString: { QString *str = static_cast(result); switch (d->type) { - case QVariant::Char: + case QMetaType::QChar: *str = *v_cast(d); break; case QMetaType::Char: @@ -455,12 +455,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; case QMetaType::Short: case QMetaType::Long: - case QVariant::Int: - case QVariant::LongLong: + case QMetaType::Int: + case QMetaType::LongLong: *str = QString::number(qMetaTypeNumber(d)); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UShort: case QMetaType::ULong: *str = QString::number(qMetaTypeUNumber(d)); @@ -468,32 +468,32 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Float: *str = QString::number(d->data.f, 'g', QLocale::FloatingPointShortest); break; - case QVariant::Double: + case QMetaType::Double: *str = QString::number(d->data.d, 'g', QLocale::FloatingPointShortest); break; #if QT_CONFIG(datestring) - case QVariant::Date: + case QMetaType::QDate: *str = v_cast(d)->toString(Qt::ISODate); break; - case QVariant::Time: + case QMetaType::QTime: *str = v_cast(d)->toString(Qt::ISODateWithMs); break; - case QVariant::DateTime: + case QMetaType::QDateTime: *str = v_cast(d)->toString(Qt::ISODateWithMs); break; #endif - case QVariant::Bool: + case QMetaType::Bool: *str = d->data.b ? QStringLiteral("true") : QStringLiteral("false"); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: *str = QString::fromUtf8(v_cast(d)->constData()); break; - case QVariant::StringList: + case QMetaType::QStringList: if (v_cast(d)->count() == 1) *str = v_cast(d)->at(0); break; #ifndef QT_BOOTSTRAPPED - case QVariant::Url: + case QMetaType::QUrl: *str = v_cast(d)->toString(); break; case QMetaType::QJsonValue: @@ -508,7 +508,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) *str = v_cast(d)->toVariant().toString(); break; #endif - case QVariant::Uuid: + case QMetaType::QUuid: *str = v_cast(d)->toString(); break; case QMetaType::Nullptr: @@ -528,11 +528,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } break; } - case QVariant::Char: { + case QMetaType::QChar: { QChar *c = static_cast(result); switch (d->type) { - case QVariant::Int: - case QVariant::LongLong: + case QMetaType::Int: + case QMetaType::LongLong: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: @@ -540,8 +540,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Float: *c = QChar(ushort(qMetaTypeNumber(d))); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -553,10 +553,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; } #ifndef QT_NO_GEOM_VARIANT - case QVariant::Size: { + case QMetaType::QSize: { QSize *s = static_cast(result); switch (d->type) { - case QVariant::SizeF: + case QMetaType::QSizeF: *s = v_cast(d)->toSize(); break; default: @@ -565,10 +565,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; } - case QVariant::SizeF: { + case QMetaType::QSizeF: { QSizeF *s = static_cast(result); switch (d->type) { - case QVariant::Size: + case QMetaType::QSize: *s = QSizeF(*(v_cast(d))); break; default: @@ -577,10 +577,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; } - case QVariant::Line: { + case QMetaType::QLine: { QLine *s = static_cast(result); switch (d->type) { - case QVariant::LineF: + case QMetaType::QLineF: *s = v_cast(d)->toLine(); break; default: @@ -589,10 +589,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; } - case QVariant::LineF: { + case QMetaType::QLineF: { QLineF *s = static_cast(result); switch (d->type) { - case QVariant::Line: + case QMetaType::QLine: *s = QLineF(*(v_cast(d))); break; default: @@ -601,27 +601,27 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; } #endif - case QVariant::StringList: - if (d->type == QVariant::List) { + case QMetaType::QStringList: + if (d->type == QMetaType::QVariantList) { QStringList *slst = static_cast(result); const QVariantList *list = v_cast(d); const int size = list->size(); slst->reserve(size); for (int i = 0; i < size; ++i) slst->append(list->at(i).toString()); - } else if (d->type == QVariant::String) { + } else if (d->type == QMetaType::QString) { QStringList *slst = static_cast(result); *slst = QStringList(*v_cast(d)); } else { return false; } break; - case QVariant::Date: { + case QMetaType::QDate: { QDate *dt = static_cast(result); - if (d->type == QVariant::DateTime) + if (d->type == QMetaType::QDateTime) *dt = v_cast(d)->date(); #if QT_CONFIG(datestring) - else if (d->type == QVariant::String) + else if (d->type == QMetaType::QString) *dt = QDate::fromString(*v_cast(d), Qt::ISODate); #endif else @@ -629,14 +629,14 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return dt->isValid(); } - case QVariant::Time: { + case QMetaType::QTime: { QTime *t = static_cast(result); switch (d->type) { - case QVariant::DateTime: + case QMetaType::QDateTime: *t = v_cast(d)->time(); break; #if QT_CONFIG(datestring) - case QVariant::String: + case QMetaType::QString: *t = QTime::fromString(*v_cast(d), Qt::ISODate); break; #endif @@ -645,11 +645,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } return t->isValid(); } - case QVariant::DateTime: { + case QMetaType::QDateTime: { QDateTime *dt = static_cast(result); switch (d->type) { #if QT_CONFIG(datestring) - case QVariant::String: + case QMetaType::QString: *dt = QDateTime::fromString(*v_cast(d), Qt::ISODate); break; # ifndef QT_BOOTSTRAPPED @@ -661,7 +661,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; # endif #endif - case QVariant::Date: + case QMetaType::QDate: *dt = QDateTime(*v_cast(d)); break; default: @@ -669,13 +669,13 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } return dt->isValid(); } - case QVariant::ByteArray: { + case QMetaType::QByteArray: { QByteArray *ba = static_cast(result); switch (d->type) { - case QVariant::String: + case QMetaType::QString: *ba = v_cast(d)->toUtf8(); break; - case QVariant::Double: + case QMetaType::Double: *ba = QByteArray::number(d->data.d, 'g', QLocale::FloatingPointShortest); break; case QMetaType::Float: @@ -686,22 +686,22 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::UChar: *ba = QByteArray(1, d->data.c); break; - case QVariant::Int: - case QVariant::LongLong: + case QMetaType::Int: + case QMetaType::LongLong: case QMetaType::Short: case QMetaType::Long: *ba = QByteArray::number(qMetaTypeNumber(d)); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UShort: case QMetaType::ULong: *ba = QByteArray::number(qMetaTypeUNumber(d)); break; - case QVariant::Bool: + case QMetaType::Bool: *ba = QByteArray(d->data.b ? "true" : "false"); break; - case QVariant::Uuid: + case QMetaType::QUuid: *ba = v_cast(d)->toByteArray(); break; case QMetaType::Nullptr: @@ -741,16 +741,16 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::ULong: *static_cast(result) = ulong(qConvertToUnsignedNumber(d, ok)); return *ok; - case QVariant::Int: + case QMetaType::Int: *static_cast(result) = int(qConvertToNumber(d, ok)); return *ok; - case QVariant::UInt: + case QMetaType::UInt: *static_cast(result) = uint(qConvertToUnsignedNumber(d, ok)); return *ok; - case QVariant::LongLong: + case QMetaType::LongLong: *static_cast(result) = qConvertToNumber(d, ok); return *ok; - case QVariant::ULongLong: { + case QMetaType::ULongLong: { *static_cast(result) = qConvertToUnsignedNumber(d, ok); return *ok; } @@ -763,21 +763,21 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) *static_cast(result) = qConvertToUnsignedNumber(d, ok); return *ok; } - case QVariant::Bool: { + case QMetaType::Bool: { bool *b = static_cast(result); switch(d->type) { - case QVariant::ByteArray: + case QMetaType::QByteArray: *b = qt_convertToBool(d); break; - case QVariant::String: + case QMetaType::QString: *b = qt_convertToBool(d); break; - case QVariant::Char: + case QMetaType::QChar: *b = !v_cast(d)->isNull(); break; - case QVariant::Double: - case QVariant::Int: - case QVariant::LongLong: + case QMetaType::Double: + case QMetaType::Int: + case QMetaType::LongLong: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: @@ -785,8 +785,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Float: *b = qMetaTypeNumber(d) != Q_INT64_C(0); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -810,31 +810,31 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } break; } - case QVariant::Double: { + case QMetaType::Double: { double *f = static_cast(result); switch (d->type) { - case QVariant::String: + case QMetaType::QString: *f = v_cast(d)->toDouble(ok); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: *f = v_cast(d)->toDouble(ok); break; - case QVariant::Bool: + case QMetaType::Bool: *f = double(d->data.b); break; case QMetaType::Float: *f = double(d->data.f); break; - case QVariant::LongLong: - case QVariant::Int: + case QMetaType::LongLong: + case QMetaType::Int: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: case QMetaType::Long: *f = double(qMetaTypeNumber(d)); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -861,28 +861,28 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Float: { float *f = static_cast(result); switch (d->type) { - case QVariant::String: + case QMetaType::QString: *f = v_cast(d)->toFloat(ok); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: *f = v_cast(d)->toFloat(ok); break; - case QVariant::Bool: + case QMetaType::Bool: *f = float(d->data.b); break; - case QVariant::Double: + case QMetaType::Double: *f = float(d->data.d); break; - case QVariant::LongLong: - case QVariant::Int: + case QMetaType::LongLong: + case QMetaType::Int: case QMetaType::Char: case QMetaType::SChar: case QMetaType::Short: case QMetaType::Long: *f = float(qMetaTypeNumber(d)); break; - case QVariant::UInt: - case QVariant::ULongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: @@ -906,8 +906,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } break; } - case QVariant::List: - if (d->type == QVariant::StringList) { + case QMetaType::QVariantList: + if (d->type == QMetaType::QStringList) { QVariantList *lst = static_cast(result); const QStringList *slist = v_cast(d); const int size = slist->size(); @@ -935,11 +935,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return false; } break; - case QVariant::Map: + case QMetaType::QVariantMap: if (qstrcmp(QMetaType::typeName(d->type), "QMap") == 0) { *static_cast(result) = *static_cast *>(d->data.shared->ptr); - } else if (d->type == QVariant::Hash) { + } else if (d->type == QMetaType::QVariantHash) { QVariantMap *map = static_cast(result); const QVariantHash *hash = v_cast(d); const auto end = hash->end(); @@ -963,11 +963,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return false; } break; - case QVariant::Hash: + case QMetaType::QVariantHash: if (qstrcmp(QMetaType::typeName(d->type), "QHash") == 0) { *static_cast(result) = *static_cast *>(d->data.shared->ptr); - } else if (d->type == QVariant::Map) { + } else if (d->type == QMetaType::QVariantMap) { QVariantHash *hash = static_cast(result); const QVariantMap *map = v_cast(d); const auto end = map->end(); @@ -992,26 +992,26 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } break; #ifndef QT_NO_GEOM_VARIANT - case QVariant::Rect: - if (d->type == QVariant::RectF) + case QMetaType::QRect: + if (d->type == QMetaType::QRectF) *static_cast(result) = (v_cast(d))->toRect(); else return false; break; - case QVariant::RectF: - if (d->type == QVariant::Rect) + case QMetaType::QRectF: + if (d->type == QMetaType::QRect) *static_cast(result) = *v_cast(d); else return false; break; - case QVariant::PointF: - if (d->type == QVariant::Point) + case QMetaType::QPointF: + if (d->type == QMetaType::QPoint) *static_cast(result) = *v_cast(d); else return false; break; - case QVariant::Point: - if (d->type == QVariant::PointF) + case QMetaType::QPoint: + if (d->type == QMetaType::QPointF) *static_cast(result) = (v_cast(d))->toPoint(); else return false; @@ -1022,12 +1022,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return *ok; } #endif - case QVariant::Uuid: + case QMetaType::QUuid: switch (d->type) { - case QVariant::String: + case QMetaType::QString: *static_cast(result) = QUuid(*v_cast(d)); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: *static_cast(result) = QUuid(*v_cast(d)); break; #ifndef QT_BOOTSTRAPPED @@ -1067,7 +1067,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Nullptr: *static_cast(result) = QJsonValue(QJsonValue::Null); break; - case QVariant::Bool: + case QMetaType::Bool: *static_cast(result) = QJsonValue(d->data.b); break; case QMetaType::Int: @@ -1086,19 +1086,19 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) *static_cast(result) = QJsonValue(qConvertToRealNumber(d, ok)); Q_ASSERT(ok); break; - case QVariant::String: + case QMetaType::QString: *static_cast(result) = QJsonValue(*v_cast(d)); break; - case QVariant::StringList: + case QMetaType::QStringList: *static_cast(result) = QJsonValue(QJsonArray::fromStringList(*v_cast(d))); break; - case QVariant::List: + case QMetaType::QVariantList: *static_cast(result) = QJsonValue(QJsonArray::fromVariantList(*v_cast(d))); break; - case QVariant::Map: + case QMetaType::QVariantMap: *static_cast(result) = QJsonValue(QJsonObject::fromVariantMap(*v_cast(d))); break; - case QVariant::Hash: + case QMetaType::QVariantHash: *static_cast(result) = QJsonValue(QJsonObject::fromVariantHash(*v_cast(d))); break; case QMetaType::QJsonObject: @@ -1128,10 +1128,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; case QMetaType::QJsonArray: switch (d->type) { - case QVariant::StringList: + case QMetaType::QStringList: *static_cast(result) = QJsonArray::fromStringList(*v_cast(d)); break; - case QVariant::List: + case QMetaType::QVariantList: *static_cast(result) = QJsonArray::fromVariantList(*v_cast(d)); break; case QMetaType::QJsonValue: @@ -1158,10 +1158,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; case QMetaType::QJsonObject: switch (d->type) { - case QVariant::Map: + case QMetaType::QVariantMap: *static_cast(result) = QJsonObject::fromVariantMap(*v_cast(d)); break; - case QVariant::Hash: + case QMetaType::QVariantHash: *static_cast(result) = QJsonObject::fromVariantHash(*v_cast(d)); break; case QMetaType::QJsonValue: @@ -1197,7 +1197,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QMetaType::Nullptr: *static_cast(result) = QCborValue(QCborValue::Null); break; - case QVariant::Bool: + case QMetaType::Bool: *static_cast(result) = QCborValue(d->data.b); break; case QMetaType::Int: @@ -1219,39 +1219,39 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) *static_cast(result) = QCborValue(qConvertToRealNumber(d, ok)); Q_ASSERT(ok); break; - case QVariant::String: + case QMetaType::QString: *static_cast(result) = *v_cast(d); break; - case QVariant::StringList: + case QMetaType::QStringList: *static_cast(result) = QCborArray::fromStringList(*v_cast(d)); break; - case QVariant::ByteArray: + case QMetaType::QByteArray: *static_cast(result) = *v_cast(d); break; - case QVariant::Date: + case QMetaType::QDate: *static_cast(result) = QCborValue(QDateTime(*v_cast(d))); break; - case QVariant::DateTime: + case QMetaType::QDateTime: *static_cast(result) = QCborValue(*v_cast(d)); break; - case QVariant::Url: + case QMetaType::QUrl: *static_cast(result) = QCborValue(*v_cast(d)); break; #if QT_CONFIG(regularexpression) - case QVariant::RegularExpression: + case QMetaType::QRegularExpression: *static_cast(result) = QCborValue(*v_cast(d)); break; #endif - case QVariant::Uuid: + case QMetaType::QUuid: *static_cast(result) = QCborValue(*v_cast(d)); break; - case QVariant::List: + case QMetaType::QVariantList: *static_cast(result) = QCborArray::fromVariantList(*v_cast(d)); break; - case QVariant::Map: + case QMetaType::QVariantMap: *static_cast(result) = QCborMap::fromVariantMap(*v_cast(d)); break; - case QVariant::Hash: + case QMetaType::QVariantHash: *static_cast(result) = QCborMap::fromVariantHash(*v_cast(d)); break; case QMetaType::QJsonValue: @@ -1287,10 +1287,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; case QMetaType::QCborArray: switch (d->type) { - case QVariant::StringList: + case QMetaType::QStringList: *static_cast(result) = QCborArray::fromStringList(*v_cast(d)); break; - case QVariant::List: + case QMetaType::QVariantList: *static_cast(result) = QCborArray::fromVariantList(*v_cast(d)); break; case QMetaType::QCborValue: @@ -1317,10 +1317,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) break; case QMetaType::QCborMap: switch (d->type) { - case QVariant::Map: + case QMetaType::QVariantMap: *static_cast(result) = QCborMap::fromVariantMap(*v_cast(d)); break; - case QVariant::Hash: + case QMetaType::QVariantHash: *static_cast(result) = QCborMap::fromVariantHash(*v_cast(d)); break; case QMetaType::QCborValue: @@ -1349,10 +1349,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) default: #ifndef QT_NO_QOBJECT - if (d->type == QVariant::String || d->type == QVariant::ByteArray) { + if (d->type == QMetaType::QString || d->type == QMetaType::QByteArray) { QMetaEnum en = metaEnumFromType(t); if (en.isValid()) { - QByteArray keys = (d->type == QVariant::String) ? v_cast(d)->toUtf8() : *v_cast(d); + QByteArray keys = (d->type == QMetaType::QString) ? v_cast(d)->toUtf8() : *v_cast(d); int value = en.keysToValue(keys.constData(), ok); if (*ok) { switch (QMetaType::sizeOf(t)) { @@ -1457,7 +1457,7 @@ static void customConstruct(QVariant::Private *d, const void *copy) const uint size = type.sizeOf(); if (!size) { qWarning("Trying to construct an instance of an invalid type, type id: %i", d->type); - d->type = QVariant::Invalid; + d->type = QMetaType::UnknownType; return; } @@ -2438,43 +2438,43 @@ QVariant::Type QVariant::nameToType(const char *name) enum { MapFromThreeCount = 36 }; static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] = { - QVariant::Invalid, - QVariant::Map, - QVariant::List, - QVariant::String, - QVariant::StringList, - QVariant::Font, - QVariant::Pixmap, - QVariant::Brush, - QVariant::Rect, - QVariant::Size, - QVariant::Color, - QVariant::Palette, + QMetaType::UnknownType, + QMetaType::QVariantMap, + QMetaType::QVariantList, + QMetaType::QString, + QMetaType::QStringList, + QMetaType::QFont, + QMetaType::QPixmap, + QMetaType::QBrush, + QMetaType::QRect, + QMetaType::QSize, + QMetaType::QColor, + QMetaType::QPalette, 0, // ColorGroup - QVariant::Icon, - QVariant::Point, - QVariant::Image, - QVariant::Int, - QVariant::UInt, - QVariant::Bool, - QVariant::Double, + QMetaType::QIcon, + QMetaType::QPoint, + QMetaType::QImage, + QMetaType::Int, + QMetaType::UInt, + QMetaType::Bool, + QMetaType::Double, 0, // Buggy ByteArray, QByteArray never had id == 20 - QVariant::Polygon, - QVariant::Region, - QVariant::Bitmap, - QVariant::Cursor, - QVariant::SizePolicy, - QVariant::Date, - QVariant::Time, - QVariant::DateTime, - QVariant::ByteArray, - QVariant::BitArray, - QVariant::KeySequence, - QVariant::Pen, - QVariant::LongLong, - QVariant::ULongLong, + QMetaType::QPolygon, + QMetaType::QRegion, + QMetaType::QBitmap, + QMetaType::QCursor, + QMetaType::QSizePolicy, + QMetaType::QDate, + QMetaType::QTime, + QMetaType::QDateTime, + QMetaType::QByteArray, + QMetaType::QBitArray, + QMetaType::QKeySequence, + QMetaType::QPen, + QMetaType::LongLong, + QMetaType::ULongLong, #if QT_CONFIG(easingcurve) - QVariant::EasingCurve + QMetaType::QEasingCurve #endif }; @@ -2551,7 +2551,7 @@ void QVariant::load(QDataStream &s) */ void QVariant::save(QDataStream &s) const { - quint32 typeId = type(); + quint32 typeId = d.type >= QMetaType::User ? QMetaType::User : userType(); bool fakeUserType = false; if (s.version() < QDataStream::Qt_4_0) { int i; @@ -3294,80 +3294,80 @@ QVariantList QVariant::toList() const } -static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = +static const quint32 qCanConvertMatrix[QMetaType::LastCoreType + 1] = { /*Invalid*/ 0, -/*Bool*/ 1 << QVariant::Double | 1 << QVariant::Int | 1 << QVariant::UInt - | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::ByteArray - | 1 << QVariant::String | 1 << QVariant::Char, +/*Bool*/ 1 << QMetaType::Double | 1 << QMetaType::Int | 1 << QMetaType::UInt + | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong | 1 << QMetaType::QByteArray + | 1 << QMetaType::QString | 1 << QMetaType::QChar, -/*Int*/ 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double - | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong - | 1 << QVariant::Char | 1 << QVariant::ByteArray | 1 << QVariant::Int, +/*Int*/ 1 << QMetaType::UInt | 1 << QMetaType::QString | 1 << QMetaType::Double + | 1 << QMetaType::Bool | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong + | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray | 1 << QMetaType::Int, -/*UInt*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double - | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong - | 1 << QVariant::Char | 1 << QVariant::ByteArray, +/*UInt*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double + | 1 << QMetaType::Bool | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong + | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray, -/*LLong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double - | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::ULongLong - | 1 << QVariant::Char | 1 << QVariant::ByteArray, +/*LLong*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double + | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::ULongLong + | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray, -/*ULlong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double - | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong - | 1 << QVariant::Char | 1 << QVariant::ByteArray, +/*ULlong*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double + | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::LongLong + | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray, -/*double*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::ULongLong - | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong - | 1 << QVariant::ByteArray, +/*double*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::ULongLong + | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::LongLong + | 1 << QMetaType::QByteArray, -/*QChar*/ 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::LongLong - | 1 << QVariant::ULongLong, +/*QChar*/ 1 << QMetaType::Int | 1 << QMetaType::UInt | 1 << QMetaType::LongLong + | 1 << QMetaType::ULongLong, /*QMap*/ 0, -/*QList*/ 1 << QVariant::StringList, +/*QList*/ 1 << QMetaType::QStringList, -/*QString*/ 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int - | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double - | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime - | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char - | 1 << QVariant::Url | 1 << QVariant::Uuid, +/*QString*/ 1 << QMetaType::QStringList | 1 << QMetaType::QByteArray | 1 << QMetaType::Int + | 1 << QMetaType::UInt | 1 << QMetaType::Bool | 1 << QMetaType::Double + | 1 << QMetaType::QDate | 1 << QMetaType::QTime | 1 << QMetaType::QDateTime + | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong | 1 << QMetaType::QChar + | 1 << QMetaType::QUrl | 1 << QMetaType::QUuid, -/*QStringList*/ 1 << QVariant::List | 1 << QVariant::String, +/*QStringList*/ 1 << QMetaType::QVariantList | 1 << QMetaType::QString, -/*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool - | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong - | 1 << QVariant::Uuid, +/*QByteArray*/ 1 << QMetaType::QString | 1 << QMetaType::Int | 1 << QMetaType::UInt | 1 << QMetaType::Bool + | 1 << QMetaType::Double | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong + | 1 << QMetaType::QUuid, /*QBitArray*/ 0, -/*QDate*/ 1 << QVariant::String | 1 << QVariant::DateTime, +/*QDate*/ 1 << QMetaType::QString | 1 << QMetaType::QDateTime, -/*QTime*/ 1 << QVariant::String | 1 << QVariant::DateTime, +/*QTime*/ 1 << QMetaType::QString | 1 << QMetaType::QDateTime, -/*QDateTime*/ 1 << QVariant::String | 1 << QVariant::Date, +/*QDateTime*/ 1 << QMetaType::QString | 1 << QMetaType::QDate, -/*QUrl*/ 1 << QVariant::String, +/*QUrl*/ 1 << QMetaType::QString, /*QLocale*/ 0, -/*QRect*/ 1 << QVariant::RectF, +/*QRect*/ 1 << QMetaType::QRectF, -/*QRectF*/ 1 << QVariant::Rect, +/*QRectF*/ 1 << QMetaType::QRect, -/*QSize*/ 1 << QVariant::SizeF, +/*QSize*/ 1 << QMetaType::QSizeF, -/*QSizeF*/ 1 << QVariant::Size, +/*QSizeF*/ 1 << QMetaType::QSize, -/*QLine*/ 1 << QVariant::LineF, +/*QLine*/ 1 << QMetaType::QLineF, -/*QLineF*/ 1 << QVariant::Line, +/*QLineF*/ 1 << QMetaType::QLine, -/*QPoint*/ 1 << QVariant::PointF, +/*QPoint*/ 1 << QMetaType::QPointF, -/*QPointF*/ 1 << QVariant::Point, +/*QPointF*/ 1 << QMetaType::QPoint, /*QRegExp*/ 0, @@ -3375,7 +3375,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QEasingCurve*/ 0, -/*QUuid*/ 1 << QVariant::String | 1 << QVariant::ByteArray, +/*QUuid*/ 1 << QMetaType::QString | 1 << QMetaType::QByteArray, }; static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix); @@ -3915,7 +3915,7 @@ static bool qIsNumericType(uint tp) static bool qIsFloatingPoint(uint tp) { - return tp == QVariant::Double || tp == QMetaType::Float; + return tp == QMetaType::Double || tp == QMetaType::Float; } static int normalizeLowerRanks(uint tp) @@ -3927,13 +3927,13 @@ static int normalizeLowerRanks(uint tp) Q_UINT64_C(1) << QMetaType::UChar | Q_UINT64_C(1) << QMetaType::Short | Q_UINT64_C(1) << QMetaType::UShort; - return numericTypeBits & (Q_UINT64_C(1) << tp) ? QVariant::Int : tp; + return numericTypeBits & (Q_UINT64_C(1) << tp) ? uint(QMetaType::Int) : tp; } static int normalizeLong(uint tp) { - const uint IntType = sizeof(long) == sizeof(int) ? QVariant::Int : QVariant::LongLong; - const uint UIntType = sizeof(ulong) == sizeof(uint) ? QVariant::UInt : QVariant::ULongLong; + const uint IntType = sizeof(long) == sizeof(int) ? QMetaType::Int : QMetaType::LongLong; + const uint UIntType = sizeof(ulong) == sizeof(uint) ? QMetaType::UInt : QMetaType::ULongLong; return tp == QMetaType::Long ? IntType : tp == QMetaType::ULong ? UIntType : tp; } @@ -3975,13 +3975,13 @@ static int numericTypePromotion(uint t1, uint t2) // if any of the two is ULongLong, then it wins (highest rank, unsigned) // otherwise, if one of the two is LongLong, then the other is either LongLong too or lower-ranked // otherwise, if one of the two is UInt, then the other is either UInt too or Int - if (t1 == QVariant::ULongLong || t2 == QVariant::ULongLong) - return QVariant::ULongLong; - if (t1 == QVariant::LongLong || t2 == QVariant::LongLong) - return QVariant::LongLong; - if (t1 == QVariant::UInt || t2 == QVariant::UInt) - return QVariant::UInt; - return QVariant::Int; + if (t1 == QMetaType::ULongLong || t2 == QMetaType::ULongLong) + return QMetaType::ULongLong; + if (t1 == QMetaType::LongLong || t2 == QMetaType::LongLong) + return QMetaType::LongLong; + if (t1 == QMetaType::UInt || t2 == QMetaType::UInt) + return QMetaType::UInt; + return QMetaType::Int; } static int integralCompare(uint promotedType, const QVariant::Private *d1, const QVariant::Private *d2) @@ -3994,13 +3994,13 @@ static int integralCompare(uint promotedType, const QVariant::Private *d1, const qlonglong l2 = qConvertToNumber(d2, &ok); Q_ASSERT(ok); - if (promotedType == QVariant::Int) + if (promotedType == QMetaType::Int) return int(l1) < int(l2) ? -1 : int(l1) == int(l2) ? 0 : 1; - if (promotedType == QVariant::UInt) + if (promotedType == QMetaType::UInt) return uint(l1) < uint(l2) ? -1 : uint(l1) == uint(l2) ? 0 : 1; - if (promotedType == QVariant::LongLong) + if (promotedType == QMetaType::LongLong) return l1 < l2 ? -1 : l1 == l2 ? 0 : 1; - if (promotedType == QVariant::ULongLong) + if (promotedType == QMetaType::ULongLong) return qulonglong(l1) < qulonglong(l2) ? -1 : qulonglong(l1) == qulonglong(l2) ? 0 : 1; Q_UNREACHABLE(); diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index b8b63b5e6f..94781a9957 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -362,7 +362,7 @@ class QVariantConstructor FilteredConstructor(const QVariantConstructor &tc) { // ignore types that lives outside of the current library - tc.m_x->type = QVariant::Invalid; + tc.m_x->type = QMetaType::UnknownType; } }; public: @@ -430,7 +430,7 @@ public: {} ~QVariantDestructor() { - m_d->type = QVariant::Invalid; + m_d->type = QMetaType::UnknownType; m_d->is_null = true; m_d->is_shared = false; } diff --git a/src/corelib/serialization/qjsoncbor.cpp b/src/corelib/serialization/qjsoncbor.cpp index 5097f4eb81..ee4dd90416 100644 --- a/src/corelib/serialization/qjsoncbor.cpp +++ b/src/corelib/serialization/qjsoncbor.cpp @@ -640,9 +640,9 @@ static void appendVariant(QCborContainerPrivate *d, const QVariant &variant) // Handle strings and byte arrays directly, to avoid creating a temporary // dummy container to hold their data. int type = variant.userType(); - if (type == QVariant::String) { + if (type == QMetaType::QString) { d->append(variant.toString()); - } else if (type == QVariant::ByteArray) { + } else if (type == QMetaType::QByteArray) { QByteArray ba = variant.toByteArray(); d->appendByteData(ba.constData(), ba.size(), QCborValue::ByteArray); } else { @@ -703,45 +703,45 @@ static void appendVariant(QCborContainerPrivate *d, const QVariant &variant) QCborValue QCborValue::fromVariant(const QVariant &variant) { switch (variant.userType()) { - case QVariant::Invalid: + case QMetaType::UnknownType: return {}; case QMetaType::Nullptr: return nullptr; - case QVariant::Bool: + case QMetaType::Bool: return variant.toBool(); case QMetaType::Short: case QMetaType::UShort: - case QVariant::Int: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::UInt: + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::ULongLong: + case QMetaType::UInt: return variant.toLongLong(); case QMetaType::Float: - case QVariant::Double: + case QMetaType::Double: return variant.toDouble(); - case QVariant::String: + case QMetaType::QString: return variant.toString(); - case QVariant::StringList: + case QMetaType::QStringList: return QCborArray::fromStringList(variant.toStringList()); - case QVariant::ByteArray: + case QMetaType::QByteArray: return variant.toByteArray(); - case QVariant::DateTime: + case QMetaType::QDateTime: return QCborValue(variant.toDateTime()); #ifndef QT_BOOTSTRAPPED - case QVariant::Url: + case QMetaType::QUrl: return QCborValue(variant.toUrl()); #endif - case QVariant::Uuid: + case QMetaType::QUuid: return QCborValue(variant.toUuid()); - case QVariant::List: + case QMetaType::QVariantList: return QCborArray::fromVariantList(variant.toList()); - case QVariant::Map: + case QMetaType::QVariantMap: return QCborMap::fromVariantMap(variant.toMap()); - case QVariant::Hash: + case QMetaType::QVariantHash: return QCborMap::fromVariantHash(variant.toHash()); #ifndef QT_BOOTSTRAPPED #if QT_CONFIG(regularexpression) - case QVariant::RegularExpression: + case QMetaType::QRegularExpression: return QCborValue(variant.toRegularExpression()); #endif case QMetaType::QJsonValue: diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index fe0500bdef..0be0fc020d 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -405,17 +405,17 @@ QJsonDocument QJsonDocument::fromVariant(const QVariant &variant) { QJsonDocument doc; - switch (variant.type()) { - case QVariant::Map: + switch (variant.userType()) { + case QMetaType::QVariantMap: doc.setObject(QJsonObject::fromVariantMap(variant.toMap())); break; - case QVariant::Hash: + case QMetaType::QVariantHash: doc.setObject(QJsonObject::fromVariantHash(variant.toHash())); break; - case QVariant::List: + case QMetaType::QVariantList: doc.setArray(QJsonArray::fromVariantList(variant.toList())); break; - case QVariant::StringList: + case QMetaType::QStringList: doc.d = qt_make_unique(); doc.d->value = QCborArray::fromStringList(variant.toStringList()); break; diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp index 7b6728d525..caf81c79ef 100644 --- a/src/corelib/serialization/qjsonvalue.cpp +++ b/src/corelib/serialization/qjsonvalue.cpp @@ -447,29 +447,29 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant) switch (variant.userType()) { case QMetaType::Nullptr: return QJsonValue(Null); - case QVariant::Bool: + case QMetaType::Bool: return QJsonValue(variant.toBool()); - case QVariant::Int: + case QMetaType::Int: case QMetaType::Float: - case QVariant::Double: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::UInt: + case QMetaType::Double: + case QMetaType::LongLong: + case QMetaType::ULongLong: + case QMetaType::UInt: return QJsonValue(variant.toDouble()); - case QVariant::String: + case QMetaType::QString: return QJsonValue(variant.toString()); - case QVariant::StringList: + case QMetaType::QStringList: return QJsonValue(QJsonArray::fromStringList(variant.toStringList())); - case QVariant::List: + case QMetaType::QVariantList: return QJsonValue(QJsonArray::fromVariantList(variant.toList())); - case QVariant::Map: + case QMetaType::QVariantMap: return QJsonValue(QJsonObject::fromVariantMap(variant.toMap())); - case QVariant::Hash: + case QMetaType::QVariantHash: return QJsonValue(QJsonObject::fromVariantHash(variant.toHash())); #ifndef QT_BOOTSTRAPPED - case QVariant::Url: + case QMetaType::QUrl: return QJsonValue(variant.toUrl().toString(QUrl::FullyEncoded)); - case QVariant::Uuid: + case QMetaType::QUuid: return variant.toUuid().toString(QUuid::WithoutBraces); case QMetaType::QJsonValue: return variant.toJsonValue(); diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 93a8abb1ce..fb45b82967 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -2430,7 +2430,7 @@ QTime QLocale::toTime(const QString &string, const QString &format, QCalendar ca { QTime time; #if QT_CONFIG(datetimeparser) - QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, cal); + QDateTimeParser dt(QMetaType::QTime, QDateTimeParser::FromString, cal); dt.setDefaultLocale(*this); if (dt.parseFormat(format)) dt.fromString(string, nullptr, &time); @@ -2469,7 +2469,7 @@ QDate QLocale::toDate(const QString &string, const QString &format, QCalendar ca { QDate date; #if QT_CONFIG(datetimeparser) - QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal); + QDateTimeParser dt(QMetaType::QDate, QDateTimeParser::FromString, cal); dt.setDefaultLocale(*this); if (dt.parseFormat(format)) dt.fromString(string, &date, nullptr); @@ -2510,7 +2510,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format, QCal QTime time; QDate date; - QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString, cal); + QDateTimeParser dt(QMetaType::QDateTime, QDateTimeParser::FromString, cal); dt.setDefaultLocale(*this); if (dt.parseFormat(format) && dt.fromString(string, &date, &time)) return QDateTime(date, time); diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp index 5e1e47eae7..207331b8ac 100644 --- a/src/corelib/text/qlocale_unix.cpp +++ b/src/corelib/text/qlocale_unix.cpp @@ -234,16 +234,16 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const case CurrencySymbol: return lc_monetary.currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt())); case CurrencyToString: { - switch (in.type()) { - case QVariant::Int: + switch (in.userType()) { + case QMetaType::Int: return lc_monetary.toCurrencyString(in.toInt()); - case QVariant::UInt: + case QMetaType::UInt: return lc_monetary.toCurrencyString(in.toUInt()); - case QVariant::Double: + case QMetaType::Double: return lc_monetary.toCurrencyString(in.toDouble()); - case QVariant::LongLong: + case QMetaType::LongLong: return lc_monetary.toCurrencyString(in.toLongLong()); - case QVariant::ULongLong: + case QMetaType::ULongLong: return lc_monetary.toCurrencyString(in.toULongLong()); default: break; diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 67d37f19d8..80751e60a0 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1791,7 +1791,7 @@ QDate QDate::fromString(const QString &string, const QString &format, QCalendar { QDate date; #if QT_CONFIG(datetimeparser) - QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal); + QDateTimeParser dt(QMetaType::QDate, QDateTimeParser::FromString, cal); // dt.setDefaultLocale(QLocale::c()); ### Qt 6 if (dt.parseFormat(format)) dt.fromString(string, &date, nullptr); @@ -2537,7 +2537,7 @@ QTime QTime::fromString(const QString &string, const QString &format) { QTime time; #if QT_CONFIG(datetimeparser) - QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, QCalendar()); + QDateTimeParser dt(QMetaType::QTime, QDateTimeParser::FromString, QCalendar()); // dt.setDefaultLocale(QLocale::c()); ### Qt 6 if (dt.parseFormat(format)) dt.fromString(string, nullptr, &time); @@ -5482,7 +5482,7 @@ QDateTime QDateTime::fromString(const QString &string, const QString &format, QC QTime time; QDate date; - QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString, cal); + QDateTimeParser dt(QMetaType::QDateTime, QDateTimeParser::FromString, cal); // dt.setDefaultLocale(QLocale::c()); ### Qt 6 if (dt.parseFormat(format) && dt.fromString(string, &date, &time)) return QDateTime(date, time); diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 31d8e6cc20..70460ae632 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -425,7 +425,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) switch (sect) { case 'H': case 'h': - if (parserType != QVariant::Date) { + if (parserType != QMetaType::QDate) { const Section hour = (sect == 'h') ? Hour12Section : Hour24Section; const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 }; newSectionNodes.append(sn); @@ -436,7 +436,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) } break; case 'm': - if (parserType != QVariant::Date) { + if (parserType != QMetaType::QDate) { const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 }; newSectionNodes.append(sn); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); @@ -446,7 +446,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) } break; case 's': - if (parserType != QVariant::Date) { + if (parserType != QMetaType::QDate) { const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 }; newSectionNodes.append(sn); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); @@ -457,7 +457,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) break; case 'z': - if (parserType != QVariant::Date) { + if (parserType != QMetaType::QDate) { const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 }; newSectionNodes.append(sn); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); @@ -468,7 +468,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) break; case 'A': case 'a': - if (parserType != QVariant::Date) { + if (parserType != QMetaType::QDate) { const bool cap = (sect == 'A'); const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 }; newSectionNodes.append(sn); @@ -482,7 +482,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) } break; case 'y': - if (parserType != QVariant::Time) { + if (parserType != QMetaType::QTime) { const int repeat = countRepeat(newFormat, i, 4); if (repeat >= 2) { const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits, @@ -496,7 +496,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) } break; case 'M': - if (parserType != QVariant::Time) { + if (parserType != QMetaType::QTime) { const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 }; newSectionNodes.append(sn); newSeparators.append(unquote(newFormat.midRef(index, i - index))); @@ -506,7 +506,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) } break; case 'd': - if (parserType != QVariant::Time) { + if (parserType != QMetaType::QTime) { const int repeat = countRepeat(newFormat, i, 4); const Section sectionType = (repeat == 4 ? DayOfWeekSectionLong : (repeat == 3 ? DayOfWeekSectionShort : DaySection)); @@ -519,7 +519,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) } break; case 't': - if (parserType != QVariant::Time) { + if (parserType != QMetaType::QTime) { const SectionNode sn = { TimeZoneSection, i - add, countRepeat(newFormat, i, 4), 0 }; newSectionNodes.append(sn); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); @@ -1252,7 +1252,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, return StateNode(); } - if (parserType != QVariant::Time) { + if (parserType != QMetaType::QTime) { if (year % 100 != year2digits && (isSet & YearSection2Digits)) { if (!(isSet & YearSection)) { year = (year / 100) * 100; @@ -1322,7 +1322,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, } } - if (parserType != QVariant::Date) { + if (parserType != QMetaType::QDate) { if (isSet & Hour12Section) { const bool hasHour = isSet & Hour24Section; if (ampm == -1) { @@ -1360,7 +1360,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, // If hour wasn't specified, check the default we're using exists on the // given date (which might be a spring-forward, skipping an hour). - if (parserType == QVariant::DateTime && !(isSet & HourSectionMask) && !when.isValid()) { + if (parserType == QMetaType::QDateTime && !(isSet & HourSectionMask) && !when.isValid()) { qint64 msecs = when.toMSecsSinceEpoch(); // Fortunately, that gets a useful answer, even though when is invalid ... const QDateTime replace = diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h index ec4e4e4df2..5c612ef6a4 100644 --- a/src/corelib/time/qdatetimeparser_p.h +++ b/src/corelib/time/qdatetimeparser_p.h @@ -83,7 +83,7 @@ public: FromString, DateTimeEdit }; - QDateTimeParser(QVariant::Type t, Context ctx, const QCalendar &cal = QCalendar()) + QDateTimeParser(QMetaType::Type t, Context ctx, const QCalendar &cal = QCalendar()) : currentSectionIndex(-1), cachedDay(-1), parserType(t), fixday(false), spec(Qt::LocalTime), context(ctx), calendar(cal) { @@ -295,7 +295,7 @@ protected: // for the benefit of QDateTimeEditPrivate QStringList separators; QString displayFormat; QLocale defaultLocale; - QVariant::Type parserType; + QMetaType::Type parserType; bool fixday; Qt::TimeSpec spec; // spec if used by QDateTimeEdit Context context; -- 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/doc/snippets/code/doc_src_properties.cpp | 1 + src/corelib/doc/src/objectmodel/properties.qdoc | 6 ++++++ src/corelib/kernel/qmetaobject.cpp | 15 +++++++++++++++ src/corelib/kernel/qmetaobject.h | 1 + src/corelib/kernel/qmetaobject_p.h | 3 ++- 5 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/doc/snippets/code/doc_src_properties.cpp b/src/corelib/doc/snippets/code/doc_src_properties.cpp index b72c9d13e1..a67945bbcf 100644 --- a/src/corelib/doc/snippets/code/doc_src_properties.cpp +++ b/src/corelib/doc/snippets/code/doc_src_properties.cpp @@ -61,6 +61,7 @@ Q_PROPERTY(type name [USER bool] [CONSTANT] [FINAL]) + [REQUIRED] //! [0] diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc index 9ef08cce07..680e5598f0 100644 --- a/src/corelib/doc/src/objectmodel/properties.qdoc +++ b/src/corelib/doc/src/objectmodel/properties.qdoc @@ -144,6 +144,12 @@ optimizations in some cases, but is not enforced by moc. Care must be taken never to override a \c FINAL property. + \li The presence of the \c REQUIRED attribute indicates that the property + should be set by a user of the class. This is not enforced by moc, and is + mostly useful for classes exposed to QML. In QML, classes with REQUIRED + properties cannot be instantiated unless all REQUIRED properties have + been set. + \endlist The \c READ, \c WRITE, and \c RESET functions can be inherited. 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 diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index fcd92afd89..beb85becae 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -266,6 +266,7 @@ public: bool isUser(const QObject *obj = nullptr) const; bool isConstant() const; bool isFinal() const; + bool isRequired() const; bool isFlagType() const; bool isEnumType() const; diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h index 56e3d6cb44..277109dac4 100644 --- a/src/corelib/kernel/qmetaobject_p.h +++ b/src/corelib/kernel/qmetaobject_p.h @@ -85,7 +85,8 @@ enum PropertyFlags { User = 0x00100000, ResolveUser = 0x00200000, Notify = 0x00400000, - Revisioned = 0x00800000 + Revisioned = 0x00800000, + Required = 0x01000000, }; enum MethodFlags { -- cgit v1.2.3 From 4d8a515a230ca9864a94830fd376a1d3ecbe6886 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 15 Jan 2020 20:53:21 +0100 Subject: QXmlStreamReader: early return in case of malformed attributes There's no point at keep raising errors after encountering the first malformed attribute. Change-Id: Idb37e577ea96c3bd850b3caf008fe3ecd57dd32e Reviewed-by: Thiago Macieira --- src/corelib/serialization/qxmlstream.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index 500e0aa6be..dfa36ea642 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -50,6 +50,7 @@ #endif #include #include +#include #ifndef QT_BOOTSTRAPPED #include #else @@ -1582,6 +1583,7 @@ QStringRef QXmlStreamReaderPrivate::namespaceForPrefix(const QStringRef &prefix) */ void QXmlStreamReaderPrivate::resolveTag() { + const auto attributeStackCleaner = qScopeGuard([this](){ attributeStack.clear(); }); int n = attributeStack.size(); if (namespaceProcessing) { @@ -1649,7 +1651,10 @@ void QXmlStreamReaderPrivate::resolveTag() if (attributes[j].name() == attribute.name() && attributes[j].namespaceUri() == attribute.namespaceUri() && (namespaceProcessing || attributes[j].qualifiedName() == attribute.qualifiedName())) + { raiseWellFormedError(QXmlStream::tr("Attribute '%1' redefined.").arg(attribute.qualifiedName())); + return; + } } } @@ -1680,8 +1685,6 @@ void QXmlStreamReaderPrivate::resolveTag() attribute.m_isDefault = true; attributes.append(attribute); } - - attributeStack.clear(); } void QXmlStreamReaderPrivate::resolvePublicNamespaces() -- cgit v1.2.3 From e83c4e813840b8632ec44f00ee3daf2ba1b18133 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 21 Jan 2020 14:43:01 +0100 Subject: QXmlStreamReader: fix memory leak On some inputs a QXmlStreamReaderPrivate may allocate another QXmlStreamReaderPrivate as its entityResolver. Which, recursively, may allocate yet another one. This "chain" of QXmlStreamReaderPrivate objects was managed using raw pointers, and a leak was possible by resetting one of these pointers to nullptr without freeing the corresponding object. Change-Id: I2c6e1f023a2ed68b2b1857db25c53cce7f6bd3e7 Reviewed-by: Sona Kurazyan --- src/corelib/serialization/qxmlstream.cpp | 7 ++++--- src/corelib/serialization/qxmlstream_p.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index dfa36ea642..7ff87885a5 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -69,6 +69,8 @@ public: \ { return QString::fromLatin1(sourceText); } \ private: #endif +#include + QT_BEGIN_NAMESPACE #include "qxmlstream_p.h" @@ -848,7 +850,7 @@ void QXmlStreamReaderPrivate::init() #endif attributeStack.clear(); attributeStack.reserve(16); - entityParser = nullptr; + entityParser.reset(); hasCheckedStartDocument = false; normalizeLiterals = false; hasSeenTag = false; @@ -881,7 +883,7 @@ void QXmlStreamReaderPrivate::parseEntity(const QString &value) if (!entityParser) - entityParser = new QXmlStreamReaderPrivate(q); + entityParser = qt_make_unique(q); else entityParser->init(); entityParser->inParseEntity = true; @@ -911,7 +913,6 @@ QXmlStreamReaderPrivate::~QXmlStreamReaderPrivate() #endif free(sym_stack); free(state_stack); - delete entityParser; } diff --git a/src/corelib/serialization/qxmlstream_p.h b/src/corelib/serialization/qxmlstream_p.h index cde66a48a3..9c94e6d434 100644 --- a/src/corelib/serialization/qxmlstream_p.h +++ b/src/corelib/serialization/qxmlstream_p.h @@ -981,7 +981,7 @@ public: QString resolveUndeclaredEntity(const QString &name); void parseEntity(const QString &value); - QXmlStreamReaderPrivate *entityParser; + std::unique_ptr entityParser; bool scanAfterLangleBang(); bool scanPublicOrSystem(); -- cgit v1.2.3 From ca85e1246eacfe7ba570882a674e313be3b808f8 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 20 Jan 2020 13:44:30 +0100 Subject: updateSystemPrivate(): fix handling of empty string as non-null QVariant QSystemLocale::query() can return an empty string for PositiveSign on Windows, apparently. In any case, we shouldn't be taking .at(0) of a QString without checking it's non-empty. Fixes: QTBUG-81530 Change-Id: I4d496a2650362f225d02998bd7b8be9fd783edb4 Reviewed-by: Friedemann Kleint --- src/corelib/text/qlocale.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index d8c4b41624..26db674a99 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -734,23 +734,23 @@ static void updateSystemPrivate() globalLocaleData.m_script_id = res.toInt(); res = sys_locale->query(QSystemLocale::DecimalPoint, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_decimal = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::GroupSeparator, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_group = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::ZeroDigit, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_zero = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::NegativeSign, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_minus = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::PositiveSign, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_plus = res.toString().at(0).unicode(); } #endif // !QT_NO_SYSTEMLOCALE -- cgit v1.2.3 From 39396409656b12940ffe9b715f13e23ac4290eca Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Jan 2020 15:48:15 +0100 Subject: Fix some qdoc-warnings src/corelib/tools/qmap.cpp:1199: (qdoc) warning: Can't link to 'QMultiMap::unite()' src/gui/kernel/qevent.cpp:949: (qdoc) warning: Unknown command '\see' src/gui/painting/qpaintengine_raster.cpp:344: (qdoc) warning: clang found diagnostics parsing \fn Type QRasterPaintEngine::type() const error: unknown type name 'Type' src/gui/doc/src/qtgui.qdoc:45: (qdoc) warning: Can't link to 'Build with CMake' examples/widgets/doc/src/gallery.qdoc:28: (qdoc) warning: Cannot find file 'widgets/gallery/gallery.pro' or 'widgets/gallery/gallery.pyproject' src/widgets/kernel/qwidget.cpp:5950: (qdoc) warning: Can't link to 'setFilePath' src/widgets/kernel/qshortcut.cpp:542: (qdoc) warning: No such parameter 'context' in QShortcut::QShortcut() Change-Id: I2395af854efebef719d4762da466f69f7c5aab9e Reviewed-by: Paul Wicking --- src/corelib/tools/qmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index d747a8cda4..a51e59b2b8 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -1203,7 +1203,7 @@ void QMapDataBase::freeData(QMapDataBase *d) key is common to both maps, the resulting map will contain the key multiple times. - \sa QMultiMap::unite() + \sa QMap::unite() */ /*! \typedef QMap::Iterator -- cgit v1.2.3 From f3d3c095a6bda505384ef56acab57b985d94fac5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 6 Dec 2019 16:51:41 +0100 Subject: Register QColorSpace as a QtGui metatype Helps pass it through QVariant, and needed for QML support. Change-Id: Id161ff9b8f81ad55a7ee7a7c4c614bdf74bca4a1 Reviewed-by: Andy Nichols --- src/corelib/kernel/qmetatype.cpp | 1 + src/corelib/kernel/qmetatype.h | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index af9a2e0dd2..46900be1a4 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -252,6 +252,7 @@ struct DefinedTypesFilter { \value QPolygon QPolygon \value QPolygonF QPolygonF \value QColor QColor + \value QColorSpace QColorSpace \value QSizeF QSizeF \value QRectF QRectF \value QLine QLine diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 825f767425..4f70eb4c6d 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -175,6 +175,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); F(QVector4D, 84, QVector4D) \ F(QQuaternion, 85, QQuaternion) \ F(QPolygonF, 86, QPolygonF) \ + F(QColorSpace, 87, QColorSpace) \ #define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)\ @@ -437,7 +438,7 @@ public: FirstCoreType = Bool, LastCoreType = QCborMap, FirstGuiType = QFont, - LastGuiType = QPolygonF, + LastGuiType = QColorSpace, FirstWidgetsType = QSizePolicy, LastWidgetsType = QSizePolicy, HighestInternalId = LastWidgetsType, @@ -472,12 +473,12 @@ public: 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, + QVector3D = 83, QVector4D = 84, QQuaternion = 85, QPolygonF = 86, QColorSpace = 87, // Widget types QSizePolicy = 121, LastCoreType = QCborMap, - LastGuiType = QPolygonF, + LastGuiType = QColorSpace, User = 1024 }; #endif -- cgit v1.2.3 From e9a797799ee7e81d1cd113ba56f62705ae150e5c Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 2 Dec 2019 18:03:47 +0100 Subject: CMake: Add Qt6 forward compatible CMake API and targets Create Qt:: versionless targets for libraries and tools. So Qt::Core will link to Qt5::Core. Add additional feature properties to targets, with the same name they have in Qt6: QT_ENABLED_PUBLIC_FEATURES, QT_DISABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES, QT_DISABLED_PRIVATE_FEATURES, to be forward-compatible with Qt6. Prefix properties with INTERFACE_ for interface libraries. Create functions with no major version in their prefix, so qt_foo instead of qt5_foo. The non-versioned functions will call the versioned functions, depending on the value of QT_DEFAULT_MAJOR_VERSION, which can be set by an application developer before finding the Qt package. Set QT_DEFAULT_MAJOR_VERSION to 5 if the value has not been defined in the current scope. Application developers can set QT_NO_CREATE_VERSIONLESS_FUNCTIONS to TRUE before calling find_package(Qt5) to suppress creation of the non-versioned functions. Application developers can set QT_NO_CREATE_VERSIONLESS_TARGETS to TRUE before calling find_package(Qt5) to suppress creation of the non-versioned targets. Setting these can be useful when both find_package(Qt5) and find_package(Qt6) are in the same project. If none of these are set by the user, then the first find_package(Qt5) will create versionless targets with the major version being "5", which means the second find_package(Qt6) will not create versionless targets. Handle versionless plugin names in qt_import_plugins, so both Qt::QCocoaIntegrationPlugin and Qt5/6::QCocoaIntegrationPlugin are recognized by the function. Allow specifying multiple types in EXCLUDE_BY_TYPE in qt_import_plugins, to be consitent with the Qt 6 version. Make sure to set the QT_PLUGIN_CLASS_NAME property to compatible with Qt 6. Task-number: QTBUG-74137 Task-number: QTBUG-80477 Change-Id: Ib89d090ea6f7794d7debd64f03f29da963a17ca7 Reviewed-by: Joerg Bornemann --- src/corelib/Qt5CoreConfigExtras.cmake.in | 24 ++++++++++++ src/corelib/Qt5CoreMacros.cmake | 66 +++++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 9b672327ef..4c1c3a612b 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -1,3 +1,6 @@ +if(NOT DEFINED QT_DEFAULT_MAJOR_VERSION) + set(QT_DEFAULT_MAJOR_VERSION 5) +endif() if (NOT TARGET Qt5::qmake) add_executable(Qt5::qmake IMPORTED) @@ -177,3 +180,24 @@ if (ANDROID_PLATFORM) endif() _qt5_Core_check_file_exists(${_Qt5CTestMacros}) + +# Create versionless tool targets. +foreach(__qt_tool qmake moc rcc) + if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::${__qt_tool} + AND TARGET Qt5::${__qt_tool}) + add_executable(Qt::${__qt_tool} IMPORTED) + get_target_property(__qt_imported_location Qt5::${__qt_tool} IMPORTED_LOCATION) + set_target_properties(Qt::${__qt_tool} + PROPERTIES IMPORTED_LOCATION \"${__qt_imported_location}\") + endif() +endforeach() + +!!IF !isEmpty(CMAKE_WINDOWS_BUILD) +# Add a versionless target for WinMain. +if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::WinMain) + add_library(Qt::WinMain INTERFACE IMPORTED) + set_target_properties(Qt::WinMain PROPERTIES + INTERFACE_LINK_LIBRARIES \"Qt5::WinMain\" + ) +endif() +!!ENDIF diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index e298cf7de7..6c21470164 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -157,6 +157,16 @@ function(qt5_generate_moc infile outfile ) qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "") endfunction() +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_generate_moc) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_generate_moc(${ARGV}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_generate_moc(${ARGV}) + endif() + endfunction() +endif() + # qt5_wrap_cpp(outfiles inputfile ... ) @@ -184,6 +194,17 @@ function(qt5_wrap_cpp outfiles ) set(${outfiles} ${${outfiles}} PARENT_SCOPE) endfunction() +# This will override the CMake upstream command, because that one is for Qt 3. +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_wrap_cpp outfiles) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_wrap_cpp("${outfiles}" ${ARGN}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_wrap_cpp("${outfiles}" ${ARGN}) + endif() + set("${outfiles}" "${${outfiles}}" PARENT_SCOPE) + endfunction() +endif() # _qt5_parse_qrc_file(infile _out_depends _rc_depends) @@ -255,6 +276,16 @@ function(qt5_add_binary_resources target ) add_custom_target(${target} ALL DEPENDS ${rcc_destination}) endfunction() +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_add_binary_resources) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_add_binary_resources(${ARGV}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_add_binary_resources(${ARGV}) + endif() + endfunction() +endif() + # qt5_add_resources(outfiles inputfile ... ) @@ -293,6 +324,18 @@ function(qt5_add_resources outfiles ) set(${outfiles} ${${outfiles}} PARENT_SCOPE) endfunction() +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_add_resources outfiles) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_add_resources("${outfiles}" ${ARGN}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_add_resources("${outfiles}" ${ARGN}) + endif() + set("${outfiles}" "${${outfiles}}" PARENT_SCOPE) + endfunction() +endif() + + # qt5_add_big_resources(outfiles inputfile ... ) function(qt5_add_big_resources outfiles ) @@ -341,6 +384,18 @@ function(qt5_add_big_resources outfiles ) set(${outfiles} ${${outfiles}} PARENT_SCOPE) endfunction() +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_add_big_resources outfiles) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_add_big_resources(${outfiles} ${ARGN}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_add_big_resources(${outfiles} ${ARGN}) + endif() + set("${outfiles}" "${${outfiles}}" PARENT_SCOPE) + endfunction() +endif() + + set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..") macro(qt5_use_modules _target _link_type) @@ -413,10 +468,19 @@ function(qt5_import_plugins TARGET_NAME) elseif(_doing STREQUAL "EXCLUDE_BY_TYPE") string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}") set_property(TARGET ${TARGET_NAME} PROPERTY "QT_PLUGINS_${_plugin_type}" -) - set(_doing "") else() message(FATAL_ERROR "Unexpected extra argument: \"${_arg}\"") endif() endif() endforeach() endfunction() + +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_import_plugins) + if(QT_DEFAULT_MAJOR_VERSION EQUAL 5) + qt5_import_plugins(${ARGV}) + elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6) + qt6_import_plugins(${ARGV}) + endif() + endfunction() +endif() -- cgit v1.2.3 From 114ff44f3c42e2575c60e6b5c8459acfea2dc60d Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Mon, 2 Sep 2019 07:32:49 +0800 Subject: QLabel: Allow pixmap() and picture() to return by-value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous versions of these functions that returned by-pointer are held over from Qt 1 times. They are inconsistent with the rest of the Qt API. [ChangeLog][QtWidgets][QLabel] QLabel::pixmap() and QLabel::picture() can now return by-value instead of by-pointer. Task-number: QTBUG-48701 Change-Id: I23ce319a7b1f757e1f4dec697551bb472e92fabf Reviewed-by: André Hartmann --- src/corelib/global/qnamespace.h | 3 +++ src/corelib/global/qnamespace.qdoc | 10 ++++++++++ 2 files changed, 13 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 5b63daec69..8f40393a7e 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1767,6 +1767,9 @@ public: PassThrough }; + // QTBUG-48701 + enum ReturnByValue_t { ReturnByValue }; // ### Qt 7: Remove me + #ifndef Q_QDOC // NOTE: Generally, do not add QT_Q_ENUM if a corresponding Q_Q_FLAG exists. QT_Q_ENUM(ScrollBarPolicy) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 6149281904..169c296bcd 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -3319,3 +3319,13 @@ \value RoundPreferFloor Round up for .75 and above. \value PassThrough Don't round. */ + +/*! + \enum Qt::ReturnByValue_t + \since 5.15 + + This is a dummy type, designed to help users transition from certain deprecated APIs to their replacement APIs. + + \sa QLabel::picture() + \sa QLabel::pixmap() +*/ -- cgit v1.2.3 From f21a6d409ea0504c64cd72861fc16b6f3e080086 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 18 Dec 2019 15:43:24 +0100 Subject: QStringList: use local storage in removeDuplicates() If available, use a C++17 std::pmr::unordered_set with a monotonic buffer resource and a 256-byte stack buffer to avoid the per-element allocations of QSet. Results on my machine: RESULT : tst_QStringList::removeDuplicates():"empty": - 0.00014 msecs per iteration (total: 74, iterations: 524288) + 0.000031 msecs per iteration (total: 66, iterations: 2097152) RESULT : tst_QStringList::removeDuplicates():"short-dup-0.00": - 0.00043 msecs per iteration (total: 57, iterations: 131072) + 0.00013 msecs per iteration (total: 69, iterations: 524288) RESULT : tst_QStringList::removeDuplicates():"short-dup-0.50": - 0.00049 msecs per iteration (total: 65, iterations: 131072) + 0.00032 msecs per iteration (total: 85, iterations: 262144) RESULT : tst_QStringList::removeDuplicates():"short-dup-0.66": - 0.00057 msecs per iteration (total: 75, iterations: 131072) + 0.00039 msecs per iteration (total: 52, iterations: 131072) RESULT : tst_QStringList::removeDuplicates():"short-dup-0.75": - 0.00064 msecs per iteration (total: 85, iterations: 131072) + 0.00048 msecs per iteration (total: 63, iterations: 131072) RESULT : tst_QStringList::removeDuplicates():"long-dup-0.00": - 0.083 msecs per iteration (total: 85, iterations: 1024) + 0.039 msecs per iteration (total: 80, iterations: 2048) RESULT : tst_QStringList::removeDuplicates():"long-dup-0.50": - 0.11 msecs per iteration (total: 58, iterations: 512) + 0.078 msecs per iteration (total: 80, iterations: 1024) RESULT : tst_QStringList::removeDuplicates():"long-dup-0.66": - 0.13 msecs per iteration (total: 70, iterations: 512) + 0.10 msecs per iteration (total: 53, iterations: 512) RESULT : tst_QStringList::removeDuplicates():"long-dup-0.75": - 0.16 msecs per iteration (total: 86, iterations: 512) + 0.13 msecs per iteration (total: 69, iterations: 512) When interpreting the data, take into account that each iteration contains _also_ a deep copy of the QStringList d/t the detach from 'input'. The pattern is used elsewhere in Qt, so I've put the class that implements the seen set into a private header file and used in some other places I found. Change-Id: I1f71a82008a16d5a3818f91f290ade21d837805e Reviewed-by: Giuseppe D'Angelo --- src/corelib/text/qstringlist.cpp | 10 ++-- src/corelib/tools/qduplicatetracker_p.h | 94 +++++++++++++++++++++++++++++++++ src/corelib/tools/tools.pri | 1 + 3 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 src/corelib/tools/qduplicatetracker_p.h (limited to 'src/corelib') diff --git a/src/corelib/text/qstringlist.cpp b/src/corelib/text/qstringlist.cpp index 4bbe424ed2..4b9dcee169 100644 --- a/src/corelib/text/qstringlist.cpp +++ b/src/corelib/text/qstringlist.cpp @@ -43,9 +43,9 @@ #if QT_CONFIG(regularexpression) # include #endif +#include #include - QT_BEGIN_NAMESPACE /*! \typedef QStringListIterator @@ -885,15 +885,13 @@ int QtPrivate::QStringList_removeDuplicates(QStringList *that) { int n = that->size(); int j = 0; - QSet seen; + + QDuplicateTracker seen; seen.reserve(n); - int setSize = 0; for (int i = 0; i < n; ++i) { const QString &s = that->at(i); - seen.insert(s); - if (setSize == seen.size()) // unchanged size => was already seen + if (seen.hasSeen(s)) continue; - ++setSize; if (j != i) that->swapItemsAt(i, j); ++j; diff --git a/src/corelib/tools/qduplicatetracker_p.h b/src/corelib/tools/qduplicatetracker_p.h new file mode 100644 index 0000000000..99068c01a3 --- /dev/null +++ b/src/corelib/tools/qduplicatetracker_p.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QDUPLICATETRACKER_P_H +#define QDUPLICATETRACKER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#if QT_HAS_INCLUDE() && __cplusplus > 201402L +# include +# include +#else +# include +#endif + +QT_BEGIN_NAMESPACE + +template +class QDuplicateTracker { +#ifdef __cpp_lib_memory_resource + char buffer[Prealloc * sizeof(T)]; + std::pmr::monotonic_buffer_resource res{buffer, sizeof buffer}; + std::pmr::unordered_set set{&res}; +#else + QSet set; + int setSize = 0; +#endif + Q_DISABLE_COPY_MOVE(QDuplicateTracker); +public: + QDuplicateTracker() = default; + void reserve(int n) { set.reserve(n); } + Q_REQUIRED_RESULT bool hasSeen(const T &s) + { + bool inserted; +#ifdef __cpp_lib_memory_resource + inserted = set.insert(s).second; +#else + set.insert(s); + const int n = set.size(); + inserted = qExchange(setSize, n) != n; +#endif + return !inserted; + } +}; + +QT_END_NAMESPACE + +#endif /* QDUPLICATETRACKER_P_H */ diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 40c84157cd..e078ab4409 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -12,6 +12,7 @@ HEADERS += \ tools/qcontainerfwd.h \ tools/qcontainertools_impl.h \ tools/qcryptographichash.h \ + tools/qduplicatetracker_p.h \ tools/qfreelist_p.h \ tools/qhash.h \ tools/qhashfunctions.h \ -- cgit v1.2.3 From ae9056587a52d51c7b41b41f631c6cab8097a7c7 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 25 Jan 2020 21:19:47 +0100 Subject: Doc/QtCore: use new signal/slot signature in snippets Use the new signal/slot syntax in the snippets where possible. Also change some 0 to nullptr. Change-Id: Ie3da2721d3cec33704f73f4d39c06a767717b095 Reviewed-by: Sze Howe Koh --- .../code/src_corelib_kernel_qcoreapplication.cpp | 10 +++--- .../src_corelib_statemachine_qstatemachine.cpp | 2 +- .../code/src_corelib_thread_qfuturewatcher.cpp | 2 +- .../snippets/code/src_corelib_tools_qtimeline.cpp | 4 +-- .../doc/snippets/qsignalmapper/buttonwidget.cpp | 14 ++++----- .../doc/snippets/qsignalmapper/buttonwidget.h | 4 +-- .../doc/snippets/resource-system/mainwindow.cpp | 36 +++++++++++----------- src/corelib/doc/snippets/statemachine/main.cpp | 13 ++++---- src/corelib/doc/snippets/statemachine/main2.cpp | 15 ++++----- src/corelib/doc/snippets/statemachine/main3.cpp | 2 +- src/corelib/doc/snippets/statemachine/main5.cpp | 14 ++++----- src/corelib/doc/snippets/timers/analogclock.cpp | 2 +- src/corelib/doc/snippets/timers/timers.cpp | 6 ++-- src/corelib/doc/src/animation.qdoc | 4 +-- src/corelib/doc/src/statemachine.qdoc | 4 +-- 15 files changed, 67 insertions(+), 65 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp index aae2456bf1..36b47e6f6e 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp @@ -56,7 +56,7 @@ QApplication::sendEvent(mainWindow, &event); //! [1] QPushButton *quitButton = new QPushButton("Quit"); -connect(quitButton, SIGNAL(clicked()), &app, SLOT(quit()), Qt::QueuedConnection); +connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection); //! [1] @@ -79,12 +79,12 @@ Q_COREAPP_STARTUP_FUNCTION(preRoutineMyDebugTool) //! [4] -static int *global_ptr = 0; +static int *global_ptr = nullptr; static void cleanup_ptr() { delete [] global_ptr; - global_ptr = 0; + global_ptr = nullptr; } void init_ptr() @@ -125,9 +125,9 @@ private: //! [6] static inline QString tr(const char *sourceText, - const char *comment = 0); + const char *comment = nullptr); static inline QString trUtf8(const char *sourceText, - const char *comment = 0); + const char *comment = nullptr); //! [6] diff --git a/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp index a606da1a0c..c756116de4 100644 --- a/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp @@ -56,7 +56,7 @@ QState *s1 = new QState(); s1->assignProperty(&button, "text", "Click me"); QFinalState *s2 = new QFinalState(); -s1->addTransition(&button, SIGNAL(clicked()), s2); +s1->addTransition(&button, &QPushButton::clicked, s2); machine.addState(s1); machine.addState(s2); diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp index 043974b25b..336c1e9c79 100644 --- a/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp @@ -52,7 +52,7 @@ // Instantiate the objects and connect to the finished signal. MyClass myObject; QFutureWatcher watcher; -connect(&watcher, SIGNAL(finished()), &myObject, SLOT(handleFinished())); +connect(&watcher, QFutureWatcher::finished, &myObject, &MyClass::handleFinished); // Start the computation. QFuture future = QtConcurrent::run(...); diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp index 004a810fce..80859d5ba5 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp @@ -56,10 +56,10 @@ progressBar->setRange(0, 100); // Construct a 1-second timeline with a frame range of 0 - 100 QTimeLine *timeLine = new QTimeLine(1000, this); timeLine->setFrameRange(0, 100); -connect(timeLine, SIGNAL(frameChanged(int)), progressBar, SLOT(setValue(int))); +connect(timeLine, &QTimeLine::frameChanged, progressBar, &QProgressBar::setValue); // Clicking the push button will start the progress bar animation pushButton = new QPushButton(tr("Start animation"), this); -connect(pushButton, SIGNAL(clicked()), timeLine, SLOT(start())); +connect(pushButton, &QPushButton::clicked, timeLine, &QTimeLine::start); ... //! [0] diff --git a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp index e91c41b305..84a156bb6d 100644 --- a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp +++ b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp @@ -48,11 +48,10 @@ ** ****************************************************************************/ -#include -#include - #include "buttonwidget.h" +#include + //! [0] ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent) : QWidget(parent) @@ -62,15 +61,16 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent) QGridLayout *gridLayout = new QGridLayout; for (int i = 0; i < texts.size(); ++i) { QPushButton *button = new QPushButton(texts[i]); - connect(button, SIGNAL(clicked()), signalMapper, SLOT(map())); + connect(button, &QPushButton::clicked, + signalMapper, &QSignalMapper::map); //! [0] //! [1] signalMapper->setMapping(button, texts[i]); gridLayout->addWidget(button, i / 3, i % 3); } - connect(signalMapper, SIGNAL(mapped(QString)), + connect(signalMapper, QOverload::of(&QSignalMapper::mapped), //! [1] //! [2] - this, SIGNAL(clicked(QString))); + this, &ButtonWidget::clicked); setLayout(gridLayout); } @@ -84,7 +84,7 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent) for (int i = 0; i < texts.size(); ++i) { QString text = texts[i]; QPushButton *button = new QPushButton(text); - connect(button, &QPushButton::clicked, [=] { clicked(text); }); + connect(button, &QPushButton::clicked, [this, text] { clicked(text); }); gridLayout->addWidget(button, i / 3, i % 3); } setLayout(gridLayout); diff --git a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h index f55683c2d5..b9d59f8dd8 100644 --- a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h +++ b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h @@ -51,7 +51,7 @@ #ifndef BUTTONWIDGET_H #define BUTTONWIDGET_H -#include +#include class QSignalMapper; class QString; @@ -63,7 +63,7 @@ class ButtonWidget : public QWidget Q_OBJECT public: - ButtonWidget(const QStringList &texts, QWidget *parent = 0); + ButtonWidget(const QStringList &texts, QWidget *parent = nullptr); signals: void clicked(const QString &text); diff --git a/src/corelib/doc/snippets/resource-system/mainwindow.cpp b/src/corelib/doc/snippets/resource-system/mainwindow.cpp index 86e93aaa62..6dc525304c 100644 --- a/src/corelib/doc/snippets/resource-system/mainwindow.cpp +++ b/src/corelib/doc/snippets/resource-system/mainwindow.cpp @@ -68,10 +68,10 @@ MainWindow::MainWindow() readSettings(); - connect(textEdit->document(), SIGNAL(contentsChanged()), - this, SLOT(documentWasModified())); + connect(textEdit->document(), &QTextEdit::contentsChanged, + this, &QAction::documentWasModified); - setCurrentFile(""); + setCurrentFile(QString()); setUnifiedTitleAndToolBarOnMac(true); } //! [2] @@ -95,7 +95,7 @@ void MainWindow::newFile() { if (maybeSave()) { textEdit->clear(); - setCurrentFile(""); + setCurrentFile(QString()); } } //! [6] @@ -162,31 +162,31 @@ void MainWindow::createActions() newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this); newAct->setShortcuts(QKeySequence::New); newAct->setStatusTip(tr("Create a new file")); - connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); + connect(newAct, &QAction::triggered, this, &MainWindow::newFile); //! [19] openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); openAct->setShortcuts(QKeySequence::Open); openAct->setStatusTip(tr("Open an existing file")); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); + connect(openAct, &QAction::triggered, this, &MainWindow::open); //! [18] //! [19] saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); saveAct->setShortcuts(QKeySequence::Save); saveAct->setStatusTip(tr("Save the document to disk")); - connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); + connect(saveAct, &QAction::triggered, this, &MainWindow::save); saveAsAct = new QAction(tr("Save &As..."), this); saveAsAct->setShortcuts(QKeySequence::SaveAs); saveAsAct->setStatusTip(tr("Save the document under a new name")); - connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); + connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs); //! [20] exitAct = new QAction(tr("E&xit"), this); exitAct->setShortcuts(QKeySequence::Quit); //! [20] exitAct->setStatusTip(tr("Exit the application")); - connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); + connect(exitAct, &QAction::triggered, this, &MainWindow::close); //! [21] cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this); @@ -194,38 +194,38 @@ void MainWindow::createActions() cutAct->setShortcuts(QKeySequence::Cut); cutAct->setStatusTip(tr("Cut the current selection's contents to the " "clipboard")); - connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut())); + connect(cutAct, &QAction::triggered, textEdit, &QTextEdit::cut); copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this); copyAct->setShortcuts(QKeySequence::Copy); copyAct->setStatusTip(tr("Copy the current selection's contents to the " "clipboard")); - connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy())); + connect(copyAct, &QAction::triggered, textEdit, &QTextEdit::copy); pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this); pasteAct->setShortcuts(QKeySequence::Paste); pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current " "selection")); - connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste())); + connect(pasteAct, &QAction::triggered, textEdit, &QTextEdit::paste); aboutAct = new QAction(tr("&About"), this); aboutAct->setStatusTip(tr("Show the application's About box")); - connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); + connect(aboutAct, &QAction::triggered, this, &MainWindow::about); //! [22] aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt); //! [22] //! [23] cutAct->setEnabled(false); //! [23] //! [24] copyAct->setEnabled(false); - connect(textEdit, SIGNAL(copyAvailable(bool)), - cutAct, SLOT(setEnabled(bool))); - connect(textEdit, SIGNAL(copyAvailable(bool)), - copyAct, SLOT(setEnabled(bool))); + connect(textEdit, &QTextEdit::copyAvailable, + cutAct, &QAction::setEnabled); + connect(textEdit, &QTextEdit::copyAvailable, + copyAct, &QAction::setEnabled); } //! [24] diff --git a/src/corelib/doc/snippets/statemachine/main.cpp b/src/corelib/doc/snippets/statemachine/main.cpp index 8cd8b69e12..c399f4f199 100644 --- a/src/corelib/doc/snippets/statemachine/main.cpp +++ b/src/corelib/doc/snippets/statemachine/main.cpp @@ -48,13 +48,14 @@ ** ****************************************************************************/ -#include +#include int main(int argv, char **args) { QApplication app(argv, args); QLabel *label = new QLabel; + QPushButton *button = new QPushButton; //![0] QStateMachine machine; @@ -70,14 +71,14 @@ int main(int argv, char **args) //![4] //![5] - QObject::connect(s3, SIGNAL(entered()), button, SLOT(showMaximized())); - QObject::connect(s3, SIGNAL(exited()), button, SLOT(showMinimized())); + QObject::connect(s3, &QState::entered, button, &QPushButton:showMaximized); + QObject::connect(s3, &QState::exited, button, &QPushButton::showMinimized); //![5] //![1] - s1->addTransition(button, SIGNAL(clicked()), s2); - s2->addTransition(button, SIGNAL(clicked()), s3); - s3->addTransition(button, SIGNAL(clicked()), s1); + s1->addTransition(button, &QPushButton::clicked, s2); + s2->addTransition(button, &QPushButton::clicked, s3); + s3->addTransition(button, &QPushButton::clicked, s1); //![1] //![2] diff --git a/src/corelib/doc/snippets/statemachine/main2.cpp b/src/corelib/doc/snippets/statemachine/main2.cpp index 96eb912b14..dedd2d29bf 100644 --- a/src/corelib/doc/snippets/statemachine/main2.cpp +++ b/src/corelib/doc/snippets/statemachine/main2.cpp @@ -48,11 +48,11 @@ ** ****************************************************************************/ -#include +#include int main(int argv, char **args) { - QApplication app(argv, args); + QApplication app(argv, args); QStateMachine machine; @@ -66,16 +66,17 @@ int main(int argv, char **args) //![0] //![2] - s12->addTransition(quitButton, SIGNAL(clicked()), s12); + s12->addTransition(quitButton, &QPushButton::clicked, s12); //![2] //![1] QFinalState *s2 = new QFinalState(); - s1->addTransition(quitButton, SIGNAL(clicked()), s2); + s1->addTransition(quitButton, &QPushButton::clicked, s2); machine.addState(s2); machine.setInitialState(s1); - QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit())); + QObject::connect(&machine, &QStateMachine::finished, + QCoreApplication::instance(), &QCoreApplication::quit); //![1] QButton *interruptButton = new QPushButton("Interrupt Button"); @@ -90,11 +91,11 @@ int main(int argv, char **args) mbox->addButton(QMessageBox::Ok); mbox->setText("Interrupted!"); mbox->setIcon(QMessageBox::Information); - QObject::connect(s3, SIGNAL(entered()), mbox, SLOT(exec())); + QObject::connect(s3, &QState::entered, mbox, &QMessageBox::exec); s3->addTransition(s1h); machine.addState(s3); - s1->addTransition(interruptButton, SIGNAL(clicked()), s3); + s1->addTransition(interruptButton, &QPushButton::clicked, s3); //![3] return app.exec(); diff --git a/src/corelib/doc/snippets/statemachine/main3.cpp b/src/corelib/doc/snippets/statemachine/main3.cpp index bc9a0e29c4..b665565aef 100644 --- a/src/corelib/doc/snippets/statemachine/main3.cpp +++ b/src/corelib/doc/snippets/statemachine/main3.cpp @@ -62,7 +62,7 @@ int main(int argv, char **args) //![0] //![1] - s1->addTransition(s1, SIGNAL(finished()), s2); + s1->addTransition(s1, &QState::finished, s2); //![1] return app.exec(); diff --git a/src/corelib/doc/snippets/statemachine/main5.cpp b/src/corelib/doc/snippets/statemachine/main5.cpp index 38bb2cb475..d701f51e2b 100644 --- a/src/corelib/doc/snippets/statemachine/main5.cpp +++ b/src/corelib/doc/snippets/statemachine/main5.cpp @@ -98,7 +98,7 @@ int main(int argv, char **args) s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100)); - s1->addTransition(button, SIGNAL(clicked()), s2); + s1->addTransition(button, &QPushButton::clicked, s2); //![3] } @@ -111,7 +111,7 @@ int main(int argv, char **args) s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100)); - QSignalTransition *transition = s1->addTransition(button, SIGNAL(clicked()), s2); + QSignalTransition *transition = s1->addTransition(button, &QPushButton::clicked, s2); transition->addAnimation(new QPropertyAnimation(button, "geometry")); //![4] @@ -130,9 +130,9 @@ int main(int argv, char **args) QState *s2 = new QState(); s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); - connect(s2, SIGNAL(entered()), messageBox, SLOT(exec())); + connect(s2, &QState::entered, messageBox, SLOT(exec())); - s1->addTransition(button, SIGNAL(clicked()), s2); + s1->addTransition(button, &QPushButton::clicked, s2); //![5] } @@ -151,10 +151,10 @@ int main(int argv, char **args) s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); QState *s3 = new QState(); - connect(s3, SIGNAL(entered()), messageBox, SLOT(exec())); + connect(s3, &QState::entered, messageBox, SLOT(exec())); - s1->addTransition(button, SIGNAL(clicked()), s2); - s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3); + s1->addTransition(button, &QPushButton::clicked, s2); + s2->addTransition(s2, &QState::propertiesAssigned, s3); //![6] } diff --git a/src/corelib/doc/snippets/timers/analogclock.cpp b/src/corelib/doc/snippets/timers/analogclock.cpp index 4e1957a450..3edfce3235 100644 --- a/src/corelib/doc/snippets/timers/analogclock.cpp +++ b/src/corelib/doc/snippets/timers/analogclock.cpp @@ -61,7 +61,7 @@ AnalogClock::AnalogClock(QWidget *parent) //! [3] //! [4] QTimer *timer = new QTimer(this); //! [4] //! [5] - connect(timer, SIGNAL(timeout()), this, SLOT(update())); + connect(timer, &QTimer::timeout, this, QOverload<>::of(&AnalogClock::update)); //! [5] //! [6] timer->start(1000); //! [6] diff --git a/src/corelib/doc/snippets/timers/timers.cpp b/src/corelib/doc/snippets/timers/timers.cpp index 5f95899af2..eb0c82c625 100644 --- a/src/corelib/doc/snippets/timers/timers.cpp +++ b/src/corelib/doc/snippets/timers/timers.cpp @@ -61,13 +61,13 @@ Foo::Foo() //! [0] QTimer *timer = new QTimer(this); //! [0] //! [1] - connect(timer, SIGNAL(timeout()), this, SLOT(updateCaption())); + connect(timer, &QTimer::timeout, this, &Foo::updateCaption); //! [1] //! [2] timer->start(1000); //! [2] //! [3] - QTimer::singleShot(200, this, SLOT(updateCaption())); + QTimer::singleShot(200, this, &Foo::updateCaption); //! [3] { @@ -75,7 +75,7 @@ Foo::Foo() //! [4] QTimer *timer = new QTimer(this); //! [4] //! [5] - connect(timer, SIGNAL(timeout()), this, SLOT(processOneThing())); + connect(timer, &QTimer::timeout, this, &Foo::processOneThing); //! [5] //! [6] timer->start(); //! [6] diff --git a/src/corelib/doc/src/animation.qdoc b/src/corelib/doc/src/animation.qdoc index 0c1b2aed17..9cbe50d4a9 100644 --- a/src/corelib/doc/src/animation.qdoc +++ b/src/corelib/doc/src/animation.qdoc @@ -356,11 +356,11 @@ state2->assignProperty(button, "geometry", QRect(250, 250, 100, 30)); QSignalTransition *transition1 = state1->addTransition(button, - SIGNAL(clicked()), state2); + &QPushButton::clicked, state2); transition1->addAnimation(new QPropertyAnimation(button, "geometry")); QSignalTransition *transition2 = state2->addTransition(button, - SIGNAL(clicked()), state1); + &QPushButton::clicked, state1); transition2->addAnimation(new QPropertyAnimation(button, "geometry")); machine->start(); diff --git a/src/corelib/doc/src/statemachine.qdoc b/src/corelib/doc/src/statemachine.qdoc index 43c8497ef2..881a0785c6 100644 --- a/src/corelib/doc/src/statemachine.qdoc +++ b/src/corelib/doc/src/statemachine.qdoc @@ -323,12 +323,12 @@ QState *s1 = new QState(&machine); QPushButton button; - QSignalTransition *trans = new QSignalTransition(&button, SIGNAL(clicked())); + QSignalTransition *trans = new QSignalTransition(&button, &QPushButton::clicked); s1->addTransition(trans); QMessageBox msgBox; msgBox.setText("The button was clicked; carry on."); - QObject::connect(trans, SIGNAL(triggered()), &msgBox, SLOT(exec())); + QObject::connect(trans, QSignalTransition::triggered, &msgBox, &QMessageBox::exec); machine.setInitialState(s1); \endcode -- cgit v1.2.3 From 2e377f29481475e938ab5a1e5857a1d3a88fa397 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 25 Jan 2020 20:16:02 +0100 Subject: Doc/QtBase: replace some 0 with \nullptr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace some 'is 0' or 'are 0' where 0 referes to a nullptr with 'is \nullptr' and 'are \nullptr' Change-Id: Ida9af2971924377efe2f49f435d79e109de2bdf4 Reviewed-by: André Hartmann Reviewed-by: Sze Howe Koh --- src/corelib/global/qglobal.cpp | 4 ++-- src/corelib/io/qbuffer.cpp | 2 +- src/corelib/io/qiodevice.cpp | 2 +- src/corelib/kernel/qmetatype.cpp | 2 +- src/corelib/serialization/qtextstream.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index da69628d2b..0f7ba8580e 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -702,7 +702,7 @@ Q_STATIC_ASSERT((std::is_same::value)); 64-bit integer literals in a platform-independent way. The Q_CHECK_PTR() macro prints a warning containing the source code's file name and line number, saying that the program ran out of - memory, if the pointer is 0. The qPrintable() and qUtf8Printable() + memory, if the pointer is \nullptr. The qPrintable() and qUtf8Printable() macros represent an easy way of printing text. The QT_POINTER_SIZE macro expands to the size of a pointer in bytes. @@ -3263,7 +3263,7 @@ QByteArray QSysInfo::bootUniqueId() \macro void Q_CHECK_PTR(void *pointer) \relates - If \a pointer is 0, prints a message containing the source + If \a pointer is \nullptr, prints a message containing the source code's file name and line number, saying that the program ran out of memory and aborts program execution. It throws \c std::bad_alloc instead if exceptions are enabled. diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index 8e980733de..595fcd2724 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -227,7 +227,7 @@ QBuffer::~QBuffer() \snippet buffer/buffer.cpp 4 - If \a byteArray is 0, the buffer creates its own internal + If \a byteArray is \nullptr, the buffer creates its own internal QByteArray to work on. This byte array is initially empty. \sa buffer(), setData(), open() diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index b89cab5e3c..f7a86c25cd 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1829,7 +1829,7 @@ QByteArray QIODevicePrivate::peek(qint64 maxSize) /*! \fn bool QIODevice::getChar(char *c) Reads one character from the device and stores it in \a c. If \a c - is 0, the character is discarded. Returns \c true on success; + is \nullptr, the character is discarded. Returns \c true on success; otherwise returns \c false. \sa read(), putChar(), ungetChar() diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 46900be1a4..a2b7fec5cd 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -457,7 +457,7 @@ struct DefinedTypesFilter { \deprecated Constructs a value of the given type which is a copy of \a copy. - The default value for \a copy is 0. + The default value for \a copy is \nullptr. Deprecated, use the static function QMetaType::create(int type, const void *copy) instead. diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index 4d92b1e0da..b8137e0abd 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -1681,7 +1681,7 @@ QString QTextStream::readLine(qint64 maxlen) \since 5.5 Reads one line of text from the stream into \a line. - If \a line is 0, the read line is not stored. + If \a line is \nullptr, the read line is not stored. The maximum allowed line length is set to \a maxlen. If the stream contains lines longer than this, then the lines will be -- cgit v1.2.3 From a4363030bf4efd8ed4d6cd99323a14231189e0f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 24 Jan 2020 12:21:46 +0100 Subject: QMultiMap: Add unite documentation I missed copying over the documentation from QMap::unite when deprecating it. Amends 4ec6748c6a30f74e6d8fbb90fc118b306d1fa690 Change-Id: I118382c4645bdc679a378e02a462d104b9af9aad Reviewed-by: Paul Wicking --- src/corelib/tools/qmap.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index a51e59b2b8..e2b7705b55 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -1203,7 +1203,7 @@ void QMapDataBase::freeData(QMapDataBase *d) key is common to both maps, the resulting map will contain the key multiple times. - \sa QMap::unite() + \sa QMultiMap::unite() */ /*! \typedef QMap::Iterator @@ -2128,4 +2128,11 @@ void QMapDataBase::freeData(QMapDataBase *d) once in the returned list. */ +/*! \fn template QMultiMap &QMultiMap::unite(const QMultiMap &other) + + Inserts all the items in the \a other map into this map. If a + key is common to both maps, the resulting map will contain the + key multiple times. +*/ + QT_END_NAMESPACE -- 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/qabstracteventdispatcher.cpp | 2 +- src/corelib/kernel/qmetaobject.cpp | 4 ++-- src/corelib/thread/qmutex.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp index 7215b3f2bd..685a0c595a 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.cpp +++ b/src/corelib/kernel/qabstracteventdispatcher.cpp @@ -160,7 +160,7 @@ QAbstractEventDispatcher::~QAbstractEventDispatcher() /*! Returns a pointer to the event dispatcher object for the specified - \a thread. If \a thread is zero, the current thread is used. If no + \a thread. If \a thread is \nullptr, the current thread is used. If no event dispatcher exists for the specified thread, this function returns \nullptr. 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, diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index f3883278e3..0508932d68 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -487,7 +487,7 @@ QRecursiveMutex::~QRecursiveMutex() \fn QMutexLocker::QMutexLocker(QMutex *mutex) Constructs a QMutexLocker and locks \a mutex. The mutex will be - unlocked when the QMutexLocker is destroyed. If \a mutex is zero, + unlocked when the QMutexLocker is destroyed. If \a mutex is \nullptr, QMutexLocker does nothing. \sa QMutex::lock() -- cgit v1.2.3 From e44de91a2cab6e3c4632523e644fadaa93b89364 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sun, 26 Jan 2020 16:39:05 +0800 Subject: Doc: Clarify usage of Qt::ReturnByValue in QCursor Change-Id: I6ce2c658dc0e72beb9e7a2497c6dbdbc71d96bc5 Reviewed-by: Paul Wicking --- src/corelib/global/qnamespace.qdoc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 169c296bcd..29b58783d5 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -3326,6 +3326,8 @@ This is a dummy type, designed to help users transition from certain deprecated APIs to their replacement APIs. + \sa QCursor::bitmap() + \sa QCursor::mask() \sa QLabel::picture() \sa QLabel::pixmap() */ -- cgit v1.2.3 From be8c257da9a264994243c120231965ff0008ef09 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Jan 2020 13:19:00 +0100 Subject: QThread::setPriority() Warn about invalid parameter on all platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit InheritPriority may not be set, but the warning only occurs on Windows. Move the warning to the public class. Change-Id: I51d401300f840e4c1396c2c30182e49ed45d60d2 Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Christian Tismer Reviewed-by: David Faure Reviewed-by: Mårten Nordheim --- src/corelib/thread/qthread.cpp | 6 +++++- src/corelib/thread/qthread_win.cpp | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index d3bb372b00..d18056063f 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -614,7 +614,7 @@ void QThread::run() priority. The \a priority argument can be any value in the \c - QThread::Priority enum except for \c InheritPriorty. + QThread::Priority enum except for \c InheritPriority. The effect of the \a priority parameter is dependent on the operating system's scheduling policy. In particular, the \a priority @@ -626,6 +626,10 @@ void QThread::run() */ void QThread::setPriority(Priority priority) { + if (priority == QThread::InheritPriority) { + qWarning("QThread::setPriority: Argument cannot be InheritPriority"); + return; + } Q_D(QThread); QMutexLocker locker(&d->mutex); if (!d->running) { diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 3df7080caf..bc70e3178a 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -715,9 +715,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority) prio = THREAD_PRIORITY_TIME_CRITICAL; break; - case QThread::InheritPriority: default: - qWarning("QThread::setPriority: Argument cannot be InheritPriority"); return; } -- cgit v1.2.3 From 07a576cc6171fd78d7fb3a0332349c2fa6127460 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Mon, 27 Jan 2020 16:45:16 +0100 Subject: QProcess: remove deprecated signature of finished signal Task-number: QTBUG-80906 Change-Id: Ic9852bc5031d357d23ff6c13a65d020a4b6ea3d6 Reviewed-by: Joerg Bornemann --- src/corelib/io/qprocess.cpp | 16 ---------------- src/corelib/io/qprocess.h | 6 +----- 2 files changed, 1 insertion(+), 21 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index aedcae2cdc..5d5b0b2a29 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -810,16 +810,6 @@ void QProcessPrivate::Channel::clear() \a newState argument is the state QProcess changed to. */ -#if QT_DEPRECATED_SINCE(5, 13) -/*! - \fn void QProcess::finished(int exitCode) - \obsolete - \overload - - Use finished(int exitCode, QProcess::ExitStatus status) instead. -*/ -#endif - /*! \fn void QProcess::finished(int exitCode, QProcess::ExitStatus exitStatus) @@ -1175,12 +1165,6 @@ bool QProcessPrivate::_q_processDied() //emit q->standardOutputClosed(); //emit q->standardErrorClosed(); -#if QT_DEPRECATED_SINCE(5, 13) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - emit q->finished(exitCode); -QT_WARNING_POP -#endif emit q->finished(exitCode, exitStatus); } #if defined QPROCESS_DEBUG diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index 585508adf1..0a2187750f 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -273,11 +273,7 @@ public Q_SLOTS: Q_SIGNALS: void started(QPrivateSignal); -#if QT_DEPRECATED_SINCE(5, 13) - QT_DEPRECATED_X("Use QProcess::finished(int, QProcess::ExitStatus) instead") - void finished(int exitCode); // ### Qt 6: merge the two signals with a default value -#endif - void finished(int exitCode, QProcess::ExitStatus exitStatus); + void finished(int exitCode, QProcess::ExitStatus exitStatus = NormalExit); #if QT_DEPRECATED_SINCE(5, 6) QT_DEPRECATED_X("Use QProcess::errorOccurred(QProcess::ProcessError) instead") void error(QProcess::ProcessError error); -- cgit v1.2.3