From 6ef7bba3758044d95f9a41603cd07b7636e63b44 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 4 Nov 2024 17:48:55 +0100 Subject: [PATCH] Clean up and clarify QLocale docs, especially around number options Only the numberOptions() getter mentioned that OmitGroupSeparator is enabled by default for the C locale. Make this clear also in the \enum documentation and clarify some poorly-phrased descriptions of other options. Reflow the getter and setter docs. Change-Id: I1bea1065bd85ba4a6944b110909217c364809497 Reviewed-by: Thiago Macieira --- src/corelib/text/qlocale.cpp | 10 ++++------ src/corelib/text/qlocale.qdoc | 33 +++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index ba5b1eacfd3..01e838f76df 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -1271,8 +1271,7 @@ size_t qHash(const QLocale &key, size_t seed) noexcept /*! \since 4.2 - Sets the \a options related to number conversions for this - QLocale instance. + Sets the \a options related to number conversions for this QLocale instance. \sa numberOptions(), FloatingPointPrecisionOption */ @@ -1284,11 +1283,10 @@ void QLocale::setNumberOptions(NumberOptions options) /*! \since 4.2 - Returns the options related to number conversions for this - QLocale instance. + Returns the options related to number conversions for this QLocale instance. - By default, no options are set for the standard locales, except - for the "C" locale, which has OmitGroupSeparator set by default. + By default, no options are set for the standard locales, except for the "C" + locale, which has OmitGroupSeparator set by default. \sa setNumberOptions(), toString(), groupSeparator(), FloatingPointPrecisionOption */ diff --git a/src/corelib/text/qlocale.qdoc b/src/corelib/text/qlocale.qdoc index 16d0c86bc74..39534385f82 100644 --- a/src/corelib/text/qlocale.qdoc +++ b/src/corelib/text/qlocale.qdoc @@ -980,12 +980,15 @@ conversions. They can be retrieved with numberOptions() and set with setNumberOptions(). - \value DefaultNumberOptions This option represents the default behavior, with - group separators, with one leading zero in single digit exponents, and - without trailing zeroes after the decimal dot. - \value OmitGroupSeparator If this option is set, the number-to-string functions - will not insert group separators in their return values. The default - is to insert group separators. + \value DefaultNumberOptions This option represents the default behavior for + all locales except the C locale, with group separators, with one + leading zero in single digit exponents, and without trailing zeroes + at the end of the fractional part (when present). + \value OmitGroupSeparator If this option is set, the number-to-string + functions will not break up digits into groups. The C locale sets + this option by default. The default for all other locales is to + break up digits into groups, in the whole-number part of a number, + with group separators. \value RejectGroupSeparator If this option is set, the string-to-number functions will fail if they encounter group separators in their input. The default is to accept numbers containing correctly placed group separators. @@ -997,14 +1000,16 @@ functions will fail if they encounter an exponent padded with zeroes when parsing a floating point number in scientific notation. The default is to accept such padding. - \value IncludeTrailingZeroesAfterDot If this option is set, the number-to-string - functions will pad numbers with zeroes to the requested precision in "g" - or "most concise" mode, even if the number of significant digits is lower - than the requested precision. The default is to omit trailing zeroes. - \value RejectTrailingZeroesAfterDot If this option is set, the string-to-number - functions will fail if they encounter trailing zeroes after the decimal - dot when parsing a number in scientific or decimal representation. The - default is to accept trailing zeroes. + \value IncludeTrailingZeroesAfterDot If this option is set, the + number-to-string functions will pad numbers with zeroes to the + requested precision in "g" or "most concise" mode. The default is to + omit trailing zeroes, which may leave fewer digits in the fractional + part than the precision asked for. + \value RejectTrailingZeroesAfterDot If this option is set, the + string-to-number functions will fail if they encounter trailing + zeroes at the end of the fractional part, when parsing a number in + scientific or decimal representation. The default is to accept + trailing zeroes. \sa setNumberOptions(), numberOptions(), FloatingPointPrecisionOption */