]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Move cursor to begin/end of selection before canceling it
authorChristoph Feck <christoph@maxiom.de>
Sun, 25 Aug 2013 15:40:49 +0000 (17:40 +0200)
committerChristoph Feck <christoph@maxiom.de>
Sun, 25 Aug 2013 15:40:49 +0000 (17:40 +0200)
Makes Left/Right keys consistent with QLineEdit behavior.

BUG: 323946
FIXED-IN: 4.11.1
REVIEW: 112256

src/kitemviews/private/kitemlistroleeditor.cpp

index 9f20afea24e81d2b89d3ed37baa067181721b16f..0a48f1ba0dcadfeaae3e20fe1f23abd81d7fc4e0 100644 (file)
@@ -93,6 +93,22 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event)
         emitRoleEditingFinished();
         event->accept();
         return;
         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;
     }
     default:
         break;
     }