diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp --- a/src/kitemviews/private/kitemlistroleeditor.cpp +++ b/src/kitemviews/private/kitemlistroleeditor.cpp @@ -20,6 +20,7 @@ #include "kitemlistroleeditor.h" #include +#include KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) : KTextEdit(parent), @@ -111,6 +112,30 @@ break; } + if (KStandardShortcut::beginningOfLine().contains(event->key())) { + QTextCursor cursor = textCursor(); + + if (event->modifiers() == Qt::NoModifier && cursor.hasSelection()) { + cursor.setPosition(cursor.selectionStart()); + } else { + //if already at StartOfLine, move 1 line up + if (event->modifiers() & Qt::ShiftModifier) { + if (!cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor)) { + cursor.movePosition(QTextCursor::Up, QTextCursor::KeepAnchor); + cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor); + } + } else { + if (!cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor)) { + cursor.movePosition(QTextCursor::Up, QTextCursor::MoveAnchor); + cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor); + } + } + } + setTextCursor(cursor); + event->accept(); + return; + } + KTextEdit::keyPressEvent(event); }