diff options
Diffstat (limited to 'src/corelib')
24 files changed, 218 insertions, 102 deletions
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp index af36bd7e2f..8561f908b9 100644 --- a/src/corelib/codecs/qutfcodec.cpp +++ b/src/corelib/codecs/qutfcodec.cpp @@ -930,6 +930,7 @@ QString QUtf32::convertToUnicode(const char *chars, int len, QTextCodec::Convert tuple[num++] = *chars++; if (num == 4) { if (!headerdone) { + headerdone = true; if (endian == DetectEndianness) { if (tuple[0] == 0xff && tuple[1] == 0xfe && tuple[2] == 0 && tuple[3] == 0 && endian != BigEndianness) { endian = LittleEndianness; diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 57ccd308d7..8851e08d4f 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -505,7 +505,7 @@ namespace Qt { AA_DontUseNativeMenuBar = 6, AA_MacDontSwapCtrlAndMeta = 7, AA_Use96Dpi = 8, - AA_MSWindowsDisableVirtualKeyboard = 9, + AA_DisableNativeVirtualKeyboard = 9, #if QT_DEPRECATED_SINCE(5, 14) AA_X11InitThreads Q_DECL_ENUMERATOR_DEPRECATED = 10, #endif diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 708ecb11ab..3e22c9e661 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -293,10 +293,10 @@ This attribute must be set before QGuiApplication is constructed. This value was added in 5.13 - \value AA_MSWindowsDisableVirtualKeyboard When this attribute is set, - Windows' native on-screen virtual keyboard will not be shown - automatically when a text input widget gains focus on a system - without a physical keyboard. + \value AA_DisableNativeVirtualKeyboard When this attribute is set, the native + on-screen virtual keyboard will not be shown automatically when a + text input widget gains focus on a system without a physical keyboard. + Currently supported on the Windows platform only. This value was added in 5.15 The following values are deprecated or obsolete: @@ -3339,6 +3339,8 @@ This is a dummy type, designed to help users transition from certain deprecated APIs to their replacement APIs. + \omitvalue ReturnByValue + \sa QCursor::bitmap() \sa QCursor::mask() \sa QLabel::picture() diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 5d5b0b2a29..acc60915e7 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -2230,8 +2230,16 @@ void QProcessPrivate::start(QIODevice::OpenMode mode) startProcess(); } +/*! + \since 5.15 + + Splits the string \a command into a list of tokens, and returns + the list. -static QStringList parseCombinedArgString(const QString &program) + Tokens with spaces can be surrounded by double quotes; three + consecutive double quotes represent the quote character itself. +*/ +QStringList QProcess::splitCommand(const QString &command) { QStringList args; QString tmp; @@ -2241,13 +2249,13 @@ static QStringList parseCombinedArgString(const QString &program) // handle quoting. tokens can be surrounded by double quotes // "hello world". three consecutive double quotes represent // the quote character itself. - for (int i = 0; i < program.size(); ++i) { - if (program.at(i) == QLatin1Char('"')) { + for (int i = 0; i < command.size(); ++i) { + if (command.at(i) == QLatin1Char('"')) { ++quoteCount; if (quoteCount == 3) { // third consecutive quote quoteCount = 0; - tmp += program.at(i); + tmp += command.at(i); } continue; } @@ -2256,13 +2264,13 @@ static QStringList parseCombinedArgString(const QString &program) inQuote = !inQuote; quoteCount = 0; } - if (!inQuote && program.at(i).isSpace()) { + if (!inQuote && command.at(i).isSpace()) { if (!tmp.isEmpty()) { args += tmp; tmp.clear(); } } else { - tmp += program.at(i); + tmp += command.at(i); } } if (!tmp.isEmpty()) @@ -2272,6 +2280,7 @@ static QStringList parseCombinedArgString(const QString &program) } /*! + \obsolete \overload Starts the command \a command in a new process. @@ -2308,11 +2317,13 @@ static QStringList parseCombinedArgString(const QString &program) list-based API. In these rare cases you need to use setProgram() and setNativeArguments() instead of this function. + \sa splitCommand() + */ #if !defined(QT_NO_PROCESS_COMBINED_ARGUMENT_START) void QProcess::start(const QString &command, OpenMode mode) { - QStringList args = parseCombinedArgString(command); + QStringList args = splitCommand(command); if (args.isEmpty()) { Q_D(QProcess); d->setErrorAndEmit(QProcess::FailedToStart, tr("No program defined")); @@ -2477,6 +2488,7 @@ int QProcess::execute(const QString &program, const QStringList &arguments) } /*! + \obsolete \overload Starts the program \a command in a new process, waits for it to finish, @@ -2487,7 +2499,7 @@ int QProcess::execute(const QString &program, const QStringList &arguments) After the \a command string has been split and unquoted, this function behaves like the overload which takes the arguments as a string list. - \sa start() + \sa start(), splitCommand() */ int QProcess::execute(const QString &command) { @@ -2543,6 +2555,7 @@ bool QProcess::startDetached(const QString &program, } /*! + \obsolete \overload startDetached() Starts the command \a command in a new process, and detaches from it. @@ -2553,11 +2566,11 @@ bool QProcess::startDetached(const QString &program, After the \a command string has been split and unquoted, this function behaves like the overload which takes the arguments as a string list. - \sa start(const QString &command, QIODevice::OpenMode mode) + \sa start(const QString &command, QIODevice::OpenMode mode), splitCommand() */ bool QProcess::startDetached(const QString &command) { - QStringList args = parseCombinedArgString(command); + QStringList args = splitCommand(command); if (args.isEmpty()) return false; diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index 0a2187750f..0ef02b196d 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -160,8 +160,14 @@ public: void start(const QString &program, const QStringList &arguments, OpenMode mode = ReadWrite); #if !defined(QT_NO_PROCESS_COMBINED_ARGUMENT_START) +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X( + "Use QProcess::start(const QString &program, const QStringList &arguments," + "OpenMode mode = ReadWrite) instead" + ) void start(const QString &command, OpenMode mode = ReadWrite); #endif +#endif void start(OpenMode mode = ReadWrite); bool startDetached(qint64 *pid = nullptr); bool open(OpenMode mode = ReadWrite) override; @@ -250,8 +256,12 @@ public: bool atEnd() const override; // ### Qt6: remove trivial override static int execute(const QString &program, const QStringList &arguments); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X( + "Use QProcess::execute(const QString &program, const QStringList &arguments) instead" + ) static int execute(const QString &command); - +#endif static bool startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory #if defined(Q_QDOC) @@ -261,12 +271,19 @@ public: #if !defined(Q_QDOC) static bool startDetached(const QString &program, const QStringList &arguments); // ### Qt6: merge overloads #endif +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X( + "Use QProcess::startDetached(const QString &program, const QStringList &arguments) instead" + ) static bool startDetached(const QString &command); +#endif static QStringList systemEnvironment(); static QString nullDevice(); + static QStringList splitCommand(const QString &command); + public Q_SLOTS: void terminate(); void kill(); diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index a5128a868b..9d773e6f52 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -343,7 +343,10 @@ QT_BEGIN_NAMESPACE OS configuration, locale, or they may change in future Qt versions. \note On Android, applications with open files on the external storage (<USER> locations), - will be killed if the external storage is unmounted. + will be killed if the external storage is unmounted. + + \note On Android 6.0 (API 23) or higher, the "WRITE_EXTERNAL_STORAGE" permission must be + requested at runtime when using QStandardPaths::writableLocation or QStandardPaths::standardLocations. \note On Android, reading/writing to GenericDataLocation needs the READ_EXTERNAL_STORAGE/WRITE_EXTERNAL_STORAGE permission granted. diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index b6ddcce27c..3e7d8e113c 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -4149,7 +4149,7 @@ static bool isIp6(const QString &text) /*! Returns a valid URL from a user supplied \a userInput string if one can be - deducted. In the case that is not possible, an invalid QUrl() is returned. + deduced. In the case that is not possible, an invalid QUrl() is returned. This overload takes a \a workingDirectory path, in order to be able to handle relative paths. This is especially useful when handling command diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 033e4e2f97..e0506b12db 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -3056,12 +3056,8 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex & Returns \c true if the item in the column indicated by the given \a source_column and \a source_parent should be included in the model; otherwise returns \c false. - The default implementation returns \c true if the value held by the relevant item - matches the filter string, wildcard string or regular expression. - - \note By default, the Qt::DisplayRole is used to determine if the column - should be accepted or not. This can be changed by setting the \l - filterRole property. + \note The default implementation always returns \c true. You must reimplement this + method to get the described behavior. \sa filterAcceptsRow(), setFilterFixedString(), setFilterRegExp(), setFilterWildcard() */ diff --git a/src/corelib/kernel/qmath.qdoc b/src/corelib/kernel/qmath.qdoc index a2e24e925b..346171f044 100644 --- a/src/corelib/kernel/qmath.qdoc +++ b/src/corelib/kernel/qmath.qdoc @@ -51,8 +51,6 @@ \value M_2_SQRTPI Two divided by the square root of pi, 2 / \unicode{0x221A}\unicode{0x3C0} \value M_SQRT2 The square root of two, \unicode{0x221A}2 \value M_SQRT1_2 The square roof of half, 1 / \unicode{0x221A}2 - - \pagekeywords math trigonometry qmath floor ceiling absolute sine cosine tangent inverse tan exponent power natural logarithm pi */ /*! diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 0730dbffd1..4c1f9f20f7 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -714,7 +714,7 @@ QMetaType &QMetaType::operator=(const QMetaType &other) as the QMetaType \a b, otherwise returns \c false. */ -/*! \fn bool operator!=(const QMetaType &a, const QMetaType &c) +/*! \fn bool operator!=(const QMetaType &a, const QMetaType &b) \since 5.15 \relates QMetaType \overload diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 697c9b6148..2fdf94c38b 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -47,6 +47,7 @@ #include "qabstracteventdispatcher_p.h" #include "qcoreapplication.h" #include "qcoreapplication_p.h" +#include "qloggingcategory.h" #include "qvariant.h" #include "qmetaobject.h" #include <qregexp.h> @@ -78,6 +79,8 @@ QT_BEGIN_NAMESPACE static int DIRECT_CONNECTION_ONLY = 0; +Q_LOGGING_CATEGORY(lcConnections, "qt.core.qmetaobject.connectslotsbyname") + Q_CORE_EXPORT QBasicAtomicPointer<QSignalSpyCallbackSet> qt_signal_spy_callback_set = Q_BASIC_ATOMIC_INITIALIZER(nullptr); void qt_register_signal_spy_callbacks(QSignalSpyCallbackSet *callback_set) @@ -183,15 +186,7 @@ QMetaObject *QObjectData::dynamicMetaObject() const QObjectPrivate::QObjectPrivate(int version) : threadData(nullptr), currentChildBeingDeleted(nullptr) { -#ifdef QT_BUILD_INTERNAL - // Don't check the version parameter in internal builds. - // This allows incompatible versions to be loaded, possibly for testing. - Q_UNUSED(version); -#else - if (Q_UNLIKELY(version != QObjectPrivateVersion)) - qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)", - version, QObjectPrivateVersion); -#endif + checkForIncompatibleLibraryVersion(version); // QObjectData initialization q_ptr = nullptr; @@ -3555,6 +3550,37 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, return success; } +// Helpers for formatting the connect statements of connectSlotsByName()'s debug mode +static QByteArray formatConnectionSignature(const char *className, const QMetaMethod &method) +{ + const auto signature = method.methodSignature(); + Q_ASSERT(signature.endsWith(')')); + const int openParen = signature.indexOf('('); + const bool hasParameters = openParen >= 0 && openParen < signature.size() - 2; + QByteArray result; + if (hasParameters) { + result += "qOverload<" + + signature.mid(openParen + 1, signature.size() - openParen - 2) + ">("; + } + result += '&'; + result += className + QByteArrayLiteral("::") + method.name(); + if (hasParameters) + result += ')'; + return result; +} + +static QByteArray msgConnect(const QMetaObject *senderMo, const QByteArray &senderName, + const QMetaMethod &signal, const QObject *receiver, int receiverIndex) +{ + const auto receiverMo = receiver->metaObject(); + const auto slot = receiverMo->method(receiverIndex); + QByteArray message = QByteArrayLiteral("QObject::connect(") + + senderName + ", " + formatConnectionSignature(senderMo->className(), signal) + + ", " + receiver->objectName().toLatin1() + ", " + + formatConnectionSignature(receiverMo->className(), slot) + ");"; + return message; +} + /*! \fn void QMetaObject::connectSlotsByName(QObject *object) @@ -3636,6 +3662,8 @@ void QMetaObject::connectSlotsByName(QObject *o) // we connect it... if (Connection(QMetaObjectPrivate::connect(co, sigIndex, smeta, o, i))) { foundIt = true; + qCDebug(lcConnections, "%s", + msgConnect(smeta, coName, QMetaObjectPrivate::signal(smeta, sigIndex), o, i).constData()); // ...and stop looking for further objects with the same name. // Note: the Designer will make sure each object name is unique in the above // 'list' but other code may create two child objects with the same name. In diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index d6e73fbefc..97b492360c 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -310,6 +310,8 @@ public: virtual ~QObjectPrivate(); void deleteChildren(); + inline void checkForIncompatibleLibraryVersion(int version) const; + void setParent_helper(QObject *); void moveToThread_helper(); void setThreadData_helper(QThreadData *currentData, QThreadData *targetData); @@ -384,6 +386,28 @@ public: Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_MOVABLE_TYPE); +/* + Catch mixing of incompatible library versions. + + Should be called from the constructor of every non-final subclass + of QObjectPrivate, to ensure we catch incompatibilities between + the intermediate base and subclasses thereof. +*/ +inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) const +{ +#if defined(QT_BUILD_INTERNAL) + // Don't check the version parameter in internal builds. + // This allows incompatible versions to be loaded, possibly for testing. + Q_UNUSED(version); +#else + if (Q_UNLIKELY(version != QObjectPrivateVersion)) { + qFatal("Cannot mix incompatible Qt library (%d.%d.%d) with this library (%d.%d.%d)", + (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff, + (QObjectPrivateVersion >> 16) & 0xff, (QObjectPrivateVersion >> 8) & 0xff, QObjectPrivateVersion & 0xff); + } +#endif +} + inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const { return declarativeData && QAbstractDeclarativeData::isSignalConnected diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index b84b5a503f..fd7c081e88 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -356,7 +356,7 @@ struct Q_CORE_EXPORT QMetaObject static typename std::enable_if<!QtPrivate::FunctionPointer<Func>::IsPointerToMemberFunction && QtPrivate::FunctionPointer<Func>::ArgumentCount == -1 && !std::is_convertible<Func, const char*>::value, bool>::type - invokeMethod(QObject *context, Func function, typename std::result_of<Func()>::type *ret) + invokeMethod(QObject *context, Func function, decltype(function()) *ret) { return invokeMethodImpl(context, new QtPrivate::QFunctorSlotObjectWithNoArgs<Func, decltype(function())>(std::move(function)), diff --git a/src/corelib/serialization/qcborcommon.cpp b/src/corelib/serialization/qcborcommon.cpp index 37fb198744..5fc47fa399 100644 --- a/src/corelib/serialization/qcborcommon.cpp +++ b/src/corelib/serialization/qcborcommon.cpp @@ -54,6 +54,8 @@ QT_BEGIN_NAMESPACE \brief The <QtCborCommon> header contains definitions common to both the streaming classes (QCborStreamReader and QCborStreamWriter) and to QCborValue. + + \sa QCborError */ /*! @@ -203,7 +205,7 @@ QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st) /*! \class QCborError \inmodule QtCore - \relates <QtCborCommon> + \inheaderfile <QtCborCommon> \reentrant \since 5.12 diff --git a/src/corelib/text/qharfbuzz.cpp b/src/corelib/text/qharfbuzz.cpp index a3e266ccd2..f54ce26206 100644 --- a/src/corelib/text/qharfbuzz.cpp +++ b/src/corelib/text/qharfbuzz.cpp @@ -72,7 +72,7 @@ HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch) void (*HB_Library_Resolve(const char *library, int version, const char *symbol))() { -#if !QT_CONFIG(library) +#if !QT_CONFIG(library) || defined(Q_OS_WASM) Q_UNUSED(library); Q_UNUSED(version); Q_UNUSED(symbol); diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 877f5df462..8cdf41ffbf 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -7397,6 +7397,8 @@ float QString::toFloat(bool *ok) const The formatting always uses QLocale::C, i.e., English/UnitedStates. To get a localized string representation of a number, use QLocale::toString() with the appropriate locale. + + \sa number() */ /*! \fn QString &QString::setNum(uint n, int base) @@ -7454,6 +7456,8 @@ QString &QString::setNum(qulonglong n, int base) The formatting always uses QLocale::C, i.e., English/UnitedStates. To get a localized string representation of a number, use QLocale::toString() with the appropriate locale. + + \sa number() */ QString &QString::setNum(double n, char f, int prec) @@ -7472,6 +7476,8 @@ QString &QString::setNum(double n, char f, int prec) The formatting always uses QLocale::C, i.e., English/UnitedStates. To get a localized string representation of a number, use QLocale::toString() with the appropriate locale. + + \sa number() */ diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 65d702ff1c..f08c7b0d00 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1116,7 +1116,7 @@ int QStringView::toWCharArray(wchar_t *array) const if (sizeof(wchar_t) == sizeof(QChar)) { if (auto src = data()) memcpy(array, src, sizeof(QChar) * size()); - return size(); + return int(size()); // ### q6sizetype } else { return QString::toUcs4_helper(reinterpret_cast<const ushort *>(data()), int(size()), reinterpret_cast<uint *>(array)); diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp index c4ddb06ea4..08dade7e68 100644 --- a/src/corelib/text/qstringview.cpp +++ b/src/corelib/text/qstringview.cpp @@ -528,9 +528,9 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QString QStringView::arg(Args &&...args) const - \fn QString QLatin1String::arg(Args &&...args) const - \fn QString QString::arg(Args &&...args) const + \fn template <typename...Args> QString QStringView::arg(Args &&...args) const + \fn template <typename...Args> QString QLatin1String::arg(Args &&...args) const + \fn template <typename...Args> QString QString::arg(Args &&...args) const \since 5.14 Replaces occurrences of \c{%N} in this string with the corresponding diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 0508932d68..9bfd50f2d9 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -212,7 +212,6 @@ QMutex::~QMutex() } /*! \fn void QMutex::lock() - \fn QRecursiveMutex::lock() Locks the mutex. If another thread has locked the mutex then this call will block until that thread has unlocked it. @@ -237,7 +236,6 @@ void QMutex::lock() QT_MUTEX_LOCK_NOEXCEPT } /*! \fn bool QMutex::tryLock(int timeout) - \fn bool QRecursiveMutex::tryLock(int timeout) Attempts to lock the mutex. This function returns \c true if the lock was obtained; otherwise it returns \c false. If another thread has @@ -272,7 +270,6 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT } /*! \fn bool QMutex::try_lock() - \fn bool QRecursiveMutex::try_lock() \since 5.8 Attempts to lock the mutex. This function returns \c true if the lock @@ -286,7 +283,6 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT */ /*! \fn template <class Rep, class Period> bool QMutex::try_lock_for(std::chrono::duration<Rep, Period> duration) - \fn template <class Rep, class Period> bool QRecursiveMutex::try_lock_for(std::chrono::duration<Rep, Period> duration) \since 5.8 Attempts to lock the mutex. This function returns \c true if the lock @@ -311,7 +307,6 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT */ /*! \fn template<class Clock, class Duration> bool QMutex::try_lock_until(std::chrono::time_point<Clock, Duration> timePoint) - \fn template<class Clock, class Duration> bool QRecursiveMutex::try_lock_until(std::chrono::time_point<Clock, Duration> timePoint) \since 5.8 Attempts to lock the mutex. This function returns \c true if the lock @@ -336,7 +331,6 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT */ /*! \fn void QMutex::unlock() - \fn void QRecursiveMutex::unlock() Unlocks the mutex. Attempting to unlock a mutex in a different thread to the one that locked it results in an error. Unlocking a diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 773280ad68..86c08058fc 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1100,9 +1100,10 @@ QString QDate::longDayName(int weekday, MonthNameType type) #if QT_CONFIG(datestring) // depends on, so implies, textdate -static QString toStringTextDate(QDate date, QCalendar cal) +static QString toStringTextDate(QDate date) { if (date.isValid()) { + QCalendar cal; // Always Gregorian const auto parts = cal.partsFromDate(date); if (parts.isValid()) { const QLatin1Char sp(' '); @@ -1123,14 +1124,10 @@ static QString toStringIsoDate(QDate date) } /*! - \fn QString QDate::toString(Qt::DateFormat format) const - \fn QString QDate::toString(Qt::DateFormat format, QCalendar cal) const - \overload Returns the date as a string. The \a format parameter determines the format - of the string. If \a cal is supplied, it determines the calendar used to - represent the date; it defaults to Gregorian. + of the string. If the \a format is Qt::TextDate, the string is formatted in the default way. The day and month names will be localized names using the system @@ -1168,16 +1165,44 @@ static QString toStringIsoDate(QDate date) */ QString QDate::toString(Qt::DateFormat format) const { - return toString(format, QCalendar()); + if (!isValid()) + return QString(); + + switch (format) { +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED + case Qt::SystemLocaleDate: + case Qt::SystemLocaleShortDate: + return QLocale::system().toString(*this, QLocale::ShortFormat); + case Qt::SystemLocaleLongDate: + return QLocale::system().toString(*this, QLocale::LongFormat); + case Qt::LocaleDate: + case Qt::DefaultLocaleShortDate: + return QLocale().toString(*this, QLocale::ShortFormat); + case Qt::DefaultLocaleLongDate: + return QLocale().toString(*this, QLocale::LongFormat); +QT_WARNING_POP +#endif // 5.15 + case Qt::RFC2822Date: + return QLocale::c().toString(*this, QStringView(u"dd MMM yyyy")); + default: + case Qt::TextDate: + return toStringTextDate(*this); + case Qt::ISODate: + case Qt::ISODateWithMs: + // No calendar dependence + return toStringIsoDate(*this); + } } +#if QT_DEPRECATED_SINCE(5, 15) QString QDate::toString(Qt::DateFormat format, QCalendar cal) const { if (!isValid()) return QString(); switch (format) { -#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED case Qt::SystemLocaleDate: case Qt::SystemLocaleShortDate: return QLocale::system().toString(*this, QLocale::ShortFormat, cal); @@ -1188,18 +1213,19 @@ QString QDate::toString(Qt::DateFormat format, QCalendar cal) const return QLocale().toString(*this, QLocale::ShortFormat, cal); case Qt::DefaultLocaleLongDate: return QLocale().toString(*this, QLocale::LongFormat, cal); -#endif // 5.15 +QT_WARNING_POP case Qt::RFC2822Date: return QLocale::c().toString(*this, QStringView(u"dd MMM yyyy"), cal); default: case Qt::TextDate: - return toStringTextDate(*this, cal); + return toStringTextDate(*this); case Qt::ISODate: case Qt::ISODateWithMs: // No calendar dependence return toStringIsoDate(*this); } } +#endif // 5.15 /*! \fn QString QDate::toString(const QString &format) const @@ -1208,7 +1234,7 @@ QString QDate::toString(Qt::DateFormat format, QCalendar cal) const \fn QString QDate::toString(QStringView format, QCalendar cal) const Returns the date as a string. The \a format parameter determines the format - of the result string. If \cal is supplied, it determines the calendar used + of the result string. If \a cal is supplied, it determines the calendar used to represent the date; it defaults to Gregorian. These expressions may be used: @@ -1643,6 +1669,7 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format) switch (format) { #if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED case Qt::SystemLocaleDate: case Qt::SystemLocaleShortDate: return QLocale::system().toDate(string, QLocale::ShortFormat); @@ -1653,6 +1680,7 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format) return QLocale().toDate(string, QLocale::ShortFormat); case Qt::DefaultLocaleLongDate: return QLocale().toDate(string, QLocale::LongFormat); +QT_WARNING_POP #endif // 5.15 case Qt::RFC2822Date: return rfcDateImpl(string).date; @@ -2033,6 +2061,7 @@ QString QTime::toString(Qt::DateFormat format) const switch (format) { #if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED case Qt::SystemLocaleDate: case Qt::SystemLocaleShortDate: return QLocale::system().toString(*this, QLocale::ShortFormat); @@ -2043,6 +2072,7 @@ QString QTime::toString(Qt::DateFormat format) const return QLocale().toString(*this, QLocale::ShortFormat); case Qt::DefaultLocaleLongDate: return QLocale().toString(*this, QLocale::LongFormat); +QT_WARNING_POP #endif // 5.15 case Qt::ISODateWithMs: return QString::asprintf("%02d:%02d:%02d.%03d", hour(), minute(), second(), msec()); @@ -2434,6 +2464,7 @@ QTime QTime::fromString(const QString &string, Qt::DateFormat format) switch (format) { #if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED case Qt::SystemLocaleDate: case Qt::SystemLocaleShortDate: return QLocale::system().toTime(string, QLocale::ShortFormat); @@ -2444,6 +2475,7 @@ QTime QTime::fromString(const QString &string, Qt::DateFormat format) return QLocale().toTime(string, QLocale::ShortFormat); case Qt::DefaultLocaleLongDate: return QLocale().toTime(string, QLocale::LongFormat); +QT_WARNING_POP #endif // 5.15 case Qt::RFC2822Date: return rfcDateImpl(string).time; @@ -4279,14 +4311,9 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC) #if QT_CONFIG(datestring) // depends on, so implies, textdate /*! - \fn QString QDateTime::toString(Qt::DateFormat format) const - \fn QString QDateTime::toString(Qt::DateFormat format, QCalendar cal) const - \overload - Returns the datetime as a string in the \a format given. If \cal is - supplied, it determines the calendar used to represent the date; it defaults - to Gregorian. + Returns the datetime as a string in the \a format given. If the \a format is Qt::TextDate, the string is formatted in the default way. The day and month names will be localized names using the system @@ -4329,37 +4356,34 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC) QString QDateTime::toString(Qt::DateFormat format) const { - return toString(format, QCalendar()); -} - -QString QDateTime::toString(Qt::DateFormat format, QCalendar cal) const -{ QString buf; if (!isValid()) return buf; switch (format) { #if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED case Qt::SystemLocaleDate: case Qt::SystemLocaleShortDate: - return QLocale::system().toString(*this, QLocale::ShortFormat, cal); + return QLocale::system().toString(*this, QLocale::ShortFormat); case Qt::SystemLocaleLongDate: - return QLocale::system().toString(*this, QLocale::LongFormat, cal); + return QLocale::system().toString(*this, QLocale::LongFormat); case Qt::LocaleDate: case Qt::DefaultLocaleShortDate: - return QLocale().toString(*this, QLocale::ShortFormat, cal); + return QLocale().toString(*this, QLocale::ShortFormat); case Qt::DefaultLocaleLongDate: - return QLocale().toString(*this, QLocale::LongFormat, cal); + return QLocale().toString(*this, QLocale::LongFormat); +QT_WARNING_POP #endif // 5.15 case Qt::RFC2822Date: { - buf = QLocale::c().toString(*this, u"dd MMM yyyy hh:mm:ss ", cal); + buf = QLocale::c().toString(*this, u"dd MMM yyyy hh:mm:ss "); buf += toOffsetString(Qt::TextDate, offsetFromUtc()); return buf; } default: case Qt::TextDate: { const QPair<QDate, QTime> p = getDateTime(d); - buf = toStringTextDate(p.first, cal); + buf = toStringTextDate(p.first); // Insert time between date's day and year: buf.insert(buf.lastIndexOf(QLatin1Char(' ')), QLatin1Char(' ') + p.second.toString(Qt::TextDate)); @@ -4381,7 +4405,6 @@ QString QDateTime::toString(Qt::DateFormat format, QCalendar cal) const } case Qt::ISODate: case Qt::ISODateWithMs: { - // No calendar dependence const QPair<QDate, QTime> p = getDateTime(d); buf = toStringIsoDate(p.first); if (buf.isEmpty()) @@ -4412,7 +4435,7 @@ QString QDateTime::toString(Qt::DateFormat format, QCalendar cal) const \fn QString QDateTime::toString(QStringView format, QCalendar cal) const Returns the datetime as a string. The \a format parameter determines the - format of the result string. If \cal is supplied, it determines the calendar + format of the result string. If \a cal is supplied, it determines the calendar used to represent the date; it defaults to Gregorian. See QTime::toString() and QDate::toString() for the supported specifiers for time and date, respectively. @@ -5228,6 +5251,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) switch (format) { #if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED case Qt::SystemLocaleDate: case Qt::SystemLocaleShortDate: return QLocale::system().toDateTime(string, QLocale::ShortFormat); @@ -5238,6 +5262,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) return QLocale().toDateTime(string, QLocale::ShortFormat); case Qt::DefaultLocaleLongDate: return QLocale().toDateTime(string, QLocale::LongFormat); +QT_WARNING_POP #endif // 5.15 case Qt::RFC2822Date: { const ParsedRfcDateTime rfc = rfcDateImpl(string); diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h index c1653b5585..645923ada8 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -111,7 +111,11 @@ public: #endif // textdate && deprecated #if QT_CONFIG(datestring) QString toString(Qt::DateFormat format = Qt::TextDate) const; +#if QT_DEPRECATED_SINCE(5, 15) + // Only the deprecated locale-dependent formats use the calendar. + QT_DEPRECATED_X("Use QLocale or omit the calendar") QString toString(Qt::DateFormat format, QCalendar cal) const; +#endif #if QT_STRINGVIEW_LEVEL < 2 QString toString(const QString &format) const; @@ -334,7 +338,6 @@ public: #if QT_CONFIG(datestring) QString toString(Qt::DateFormat format = Qt::TextDate) const; - QString toString(Qt::DateFormat format, QCalendar cal) const; #if QT_STRINGVIEW_LEVEL < 2 QString toString(const QString &format) const; QString toString(const QString &format, QCalendar cal) const; diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 9b9c67e42b..6d2b8f7a3e 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -1999,7 +1999,7 @@ void QMapDataBase::freeData(QMapDataBase *d) \sa replace() */ -/*! \fn template <class Key, class T> typename QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(typename QMultiMap<Key, T>::const_iterator pos, const Key &key, const T &value) +/*! \fn [qmultimap-insert-pos] template <class Key, class T> typename QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(typename QMultiMap<Key, T>::const_iterator pos, const Key &key, const T &value) \since 5.1 Inserts a new item with the key \a key and value \a value and with hint \a pos @@ -2128,7 +2128,8 @@ void QMapDataBase::freeData(QMapDataBase *d) once in the returned list. */ -/*! \fn template <class Key, class T> QMultiMap<Key, T> &QMultiMap<Key, T>::unite(const QMultiMap<Key, T> &other) +/*! + \fn [qmultimap-unite] template <class Key, class T> QMultiMap<Key, T> &QMultiMap<Key, T>::unite(const QMultiMap<Key, T> &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 diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index a70b355c67..a971919e54 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -1086,14 +1086,14 @@ public: QList<Key> uniqueKeys() const; QList<T> values(const Key &key) const; - using typename QMap<Key, T>::iterator; - using typename QMap<Key, T>::const_iterator; - inline typename QMap<Key, T>::iterator replace(const Key &key, const T &value) { return QMap<Key, T>::insert(key, value); } - iterator insert(const Key &key, const T &value); - iterator insert(const_iterator pos, const Key &key, const T &value); + typename QMap<Key, T>::iterator insert(const Key &key, const T &value); + //! [qmultimap-insert-pos] + typename QMap<Key, T>::iterator insert(typename QMap<Key, T>::const_iterator pos, + const Key &key, const T &value); + //! [qmultimap-unite] QMultiMap &unite(const QMultiMap &other); inline QMultiMap &operator+=(const QMultiMap &other) { return unite(other); } @@ -1151,7 +1151,7 @@ Q_OUTOFLINE_TEMPLATE QList<Key> QMultiMap<Key, T>::uniqueKeys() const { QList<Key> res; res.reserve(size()); // May be too much, but assume short lifetime - const_iterator i = this->begin(); + typename QMap<Key, T>::const_iterator i = this->begin(); if (i != this->end()) { for (;;) { const Key &aKey = i.key(); @@ -1172,7 +1172,7 @@ Q_OUTOFLINE_TEMPLATE QList<T> QMultiMap<Key, T>::values(const Key &akey) const QList<T> res; Node *n = this->d->findNode(akey); if (n) { - const_iterator it(n); + typename QMap<Key, T>::const_iterator it(n); do { res.append(*it); ++it; @@ -1182,8 +1182,8 @@ Q_OUTOFLINE_TEMPLATE QList<T> QMultiMap<Key, T>::values(const Key &akey) const } template <class Key, class T> -Q_INLINE_TEMPLATE typename QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(const Key &akey, - const T &avalue) +Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMultiMap<Key, T>::insert(const Key &akey, + const T &avalue) { detach(); Node* y = this->d->end(); @@ -1195,11 +1195,13 @@ Q_INLINE_TEMPLATE typename QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert x = left ? x->leftNode() : x->rightNode(); } Node *z = this->d->createNode(akey, avalue, y, left); - return iterator(z); + return typename QMap<Key, T>::iterator(z); } +#ifndef Q_CLANG_QDOC template <class Key, class T> -typename QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(const_iterator pos, const Key &akey, const T &avalue) +typename QMap<Key, T>::iterator QMultiMap<Key, T>::insert(typename QMap<Key, T>::const_iterator pos, + const Key &akey, const T &avalue) { if (this->d->ref.isShared()) return insert(akey, avalue); @@ -1216,7 +1218,7 @@ typename QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(const_iterator po if (!qMapLessThanKey(n->key, akey)) return insert(akey, avalue); // ignore hint Node *z = this->d->createNode(akey, avalue, n, false); // insert right most - return iterator(z); + return typename QMap<Key, T>::iterator(z); } return insert(akey, avalue); } else { @@ -1229,7 +1231,7 @@ typename QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(const_iterator po if (pos == this->constBegin()) { // There is no previous value (insert left most) Node *z = this->d->createNode(akey, avalue, this->begin().i, true); - return iterator(z); + return typename QMap<Key, T>::iterator(z); } else { Node *prev = const_cast<Node*>(pos.i->previousNode()); if (!qMapLessThanKey(prev->key, akey)) @@ -1238,11 +1240,11 @@ typename QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(const_iterator po // Hint is ok - do insert if (prev->right == nullptr) { Node *z = this->d->createNode(akey, avalue, prev, false); - return iterator(z); + return typename QMap<Key, T>::iterator(z); } if (next->left == nullptr) { Node *z = this->d->createNode(akey, avalue, next, true); - return iterator(z); + return typename QMap<Key, T>::iterator(z); } Q_ASSERT(false); // We should have prev->right == nullptr or next->left == nullptr. return insert(akey, avalue); @@ -1254,14 +1256,15 @@ template <class Key, class T> Q_INLINE_TEMPLATE QMultiMap<Key, T> &QMultiMap<Key, T>::unite(const QMultiMap<Key, T> &other) { QMultiMap<Key, T> copy(other); - const_iterator it = copy.constEnd(); - const const_iterator b = copy.constBegin(); + typename QMap<Key, T>::const_iterator it = copy.constEnd(); + const typename QMap<Key, T>::const_iterator b = copy.constBegin(); while (it != b) { --it; insert(it.key(), it.value()); } return *this; } +#endif // Q_CLANG_QDOC template <class Key, class T> Q_INLINE_TEMPLATE bool QMultiMap<Key, T>::contains(const Key &key, const T &value) const @@ -1293,8 +1296,8 @@ Q_INLINE_TEMPLATE int QMultiMap<Key, T>::count(const Key &akey) const QMultiMap::Node *lastNode; this->d->nodeRange(akey, &firstNode, &lastNode); - const_iterator ci_first(firstNode); - const const_iterator ci_last(lastNode); + typename QMap<Key, T>::const_iterator ci_first(firstNode); + const typename QMap<Key, T>::const_iterator ci_last(lastNode); int cnt = 0; while (ci_first != ci_last) { ++cnt; diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index a0e9abe0ae..d530e4358e 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -903,7 +903,7 @@ */ /*! - template <typename T, int Prealloc> uint qHash(const QVarLengthArray<T, Prealloc> &key, uint seed = 0) + \fn template <typename T, int Prealloc> uint qHash(const QVarLengthArray<T, Prealloc> &key, uint seed = 0) \relates QVarLengthArray \since 5.14 |