From 235ac95520a0fc2c822dedce7358e3c64a764255 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 2 Oct 2018 17:25:17 +0200 Subject: Improve the default selection of locale for QCollator QCollator was using the default-constructed QLocale() as its default; this locale's default was the system locale; however, that didn't pay any attention to system settings for collation such as Unix's environment variable LC_COLLATE or the MS-Win LOCALE_SSORTLOCALE configuration option. Teach the system locale back-ends to look up their relevant settings, add QLocale::collation() as a channel via which to access that and change no-parameter construction of QCollator to a separate implementation (rather than the constructor taking QLocale having a default) using it. [ChangeLog][QtCore][QLocale] The system locale now knows what to use for collation, QLocale::system().collation(). [ChangeLog][QtCore][QCollator] The default QCollator now uses the system's collation locale, rather than the system locale itself. Fixes: QTBUG-58621 Change-Id: I90f86621541385330315d1f9d6a4b982bdcea9d5 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale_win.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/corelib/tools/qlocale_win.cpp') diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index ebc4430046..dc904ad02d 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -120,6 +120,7 @@ struct QSystemLocalePrivate QVariant toString(const QTime &, QLocale::FormatType); QVariant toString(const QDateTime &, QLocale::FormatType); QVariant measurementSystem(); + QVariant collation(); QVariant amText(); QVariant pmText(); QVariant firstDayOfWeek(); @@ -455,6 +456,11 @@ QVariant QSystemLocalePrivate::measurementSystem() return QLocale::MetricSystem; } +QVariant QSystemLocalePrivate::collation() +{ + return getLocaleInfo(LOCALE_SSORTLOCALE); +} + QVariant QSystemLocalePrivate::amText() { wchar_t output[15]; // maximum length including terminating zero character for Win2003+ @@ -808,6 +814,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const return QVariant(QLocale::AnyScript); case MeasurementSystem: return d->measurementSystem(); + case Collation: + return d->collation(); case AMText: return d->amText(); case PMText: -- cgit v1.2.3