src/gui/widgets/qvalidator.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
--- a/src/gui/widgets/qvalidator.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/gui/widgets/qvalidator.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -400,8 +400,10 @@
     qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow);
     if (overflow || !ok)
         return Invalid;
-    if (entered >= b && entered <= t)
-        return Acceptable;
+    if (entered >= b && entered <= t) {
+        locale().toInt(input, &ok);
+        return ok ? Acceptable : Intermediate;
+    }
 
     if (entered >= 0) {
         // the -entered < b condition is necessary to allow people to type
@@ -412,6 +414,20 @@
     }
 }
 
+/*! \reimp */
+void QIntValidator::fixup(QString &input) const
+{
+    QByteArray buff;
+    if (!locale().d()->validateChars(input, QLocalePrivate::IntegerMode, &buff)) {
+        QLocale cl(QLocale::C);
+        if (!cl.d()->validateChars(input, QLocalePrivate::IntegerMode, &buff))
+            return;
+    }
+    bool ok, overflow;
+    qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow);
+    if (ok && !overflow)
+        input = locale().toString(entered);
+}
 
 /*!
     Sets the range of the validator to only accept integers between \a
@@ -507,7 +523,7 @@
 
     In addition, QDoubleValidator is always guaranteed to accept a number
     formatted according to the "C" locale. QDoubleValidator will not accept
-    numbers with thousand-seperators.
+    numbers with thousand-separators.
 
     \sa QIntValidator, QRegExpValidator, {Line Edits Example}
 */