diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-10-15 11:27:09 +0300 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-20 11:35:52 +0200 |
commit | 9ed6ff0b1f6fe526978d4132b2e27aa98112900c (patch) | |
tree | 56845a67a6186892b6e7ed6813cb0a84763f7a09 | |
parent | 2b0da5b2799e1157d46f095093f370f2eef9c3ae (diff) |
Fix QDeclarativeTextInput::moveCursorSelection()
by using fixed QTextBoundaryFinder behavior.
Update QDeclarativeTextInput autotests.
Task-number: QTBUG-11365
Task-number: QTBUG-27364
Change-Id: Idda22f6c0974bf29d2ff961ea8d998a68c3d676b
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
3 files changed, 44 insertions, 42 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 4d07f55f..8c13faeb 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1684,8 +1684,8 @@ void QDeclarativeTextInput::moveCursorSelection(int pos, SelectionMode mode) finder.setPosition(anchor); const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons(); - if (anchor < text.length() && (!(reasons & QTextBoundaryFinder::StartWord) - || ((reasons & QTextBoundaryFinder::EndWord) && anchor > cursor))) { + if (anchor < text.length() && (reasons == QTextBoundaryFinder::NotAtBoundary + || (reasons & QTextBoundaryFinder::EndOfItem))) { finder.toPreviousBoundary(); } anchor = finder.position() != -1 ? finder.position() : 0; @@ -1702,8 +1702,8 @@ void QDeclarativeTextInput::moveCursorSelection(int pos, SelectionMode mode) finder.setPosition(anchor); const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons(); - if (anchor > 0 && (!(reasons & QTextBoundaryFinder::EndWord) - || ((reasons & QTextBoundaryFinder::StartWord) && anchor < cursor))) { + if (anchor > 0 && (reasons == QTextBoundaryFinder::NotAtBoundary + || (reasons & QTextBoundaryFinder::StartOfItem))) { finder.toNextBoundary(); } anchor = finder.position() != -1 ? finder.position() : text.length(); diff --git a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro index 83ee832a..ab012ffb 100644 --- a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro +++ b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro @@ -10,5 +10,3 @@ SOURCES += tst_qdeclarativetextinput.cpp DEFINES += SRCDIR=\\\"$$PWD\\\" DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 - -CONFIG += insignificant_test # QTBUG-27364 diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index f418372e..be146d82 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -602,10 +602,12 @@ void tst_qdeclarativetextinput::moveCursorSelection_data() QTest::newRow("jum<()>ped|words") << standard[0] << 23 << 23 << QDeclarativeTextInput::SelectWords << 23 << 23 << true; - QTest::newRow("Hello<(,)> |words") - << standard[2] << 5 << 6 << QDeclarativeTextInput::SelectWords << 5 << 6 << true; - QTest::newRow("Hello<(, )>world|words,ltr") - << standard[2] << 5 << 7 << QDeclarativeTextInput::SelectWords << 5 << 7 << false; + QTest::newRow("<Hello(,)> |words,ltr") + << standard[2] << 5 << 6 << QDeclarativeTextInput::SelectWords << 0 << 6 << false; + QTest::newRow("Hello<(,)> |words,rtl") + << standard[2] << 6 << 5 << QDeclarativeTextInput::SelectWords << 5 << 6 << false; + QTest::newRow("<Hello(, )>world|words,ltr") + << standard[2] << 5 << 7 << QDeclarativeTextInput::SelectWords << 0 << 7 << false; QTest::newRow("Hello<(, )world>|words,rtl") << standard[2] << 7 << 5 << QDeclarativeTextInput::SelectWords << 5 << 12 << false; QTest::newRow("<Hel(lo, )>world|words,ltr") @@ -618,33 +620,35 @@ void tst_qdeclarativetextinput::moveCursorSelection_data() << standard[2] << 5 << 5 << QDeclarativeTextInput::SelectWords << 5 << 5 << true; QTest::newRow("Hello,<()>|words") << standard[2] << 6 << 6 << QDeclarativeTextInput::SelectWords << 6 << 6 << true; - QTest::newRow("Hello<,( )>world|words,ltr") - << standard[2] << 6 << 7 << QDeclarativeTextInput::SelectWords << 5 << 7 << false; + QTest::newRow("Hello,<( )>world|words,ltr") + << standard[2] << 6 << 7 << QDeclarativeTextInput::SelectWords << 6 << 7 << false; QTest::newRow("Hello,<( )world>|words,rtl") << standard[2] << 7 << 6 << QDeclarativeTextInput::SelectWords << 6 << 12 << false; - QTest::newRow("Hello<,( world)>|words,ltr") - << standard[2] << 6 << 12 << QDeclarativeTextInput::SelectWords << 5 << 12 << false; - QTest::newRow("Hello,<( world)>|words,rtl") - << standard[2] << 12 << 6 << QDeclarativeTextInput::SelectWords << 6 << 12 << false; - QTest::newRow("Hello<,( world!)>|words,ltr") - << standard[2] << 6 << 13 << QDeclarativeTextInput::SelectWords << 5 << 13 << false; - QTest::newRow("Hello,<( world!)>|words,rtl") - << standard[2] << 13 << 6 << QDeclarativeTextInput::SelectWords << 6 << 13 << false; - QTest::newRow("Hello<(, world!)>|words") - << standard[2] << 5 << 13 << QDeclarativeTextInput::SelectWords << 5 << 13 << true; - QTest::newRow("world<(!)>|words") - << standard[2] << 12 << 13 << QDeclarativeTextInput::SelectWords << 12 << 13 << true; + QTest::newRow("Hello,<( world)>|words") + << standard[2] << 6 << 12 << QDeclarativeTextInput::SelectWords << 6 << 12 << true; + QTest::newRow("Hello,<( world!)>|words") + << standard[2] << 6 << 13 << QDeclarativeTextInput::SelectWords << 6 << 13 << true; + QTest::newRow("<Hello(, world!)>|words,ltr") + << standard[2] << 5 << 13 << QDeclarativeTextInput::SelectWords << 0 << 13 << false; + QTest::newRow("Hello<(, world!)>|words,rtl") + << standard[2] << 13 << 5 << QDeclarativeTextInput::SelectWords << 5 << 13 << false; + QTest::newRow("<world(!)>|words,ltr") + << standard[2] << 12 << 13 << QDeclarativeTextInput::SelectWords << 7 << 13 << false; + QTest::newRow("world<(!)>|words,rtl") + << standard[2] << 13 << 12 << QDeclarativeTextInput::SelectWords << 12 << 13 << false; QTest::newRow("world!<()>)|words") << standard[2] << 13 << 13 << QDeclarativeTextInput::SelectWords << 13 << 13 << true; QTest::newRow("world<()>!)|words") << standard[2] << 12 << 12 << QDeclarativeTextInput::SelectWords << 12 << 12 << true; - QTest::newRow("<(,)>olleH |words") - << standard[3] << 7 << 8 << QDeclarativeTextInput::SelectWords << 7 << 8 << true; + QTest::newRow("<(,)>olleH |words,ltr") + << standard[3] << 7 << 8 << QDeclarativeTextInput::SelectWords << 7 << 8 << false; + QTest::newRow("<(,)olleH> |words,rtl") + << standard[3] << 8 << 7 << QDeclarativeTextInput::SelectWords << 7 << 13 << false; QTest::newRow("<dlrow( ,)>olleH|words,ltr") << standard[3] << 6 << 8 << QDeclarativeTextInput::SelectWords << 1 << 8 << false; - QTest::newRow("dlrow<( ,)>olleH|words,rtl") - << standard[3] << 8 << 6 << QDeclarativeTextInput::SelectWords << 6 << 8 << false; + QTest::newRow("dlrow<( ,)olleH>|words,rtl") + << standard[3] << 8 << 6 << QDeclarativeTextInput::SelectWords << 6 << 13 << false; QTest::newRow("<dlrow( ,ol)leH>|words,ltr") << standard[3] << 6 << 10 << QDeclarativeTextInput::SelectWords << 1 << 13 << false; QTest::newRow("dlrow<( ,ol)leH>|words,rtl") @@ -657,20 +661,20 @@ void tst_qdeclarativetextinput::moveCursorSelection_data() << standard[3] << 7 << 7 << QDeclarativeTextInput::SelectWords << 7 << 7 << true; QTest::newRow("<dlrow( )>,olleH|words,ltr") << standard[3] << 6 << 7 << QDeclarativeTextInput::SelectWords << 1 << 7 << false; - QTest::newRow("dlrow<( ),>olleH|words,rtl") - << standard[3] << 7 << 6 << QDeclarativeTextInput::SelectWords << 6 << 8 << false; - QTest::newRow("<(dlrow )>,olleH|words,ltr") - << standard[3] << 1 << 7 << QDeclarativeTextInput::SelectWords << 1 << 7 << false; - QTest::newRow("<(dlrow ),>olleH|words,rtl") - << standard[3] << 7 << 1 << QDeclarativeTextInput::SelectWords << 1 << 8 << false; - QTest::newRow("<(!dlrow )>,olleH|words,ltr") - << standard[3] << 0 << 7 << QDeclarativeTextInput::SelectWords << 0 << 7 << false; - QTest::newRow("<(!dlrow ),>olleH|words,rtl") - << standard[3] << 7 << 0 << QDeclarativeTextInput::SelectWords << 0 << 8 << false; - QTest::newRow("(!dlrow ,)olleH|words") - << standard[3] << 0 << 8 << QDeclarativeTextInput::SelectWords << 0 << 8 << true; - QTest::newRow("<(!)>dlrow|words") - << standard[3] << 0 << 1 << QDeclarativeTextInput::SelectWords << 0 << 1 << true; + QTest::newRow("dlrow<( )>,olleH|words,rtl") + << standard[3] << 7 << 6 << QDeclarativeTextInput::SelectWords << 6 << 7 << false; + QTest::newRow("<(dlrow )>,olleH|words") + << standard[3] << 1 << 7 << QDeclarativeTextInput::SelectWords << 1 << 7 << true; + QTest::newRow("<(!dlrow )>,olleH|words") + << standard[3] << 0 << 7 << QDeclarativeTextInput::SelectWords << 0 << 7 << true; + QTest::newRow("<(!dlrow ,)>olleH|words,ltr") + << standard[3] << 0 << 8 << QDeclarativeTextInput::SelectWords << 0 << 8 << false; + QTest::newRow("<(!dlrow ,)olleH>|words,rtl") + << standard[3] << 8 << 0 << QDeclarativeTextInput::SelectWords << 0 << 13 << false; + QTest::newRow("<(!)>dlrow|words,ltr") + << standard[3] << 0 << 1 << QDeclarativeTextInput::SelectWords << 0 << 1 << false; + QTest::newRow("<(!)dlrow|words,rtl") + << standard[3] << 1 << 0 << QDeclarativeTextInput::SelectWords << 0 << 6 << false; QTest::newRow("<()>!dlrow|words") << standard[3] << 0 << 0 << QDeclarativeTextInput::SelectWords << 0 << 0 << true; QTest::newRow("!<()>dlrow|words") |