From 58f5ec35f108bca01489124e74e96018fd937ed4 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 21 Feb 2023 18:24:30 +0100 Subject: [PATCH] Doc fix in QIntValidator::validate() and comment on a test The doc said positive values for a negative range were intermediate but the code actually rejects them if the value has an overt plus sign, so make clear that intermediate is only for the case without a sign. Incidentally comment on a test where it might not have been obvious to the reader that a space is the locale's digit-grouping chracter. Pick-to: 6.5 6.5.0 Change-Id: I3edab74fe8c2cbe8448c0e523676f1fd0d0d8a9f Reviewed-by: Volker Hilsheimer --- src/gui/util/qvalidator.cpp | 12 ++++++------ .../gui/util/qintvalidator/tst_qintvalidator.cpp | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 84f40a6226..8b0f9ac321 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -331,12 +331,12 @@ QIntValidator::~QIntValidator() or is a prefix of an integer in the valid range, returns \l Intermediate. Otherwise, returns \l Invalid. - If the valid range consists of just positive integers (e.g., 32 to 100) - and \a input is a negative integer, then Invalid is returned. (On the other - hand, if the range consists of negative integers (e.g., -100 to -32) and - \a input is a positive integer, then Intermediate is returned, because - the user might be just about to type the minus (especially for right-to-left - languages). + If the valid range consists of just positive integers (e.g., 32 to 100) and + \a input is a negative integer, then Invalid is returned. (On the other + hand, if the range consists of negative integers (e.g., -100 to -32) and \a + input is a positive integer without leading plus sign, then Intermediate is + returned, because the user might be just about to type the minus (especially + for right-to-left languages). Similarly, if the valid range is between 46 and 53, then 41 and 59 will be evaluated as \l Intermediate, as otherwise the user wouldn't be able to diff --git a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp index ec4e3930ec..5b0f30cf9a 100644 --- a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp +++ b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp @@ -165,6 +165,7 @@ void tst_QIntValidator::validateFrench() QIntValidator validator(-2000, 2000, 0); validator.setLocale(QLocale::French); int i; + // Grouping separator is a narrow no-break space; QLocale accepts a space as it. QString s = QLatin1String("1 "); QCOMPARE(validator.validate(s, i), QValidator::Acceptable); validator.fixup(s);