From 274b6f3c1323a237d04520daacb7212c89d1cb13 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 17 Feb 2020 14:42:33 +0100 Subject: Silence deprecation warnings on implementation of deprecated formats Change-Id: I3abb36e27e96033b4eb44802c28e0a6ba8250ce5 Reviewed-by: Friedemann Kleint --- src/corelib/time/qdatetime.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/corelib/time/qdatetime.cpp') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 773280ad68..3ae733cf01 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1178,6 +1178,7 @@ QString QDate::toString(Qt::DateFormat format, QCalendar cal) 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, cal); @@ -1188,6 +1189,7 @@ 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); +QT_WARNING_POP #endif // 5.15 case Qt::RFC2822Date: return QLocale::c().toString(*this, QStringView(u"dd MMM yyyy"), cal); @@ -1643,6 +1645,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 +1656,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 +2037,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 +2048,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 +2440,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 +2451,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; @@ -4340,6 +4348,7 @@ QString QDateTime::toString(Qt::DateFormat format, QCalendar cal) 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, cal); @@ -4350,6 +4359,7 @@ QString QDateTime::toString(Qt::DateFormat format, QCalendar cal) const return QLocale().toString(*this, QLocale::ShortFormat, cal); case Qt::DefaultLocaleLongDate: return QLocale().toString(*this, QLocale::LongFormat, cal); +QT_WARNING_POP #endif // 5.15 case Qt::RFC2822Date: { buf = QLocale::c().toString(*this, u"dd MMM yyyy hh:mm:ss ", cal); @@ -5228,6 +5238,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 +5249,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); -- cgit v1.2.3 From 336fe172b10eea55eba17c18b8e36b787565346c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 17 Feb 2020 15:09:43 +0100 Subject: Back out of calendar support in Qt::DateFormat methods We're deprecating the locale-specific date-formats, which are the only ones that use the calendar. The QDateTime::toString() variant was new in 5.15, so we can simply remove it again. The QDate one was present in 5.14, so we need to keep it; deprecated it at 5.15 for removal at Qt 6. [ChangeLog][QtCore][QDate] QDate::toString(Qt::DateFormat, QCalendar) no longer takes calendar into account for Qt::TextDate. There was no matching support in QDateTime and the locale-independent formats are intended to be standard, rather than customized to the user. Fixes: QTBUG-82178 Change-Id: I09db8a82ec5a4eab22f197790264fa3a3724e383 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/corelib/time/qdatetime.cpp | 69 +++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 27 deletions(-) (limited to 'src/corelib/time/qdatetime.cpp') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 3ae733cf01..45c6ecbf23 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,12 @@ 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. + represent the date; it defaults to Gregorian and only affects the + locale-specific formats. 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 +1167,43 @@ 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: @@ -1190,18 +1216,18 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED case Qt::DefaultLocaleLongDate: return QLocale().toString(*this, QLocale::LongFormat, cal); QT_WARNING_POP -#endif // 5.15 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 @@ -4287,14 +4313,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 @@ -4336,11 +4357,6 @@ 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()) @@ -4351,25 +4367,25 @@ QString QDateTime::toString(Qt::DateFormat format, QCalendar cal) const 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 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)); @@ -4391,7 +4407,6 @@ QT_WARNING_POP } case Qt::ISODate: case Qt::ISODateWithMs: { - // No calendar dependence const QPair p = getDateTime(d); buf = toStringIsoDate(p.first); if (buf.isEmpty()) -- cgit v1.2.3 From 95aec76e3169d37d4d6ba908d8a96ce578cb45e2 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 14 Feb 2020 17:45:45 +0100 Subject: Doc: Fix documentation warnings for Qt Core - QCborError: Classes cannot relate to header files; use \inheaderfile instead and link to the class from header file documentation. - QRecursiveMutex: QDoc doesn't allow shared documentation comments for duplicating \fn docs between the base and deriving classes. Remove the sharing, the function documentation is available under 'All Members' doc for QRecursiveMutex. - QMultiMap: unite() and one overload of insert() were not recognized because their definitions in the same header file interfered with QDoc - use Q_CLANG_QDOC macro to comment them out, and tag \fn comments to ensure that the function documentation is matched. Change-Id: Ic96869904a72d92453e4ffa6901000147571969b Reviewed-by: Paul Wicking --- src/corelib/time/qdatetime.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/corelib/time/qdatetime.cpp') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 45c6ecbf23..86c08058fc 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1127,9 +1127,7 @@ static QString toStringIsoDate(QDate date) \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 and only affects the - locale-specific formats. + 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 @@ -1236,7 +1234,7 @@ QT_WARNING_POP \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: @@ -4437,7 +4435,7 @@ QT_WARNING_POP \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. -- cgit v1.2.3