[Development] QLocale work
John Layt
jlayt at kde.org
Wed Jan 18 01:47:31 CET 2012
Looking at the knock-on effects code-wise to other classes in QtBase of
changing QLocale to use ICU. Behavioural changes are not covered.
tl;dr?
* If we can port the QLocalePrivate number routines to call ICU instead of
their current implementations, the rest of Qt will "just work", except
QTextStream and QSpinBox which will need attention.
* We may eventually want to clean up the QLocalePrivate number API to make
them public.
* QString will need a decision on the behaviour of toInt() / toLong() / etc
using the Default Locale.
* QDateTimeParser will be a problem in QDateTimeEdit, so should probably be
renamed and moved to widgets.
In detail.
QLocale has friends which use QLocalePrivate methods and enums to perform
number parse/format.
* QString
* QByteArray
* QIntValidator
* QDoubleValidatorPrivate
* QTextStream
* QTextStreamPrivate
Side question for later: If the private methods are so useful, then why not
make the API public and remove friends?
Other classes call public QLocale methods for number symbols like
decimalPoint() and negativeSign() to use in their own custom char-at-a-time
parse/format routines which will cause an issue as ICU / CLDR define these
symbols as strings and not chars.
* QTextStream
* QSpinBox
The private QDateTimeParser class is also used outside QLocale. All date/time
formatting is done using public QDateTime/QLocale api.
Looking at them:
QString - Well behaved, only uses the QLocalePrivate number methods and enums.
Mostly only uses C Locale, but does use Default Locale first in toInt() /
toLong() / etc methods, and in arg() methods if %L override used.
QByteArray - Very well behaved, only uses the QLocalePrivate number methods
and enums, only uses C Locale.
QIntValidator & QDoubleValidator - Very well behaved, only uses the
QLocalePrivate number methods and enums. You can set/get locale to use,
defaults to Default Locale but falls back to C Locale.
QTextStream - Uses QLocalePrivate number methods and enums for format, but has
bespoke parsers using QLocale number symbol methods. You can set/get locale
to use, defaults to C Locale. Thsi needs an expert.
QSpinBox - Has bespoke validating parser using QLocale number symbol methods.
Could probably be replaced by calls to QLocalePrivate.
QDateTimeParser is a private class used for basic date/time parsing in QLocale
and QDateTime, but as a validating parser in QDateTimeEdit where it is very
deeply embedded. It only uses the Default Locale unless you sub-class it.
QLocale and QDateTime can easily port to use ICU (QDateTime probably using C
Locale) but QDateTimeEdit still needs QDateTimeParser. It's not a great class
or widget, so I'd suggest doing the minimal work required to port to ICU,
rename it QDateTimeEditParser and move it to Widgets.
John.
More information about the Development
mailing list