aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2011-11-15 18:17:29 +0200
committerQt by Nokia <qt-info@nokia.com>2011-11-24 13:50:37 +0100
commit38276a3d5348423a222c0fc794a28ab361d97e78 (patch)
tree30b5d3898ef2f2d052e6f65a10235a6cea756bb4
parentb7be92e8ad22481c79f87e3741f85609c2612be7 (diff)
TextInput elements not to have tentative commit in inputMethodQuery
Tentative commit should not be part of surrounding text, it's already a property of the input method. Change-Id: I64aec9763fb20770b6729f7f59dcbe23cf5a6718 Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--src/declarative/items/qquicktextinput.cpp2
-rw-r--r--src/qtquick1/graphicsitems/qdeclarativetextinput.cpp2
-rw-r--r--tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp22
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp22
4 files changed, 46 insertions, 2 deletions
diff --git a/src/declarative/items/qquicktextinput.cpp b/src/declarative/items/qquicktextinput.cpp
index 218a313a17..c9469babdb 100644
--- a/src/declarative/items/qquicktextinput.cpp
+++ b/src/declarative/items/qquicktextinput.cpp
@@ -1355,7 +1355,7 @@ QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property) const
&& !d->control->passwordEchoEditing()) {
return QVariant(displayText());
} else {
- return QVariant(text());
+ return QVariant(d->control->realText());
}
case Qt::ImCurrentSelection:
return QVariant(selectedText());
diff --git a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp
index 009c72a4cd..04aa06d7c8 100644
--- a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp
@@ -1396,7 +1396,7 @@ QVariant QDeclarative1TextInput::inputMethodQuery(Qt::InputMethodQuery property)
&& !d->control->passwordEchoEditing())
return QVariant(displayText());
else
- return QVariant(text());
+ return QVariant(d->control->realText());
case Qt::ImCurrentSelection:
return QVariant(selectedText());
case Qt::ImMaximumTextLength:
diff --git a/tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp
index 7c794d6e97..147208ea5e 100644
--- a/tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp
@@ -1565,6 +1565,28 @@ void tst_qquicktextinput::inputMethods()
QGuiApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &event);
QCOMPARE(input->text(), QString("Our Goodbye world!"));
QCOMPARE(input->cursorPosition(), 7);
+
+ // test that basic tentative commit gets to text property on preedit state
+ input->setText("");
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent preeditEvent("test", attributes);
+ preeditEvent.setTentativeCommitString("test");
+ QApplication::sendEvent(input, &preeditEvent);
+ QCOMPARE(input->text(), QString("test"));
+
+ // tentative commit not allowed present in surrounding text
+ QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText);
+ QApplication::sendEvent(input, &queryEvent);
+ QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString(""));
+
+ // if text with tentative commit does not validate, not allowed to be part of text property
+ input->setText(""); // ensure input state is reset
+ QValidator *validator = new QIntValidator(0, 100);
+ input->setValidator(validator);
+ QApplication::sendEvent(input, &preeditEvent);
+ QCOMPARE(input->text(), QString(""));
+ input->setValidator(0);
+ delete validator;
}
/*
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 38e01ebe47..c84de1260e 100644
--- a/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -1565,6 +1565,28 @@ void tst_qdeclarativetextinput::inputMethods()
QCOMPARE(input->text(), QString("Our Goodbye world!"));
QCOMPARE(input->cursorPosition(), 7);
+ // test that basic tentative commit gets to text property on preedit state
+ input->setText("");
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent preeditEvent("test", attributes);
+ preeditEvent.setTentativeCommitString("test");
+ QApplication::sendEvent(canvas, &preeditEvent);
+ QCOMPARE(input->text(), QString("test"));
+
+ // tentative commit not allowed present in surrounding text
+ QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText);
+ QApplication::sendEvent(canvas, &queryEvent);
+ QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString(""));
+
+ // if text with tentative commit does not validate, not allowed to be part of text property
+ input->setText(""); // ensure input state is reset
+ QValidator *validator = new QIntValidator(0, 100);
+ input->setValidator(validator);
+ QApplication::sendEvent(canvas, &preeditEvent);
+ QCOMPARE(input->text(), QString(""));
+ input->setValidator(0);
+ delete validator;
+
delete canvas;
}