diff options
author | jasplin <qt-info@nokia.com> | 2009-03-27 10:51:40 (GMT) |
---|---|---|
committer | jasplin <qt-info@nokia.com> | 2009-03-27 10:59:36 (GMT) |
commit | f9796f295e3fa42e4855f386b5663b1c2b957d10 (patch) | |
tree | aad54733c3a3e5d603d9976e71892c638c23bdca | |
parent | 4b3d81c629167a24424119ca4f296a85b78eab05 (diff) | |
download | Qt-f9796f295e3fa42e4855f386b5663b1c2b957d10.zip Qt-f9796f295e3fa42e4855f386b5663b1c2b957d10.tar.gz Qt-f9796f295e3fa42e4855f386b5663b1c2b957d10.tar.bz2 |
Clear QLineEdit selection when redoing a delete operation.
Deleting text in a QLineEdit should never leave a non-empty
selection. This is now reflected properly in the redo function.
Reviewed-by: janarve
Task-number: 248948
-rw-r--r-- | src/gui/widgets/qlineedit.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qlineedit/tst_qlineedit.cpp | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index b03df9e..e243ad0 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -3523,6 +3523,8 @@ void QLineEditPrivate::redo() { case RemoveSelection: case DeleteSelection: text.remove(cmd.pos, 1); + selstart = cmd.selStart; + selend = cmd.selEnd; cursor = cmd.pos; break; case Separator: diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 87e966f..8779831 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -257,6 +257,7 @@ private slots: void task233101_cursorPosAfterInputMethod_data(); void task233101_cursorPosAfterInputMethod(); void task241436_passwordEchoOnEditRestoreEchoMode(); + void task248948_redoRemovedSelection(); protected slots: #ifdef QT3_SUPPORT @@ -3487,5 +3488,17 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode() testWidget->setEchoMode(QLineEdit::Normal); } +void tst_QLineEdit::task248948_redoRemovedSelection() +{ + testWidget->setText("a"); + testWidget->selectAll(); + QTest::keyPress(testWidget, Qt::Key_Delete); + testWidget->undo(); + testWidget->redo(); + QTest::keyPress(testWidget, 'a'); + QTest::keyPress(testWidget, 'b'); + QCOMPARE(testWidget->text(), QLatin1String("ab")); +} + QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" |