┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristoph Feck <[email protected]>2013-08-25 17:40:49 +0200
committerChristoph Feck <[email protected]>2013-08-25 17:40:49 +0200
commit092c820023466f5291ba7d52f55a8e7b9939a502 (patch)
tree3abf9c34a839a681c581d9701676c4e959d6a258 /src
parentf830e1179ceb7bb31e449215294e5f0ffa3ed6ec (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.cpp16
1 files changed, 16 insertions, 0 deletions
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;
}