diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-07-12 10:46:14 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-16 11:44:15 +0000 |
commit | b953b7440f3176d6723d4b91e3c229cf079a753e (patch) | |
tree | a065e509c089393315182aa9d3af714ad3c07de7 | |
parent | 0be6cc1fa34c75aab8fec33c146023c67b2304e6 (diff) |
Change QCollator's default locale to QLocale().collation()
This replaces QLocale::system().collation(), which left client code
with no way to change this default. Since QLocale's default is the
system locale initially, the old behavior is retained until the first
call to QLocale;:setDefault(). Addition of a separate collation locale
in 5.14 changed from using the default locale to using the system's
collation locale; the present change restores the ability to override
this.
[ChangeLog][QtCore][QCollator] The default locale used by QCollator is
now the collation locale of the default QLocale. This restores the
ability (lost at 5.14) to control the locale used by
QString::localeAwareCompare(), while retaining the use of a collation
locale when the default is the system locale.
Task-number: QTBUG-95050
Change-Id: I232772bb8f23fffd74573174de70ef2deae372a9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 973ca1fac680d8c593645058fae3fe7c84a7fa16)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/corelib/text/qcollator.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/text/qcollator.cpp b/src/corelib/text/qcollator.cpp index b6c9f7680a..425bfc82ff 100644 --- a/src/corelib/text/qcollator.cpp +++ b/src/corelib/text/qcollator.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Copyright (C) 2013 Aleix Pol Gonzalez <aleixpol@kde.org> ** Contact: https://www.qt.io/licensing/ ** @@ -77,12 +77,16 @@ QT_BEGIN_NAMESPACE /*! \since 5.13 - Constructs a QCollator using the system's default collation locale. + Constructs a QCollator using the default locale's collation locale. - \sa setLocale(), QLocale::collation() + The system locale, when used as default locale, may have a collation locale + other than itself (e.g. on Unix, if LC_COLLATE is set differently to LANG in + the environment). All other locales are their own collation locales. + + \sa setLocale(), QLocale::collation(), QLocale::setDefault() */ QCollator::QCollator() - : d(new QCollatorPrivate(QLocale::system().collation())) + : d(new QCollatorPrivate(QLocale().collation())) { d->init(); } |