diff options
author | Robert Loehning <robert.loehning@nokia.com> | 2012-06-15 14:35:00 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-20 11:13:18 (GMT) |
commit | 4093ae7ae38f6006f7f8c1438e89777144a0c10b (patch) | |
tree | 94568f0bbd4ae9766636b908f9121fd020cf50e3 | |
parent | d146da2d76531fe3ad22e592e4f111449788536b (diff) | |
download | Qt-4093ae7ae38f6006f7f8c1438e89777144a0c10b.zip Qt-4093ae7ae38f6006f7f8c1438e89777144a0c10b.tar.gz Qt-4093ae7ae38f6006f7f8c1438e89777144a0c10b.tar.bz2 |
Restored native behavior when moving cursor from selection
Reverting changes from 1b031759ddfdab9703dfecac13f1ed318da3dafe except
for Mac
Task-number: QTCREATORBUG-7215
Change-Id: I8570c4bd35daf8b5820507a9399d33d00f96d41b
Reviewed-by: Alessandro Portale <alessandro.portale@nokia.com>
-rw-r--r-- | src/gui/text/qtextcursor.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qplaintextedit/tst_qplaintextedit.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qtextedit/tst_qtextedit.cpp | 10 |
3 files changed, 24 insertions, 4 deletions
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index e6af105..7dcb187 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -421,16 +421,20 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor break; } case QTextCursor::PreviousCharacter: +#ifdef Q_WS_MAC if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor) newPosition = qMin(position, adjusted_anchor); else +#endif newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters); break; case QTextCursor::Left: +#ifdef Q_WS_MAC if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor) newPosition = visualMovement ? qMax(position, adjusted_anchor) : qMin(position, adjusted_anchor); else +#endif newPosition = visualMovement ? priv->leftCursorPosition(position) : priv->previousCursorPosition(position, QTextLayout::SkipCharacters); break; @@ -542,16 +546,20 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor break; } case QTextCursor::NextCharacter: +#ifdef Q_WS_MAC if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor) newPosition = qMax(position, adjusted_anchor); else +#endif newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters); break; case QTextCursor::Right: +#ifdef Q_WS_MAC if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor) newPosition = visualMovement ? qMin(position, adjusted_anchor) : qMax(position, adjusted_anchor); else +#endif newPosition = visualMovement ? priv->rightCursorPosition(position) : priv->nextCursorPosition(position, QTextLayout::SkipCharacters); break; diff --git a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp index 3eeae7e..4681ef0 100644 --- a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp @@ -1478,12 +1478,18 @@ void tst_QPlainTextEdit::selectionChanged() QCOMPARE(ed->textCursor().position(), 4); QCOMPARE(selectionChangedSpy.count(), 3); +#ifdef Q_WS_MAC + const int posAfterRight = 4; // cursor at end of former selection +#else + const int posAfterRight = 5; // cursor was at end of former selection, moved right +#endif + QTest::keyClick(ed, Qt::Key_Right); - QCOMPARE(ed->textCursor().position(), 4); + QCOMPARE(ed->textCursor().position(), posAfterRight); QCOMPARE(selectionChangedSpy.count(), 4); QTest::keyClick(ed, Qt::Key_Right); - QCOMPARE(ed->textCursor().position(), 5); + QCOMPARE(ed->textCursor().position(), posAfterRight + 1); QCOMPARE(selectionChangedSpy.count(), 4); } diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index d308332..83913d3 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -1901,12 +1901,18 @@ void tst_QTextEdit::selectionChanged() QCOMPARE(ed->textCursor().position(), 4); QCOMPARE(selectionChangedSpy.count(), 3); +#ifdef Q_WS_MAC + const int posAfterRight = 4; // cursor at end of former selection +#else + const int posAfterRight = 5; // cursor was at end of former selection, moved right +#endif + QTest::keyClick(ed, Qt::Key_Right); - QCOMPARE(ed->textCursor().position(), 4); + QCOMPARE(ed->textCursor().position(), posAfterRight); QCOMPARE(selectionChangedSpy.count(), 4); QTest::keyClick(ed, Qt::Key_Right); - QCOMPARE(ed->textCursor().position(), 5); + QCOMPARE(ed->textCursor().position(), posAfterRight + 1); QCOMPARE(selectionChangedSpy.count(), 4); } |