diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-10-23 14:31:25 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-11-07 06:24:52 +0100 |
commit | cfac358fa3cfe7056f9d71b7cdb8e557dd711810 (patch) | |
tree | 5224481606481ace9495af9da7c71cb238e589a2 | |
parent | 9a1a15b42fb526ad4f80944afb7761bfff1b5c9d (diff) |
Turn QLocale's operator==() and operator!=() into hidden friends
Update docs to match. Add note on the conditions for equality.
Change-Id: I973b7a5dae3fae2e62f8a0d1db1f3115d24bee8b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/corelib/text/qlocale.cpp | 12 | ||||
-rw-r--r-- | src/corelib/text/qlocale.h | 7 | ||||
-rw-r--r-- | src/corelib/text/qlocale.qdoc | 24 |
3 files changed, 28 insertions, 15 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 260af879db..1ac7742593 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -1060,14 +1060,14 @@ QLocale &QLocale::operator=(const QLocale &other) return *this; } -bool QLocale::operator==(const QLocale &other) const -{ - return d->m_data == other.d->m_data && d->m_numberOptions == other.d->m_numberOptions; -} +/*! + \internal + Equality comparison. +*/ -bool QLocale::operator!=(const QLocale &other) const +bool QLocale::equals(const QLocale &other) const { - return d->m_data != other.d->m_data || d->m_numberOptions != other.d->m_numberOptions; + return d->m_data == other.d->m_data && d->m_numberOptions == other.d->m_numberOptions; } /*! diff --git a/src/corelib/text/qlocale.h b/src/corelib/text/qlocale.h index 269a8b8039..1ba0e3d79f 100644 --- a/src/corelib/text/qlocale.h +++ b/src/corelib/text/qlocale.h @@ -1028,9 +1028,6 @@ public: QStringList uiLanguages() const; - bool operator==(const QLocale &other) const; - bool operator!=(const QLocale &other) const; - static QString languageToString(Language language); static QString countryToString(Country country); static QString scriptToString(Script script); @@ -1054,12 +1051,16 @@ public: private: QLocale(QLocalePrivate &dd); + bool equals(const QLocale &other) const; friend class QLocalePrivate; friend class QSystemLocale; friend class QCalendarBackend; friend class QGregorianCalendar; friend Q_CORE_EXPORT size_t qHash(const QLocale &key, size_t seed) noexcept; + friend bool operator==(const QLocale &lhs, const QLocale &rhs) { return lhs.equals(rhs); } + friend bool operator!=(const QLocale &lhs, const QLocale &rhs) { return !lhs.equals(rhs); } + QSharedDataPointer<QLocalePrivate> d; }; Q_DECLARE_SHARED(QLocale) diff --git a/src/corelib/text/qlocale.qdoc b/src/corelib/text/qlocale.qdoc index 30c5ec6493..42f2e85264 100644 --- a/src/corelib/text/qlocale.qdoc +++ b/src/corelib/text/qlocale.qdoc @@ -979,17 +979,29 @@ /*! - \fn bool QLocale::operator==(const QLocale &other) const + \fn bool QLocale::operator==(const QLocale &lhs, const QLocale &rhs) - Returns \c true if the QLocale object is the same as the \a other - locale specified; otherwise returns \c false. + Returns \c true if the two QLocale objects, \a lhs and \a rhs, are the same; + otherwise returns \c false. + + \note The system locale is not equal to the QLocale object constructed from + its language(), script() and country(), even if the two agree in all data + fields. Nor are two locales with different number options equal. + + \sa operator!=(), setNumberOptions() */ /*! - \fn bool QLocale::operator!=(const QLocale &other) const + \fn bool QLocale::operator!=(const QLocale &lhs, const QLocale &rhs) + + Returns \c true if the two QLocale objects, \a lhs and \a rhs, differ; + otherwise returns \c false. + + \note The system locale is not equal to the QLocale object constructed from + its language(), script() and country(), even if the two agree in all data + fields. Nor are two locales with different number options equal. - Returns \c true if the QLocale object is not the same as the \a other - locale specified; otherwise returns \c false. + \sa operator==(), setNumberOptions() */ /*! |