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>
bb10
Edward Welbourne 2020-10-23 14:31:25 +02:00
parent 9a1a15b42f
commit cfac358fa3
3 changed files with 28 additions and 15 deletions

View File

@ -1060,16 +1060,16 @@ QLocale &QLocale::operator=(const QLocale &other)
return *this;
}
bool QLocale::operator==(const QLocale &other) const
/*!
\internal
Equality comparison.
*/
bool QLocale::equals(const QLocale &other) const
{
return d->m_data == other.d->m_data && d->m_numberOptions == other.d->m_numberOptions;
}
bool QLocale::operator!=(const QLocale &other) const
{
return d->m_data != other.d->m_data || d->m_numberOptions != other.d->m_numberOptions;
}
/*!
\fn void QLocale::swap(QLocale &other)
\since 5.6

View File

@ -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)

View File

@ -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 QLocale object is not 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, 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.
\sa operator==(), setNumberOptions()
*/
/*!