From d06cff08598129c85952f4d45a382d300cb4ac65 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 26 Feb 2024 16:18:46 +0100 Subject: [PATCH] Tidy up a bit in QTZP_p.h The ICU backend was using its base's displayName() but none of the other backends did so; have them do the same. This saves the need for a QTZP:: suffix one one call to the UTC backend's displayName(). The order of backends in the header is a jumbled mess and the set of could surely be reduced to a #if...#elif...#endif chain, especially once TZ's dependence on ICU is sorted out, so add a TODO about that. Change-Id: I6d6daf3f899f7c79538a7d16bc94b0610f1a4c28 Reviewed-by: Thiago Macieira --- src/corelib/time/qtimezone.cpp | 2 +- src/corelib/time/qtimezoneprivate_p.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp index 558cb53a08d..3a68277a6c8 100644 --- a/src/corelib/time/qtimezone.cpp +++ b/src/corelib/time/qtimezone.cpp @@ -908,7 +908,7 @@ QString QTimeZone::displayName(const QDateTime &atDateTime, NameType nameType, return systemTimeZone().displayName(atDateTime, nameType, locale); case Qt::UTC: case Qt::OffsetFromUTC: - return QUtcTimeZonePrivate(d.s.offset).QTimeZonePrivate::displayName( + return QUtcTimeZonePrivate(d.s.offset).displayName( atDateTime.toMSecsSinceEpoch(), nameType, locale); case Qt::TimeZone: Q_UNREACHABLE(); diff --git a/src/corelib/time/qtimezoneprivate_p.h b/src/corelib/time/qtimezoneprivate_p.h index 4ad51f44e7b..506acaa1f72 100644 --- a/src/corelib/time/qtimezoneprivate_p.h +++ b/src/corelib/time/qtimezoneprivate_p.h @@ -183,6 +183,7 @@ public: QLocale::Territory territory() const override; QString comment() const override; + using QTimeZonePrivate::displayName; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, const QLocale &locale) const override; @@ -213,6 +214,9 @@ private: int m_offsetFromUtc; }; +// TODO: shuffle (almost reverse) order of and rework #if-ery here to use #elif +// and match the #if-ery in each of QTZ's newBackendTimeZone() cascades for +// backend selection. #if QT_CONFIG(icu) class Q_AUTOTEST_EXPORT QIcuTimeZonePrivate final : public QTimeZonePrivate { @@ -255,7 +259,7 @@ private: UCalendar *m_ucal; }; -#endif +#endif // ICU #if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) struct QTzTransitionTime @@ -303,6 +307,7 @@ public: QLocale::Territory territory() const override; QString comment() const override; + using QTimeZonePrivate::displayName; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, const QLocale &locale) const override; @@ -361,6 +366,7 @@ public: QString comment() const override; + using QTimeZonePrivate::displayName; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, const QLocale &locale) const override; QString abbreviation(qint64 atMSecsSinceEpoch) const override; @@ -414,6 +420,7 @@ public: QString comment() const override; + using QTimeZonePrivate::displayName; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, const QLocale &locale) const override; QString abbreviation(qint64 atMSecsSinceEpoch) const override; @@ -462,6 +469,7 @@ public: QAndroidTimeZonePrivate *clone() const override; + using QTimeZonePrivate::displayName; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, const QLocale &locale) const override; QString abbreviation(qint64 atMSecsSinceEpoch) const override;