From: Christoph Feck Date: Sun, 25 Aug 2013 15:40:49 +0000 (+0200) Subject: Move cursor to begin/end of selection before canceling it X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/092c820023466f5291ba7d52f55a8e7b9939a502 Move cursor to begin/end of selection before canceling it Makes Left/Right keys consistent with QLineEdit behavior. BUG: 323946 FIXED-IN: 4.11.1 REVIEW: 112256 --- diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp index 9f20afea2..0a48f1ba0 100644 --- a/src/kitemviews/private/kitemlistroleeditor.cpp +++ b/src/kitemviews/private/kitemlistroleeditor.cpp @@ -93,6 +93,22 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event) emitRoleEditingFinished(); event->accept(); return; + case Qt::Key_Left: + case Qt::Key_Right: { + QTextCursor cursor = textCursor(); + if (event->modifiers() == Qt::NoModifier && cursor.hasSelection()) { + if (event->key() == Qt::Key_Left) { + cursor.setPosition(cursor.selectionStart()); + } else { + cursor.setPosition(cursor.selectionEnd()); + } + cursor.clearSelection(); + setTextCursor(cursor); + event->accept(); + return; + } + break; + } default: break; }