summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Millán Soto <fid@gpul.org>2011-06-03 18:44:37 (GMT)
committerFrederik Gladhorn <frederik.gladhorn@nokia.com>2011-06-10 09:09:08 (GMT)
commit731d843b52b0a0bc387c50c2af37a71f87804f4d (patch)
treed8e8d8198f9f85d26cab47f707d93c3acd6a9bcf
parent13d438ef43a3cb2a90acfaa5304cba34b31fb627 (diff)
downloadQt-731d843b52b0a0bc387c50c2af37a71f87804f4d.zip
Qt-731d843b52b0a0bc387c50c2af37a71f87804f4d.tar.gz
Qt-731d843b52b0a0bc387c50c2af37a71f87804f4d.tar.bz2
Check validator when changing text using accessibility functions.
Reviewed-by: Frederik Gladhorn
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.cpp9
-rw-r--r--tests/auto/qaccessibility/tst_qaccessibility.cpp6
2 files changed, 14 insertions, 1 deletions
diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp
index aa64630..ac40aef 100644
--- a/src/plugins/accessible/widgets/simplewidgets.cpp
+++ b/src/plugins/accessible/widgets/simplewidgets.cpp
@@ -703,7 +703,14 @@ void QAccessibleLineEdit::setText(Text t, int control, const QString &text)
QAccessibleWidgetEx::setText(t, control, text);
return;
}
- lineEdit()->setText(text);
+
+ QString newText = text;
+ if (lineEdit()->validator()) {
+ int pos = 0;
+ if (lineEdit()->validator()->validate(newText, pos) != QValidator::Acceptable)
+ return;
+ }
+ lineEdit()->setText(newText);
}
/*! \reimp */
diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp
index 7ff1a08..235449b 100644
--- a/tests/auto/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp
@@ -3190,6 +3190,12 @@ void tst_QAccessibility::lineEditTest()
QTestAccessibility::clearEvents();
le2->setFocus(Qt::TabFocusReason);
QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le2, 0, QAccessible::Focus)));
+
+ le->setText(QLatin1String("500"));
+ le->setValidator(new QIntValidator());
+ iface->setText(QAccessible::Value, 0, QLatin1String("This text is not a number"));
+ QCOMPARE(le->text(), QLatin1String("500"));
+
delete iface;
delete le;
delete le2;