]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/private/kitemlistroleeditor.cpp
Removed unused KGlobal includes and use KIO/Job instead of KIO/JobClasses
[dolphin.git] / src / kitemviews / private / kitemlistroleeditor.cpp
index 9f20afea24e81d2b89d3ed37baa067181721b16f..5ff013429cb709a25dce3518418c896cce98c2a9 100644 (file)
@@ -19,8 +19,7 @@
 
 #include "kitemlistroleeditor.h"
 
-#include <KDebug>
-#include <kio/global.h>
+#include <KIO/Global>
 #include <QKeyEvent>
 
 KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) :
@@ -38,7 +37,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 +92,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 +147,3 @@ void KItemListRoleEditor::emitRoleEditingFinished()
     }
 }
 
-#include "kitemlistroleeditor.moc"