Changing cursor position in all boundaries

Merge-request: 1242
Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com>
(cherry picked from commit 97c59df43d821e8e1784749e72f8ee7f90d46da2)

Change-Id: Iccb872281a443e57ff3e492911490a8d7495bbdc
Reviewed-on: http://codereview.qt.nokia.com/3004
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
This commit is contained in:
José Millán Soto 2011-06-06 15:03:09 +02:00 committed by Qt by Nokia
parent d6d3a32a68
commit 5622e32ac9
2 changed files with 9 additions and 1 deletions

View File

@ -1435,9 +1435,9 @@ QString QAccessibleTextEdit::textAtOffset(int offset, BoundaryType boundaryType,
if (offset >= characterCount())
return QString();
cursor.setPosition(offset);
switch (boundaryType) {
case CharBoundary:
cursor.setPosition(offset);
*startOffset = cursor.position();
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
*endOffset = cursor.position();

View File

@ -1679,6 +1679,8 @@ void tst_QAccessibility::textEditTest()
{
{
QTextEdit edit;
int startOffset;
int endOffset;
QString text = "hello world\nhow are you today?\n";
edit.setText(text);
edit.show();
@ -1688,6 +1690,12 @@ void tst_QAccessibility::textEditTest()
QCOMPARE(iface->childCount(), 6);
QCOMPARE(iface->text(QAccessible::Value, 4), QString("hello world"));
QCOMPARE(iface->text(QAccessible::Value, 5), QString("how are you today?"));
QCOMPARE(iface->textInterface()->textAtOffset(8, QAccessible2::WordBoundary, &startOffset, &endOffset), QString("world"));
QCOMPARE(startOffset, 6);
QCOMPARE(endOffset, 11);
QCOMPARE(iface->textInterface()->textAtOffset(14, QAccessible2::LineBoundary, &startOffset, &endOffset), QString("how are you today?"));
QCOMPARE(startOffset, 12);
QCOMPARE(endOffset, 30);
QCOMPARE(iface->text(QAccessible::Value, 6), QString());
QCOMPARE(iface->textInterface()->characterCount(), 31);
QFontMetrics fm(edit.font());