]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/private/kitemlistroleeditor.cpp
Merge remote-tracking branch 'origin/Applications/18.08'
[dolphin.git] / src / kitemviews / private / kitemlistroleeditor.cpp
index 9f20afea24e81d2b89d3ed37baa067181721b16f..e79a9f9d144483a2b023499490fffd0f9be7e78b 100644 (file)
@@ -19,9 +19,7 @@
 
 #include "kitemlistroleeditor.h"
 
-#include <KDebug>
-#include <kio/global.h>
-#include <QKeyEvent>
+#include <KIO/Global>
 
 KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) :
     KTextEdit(parent),
@@ -38,7 +36,7 @@ KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) :
         parent->installEventFilter(this);
     }
 
-    connect(this, SIGNAL(textChanged()), this, SLOT(autoAdjustSize()));
+    connect(this, &KItemListRoleEditor::textChanged, this, &KItemListRoleEditor::autoAdjustSize);
 }
 
 KItemListRoleEditor::~KItemListRoleEditor()
@@ -93,6 +91,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;
     }
@@ -132,4 +146,3 @@ void KItemListRoleEditor::emitRoleEditingFinished()
     }
 }
 
-#include "kitemlistroleeditor.moc"