aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextinput.cpp
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-01-19 15:53:20 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-25 10:57:36 +0100
commit8df8bc5062bf5848a616792c79dddd1626014072 (patch)
treed3b5808fb8cbbd420c97d79a6756a4c7a28a7324 /src/quick/items/qquicktextinput.cpp
parent100f7ee211e27b8f8dd647ca76210293c7962adc (diff)
Add a locale property to IntValidator and DoubleValidator.
Allow the locale used for interpreting numbers to be changed from the application default. Task-number: QTBUG-23713 Change-Id: I28463485c86236fb2586eeb703ec4b051405c5a8 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/quick/items/qquicktextinput.cpp')
-rw-r--r--src/quick/items/qquicktextinput.cpp80
1 files changed, 76 insertions, 4 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 237db3537d..08892e1922 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -823,11 +823,48 @@ void QQuickTextInput::setAutoScroll(bool b)
This element provides a validator for integer values.
- IntValidator uses the \l {QLocale::setDefault()}{default locale} to interpret the number and
- will accept locale specific digits, group separators, and positive and negative signs. In
- addition, IntValidator is always guaranteed to accept a number formatted according to the "C"
- locale.
+ If no \l locale is set IntValidator uses the \l {QLocale::setDefault()}{default locale} to
+ interpret the number and will accept locale specific digits, group separators, and positive
+ and negative signs. In addition, IntValidator is always guaranteed to accept a number
+ formatted according to the "C" locale.
*/
+
+
+QQuickIntValidator::QQuickIntValidator(QObject *parent)
+ : QIntValidator(parent)
+{
+}
+
+/*!
+ \qmlproperty string QtQuick2::IntValidator::locale
+
+ This property holds the name of the locale used to interpret the number.
+
+ \sa QML:Qt::locale()
+*/
+
+QString QQuickIntValidator::localeName() const
+{
+ return locale().name();
+}
+
+void QQuickIntValidator::setLocaleName(const QString &name)
+{
+ if (locale().name() != name) {
+ setLocale(QLocale(name));
+ emit localeNameChanged();
+ }
+}
+
+void QQuickIntValidator::resetLocaleName()
+{
+ QLocale defaultLocale;
+ if (locale() != defaultLocale) {
+ setLocale(defaultLocale);
+ emit localeNameChanged();
+ }
+}
+
/*!
\qmlproperty int QtQuick2::IntValidator::top
@@ -866,6 +903,41 @@ void QQuickTextInput::setAutoScroll(bool b)
value may yet become valid by changing the exponent.
*/
+QQuickDoubleValidator::QQuickDoubleValidator(QObject *parent)
+ : QDoubleValidator(parent)
+{
+}
+
+/*!
+ \qmlproperty string QtQuick2::DoubleValidator::locale
+
+ This property holds the name of the locale used to interpret the number.
+
+ \sa QML:Qt::locale()
+*/
+
+QString QQuickDoubleValidator::localeName() const
+{
+ return locale().name();
+}
+
+void QQuickDoubleValidator::setLocaleName(const QString &name)
+{
+ if (locale().name() != name) {
+ setLocale(QLocale(name));
+ emit localeNameChanged();
+ }
+}
+
+void QQuickDoubleValidator::resetLocaleName()
+{
+ QLocale defaultLocale;
+ if (locale() != defaultLocale) {
+ setLocale(defaultLocale);
+ emit localeNameChanged();
+ }
+}
+
/*!
\qmlproperty real QtQuick2::DoubleValidator::top