X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/8f4d13dab8165e4c60c320d4b867e8476bdb041b..6d9f5b21315bf7c9f6b08e32a89346e22c482714:/src/kitemviews/private/kitemlistroleeditor.cpp diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp index 9f3b53c05..5ff013429 100644 --- a/src/kitemviews/private/kitemlistroleeditor.cpp +++ b/src/kitemviews/private/kitemlistroleeditor.cpp @@ -19,13 +19,11 @@ #include "kitemlistroleeditor.h" -#include -#include +#include #include KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) : KTextEdit(parent), - m_index(0), m_role(), m_blockFinishedSignal(false) { @@ -39,23 +37,13 @@ KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) : parent->installEventFilter(this); } - connect(this, SIGNAL(textChanged()), this, SLOT(autoAdjustSize())); + connect(this, &KItemListRoleEditor::textChanged, this, &KItemListRoleEditor::autoAdjustSize); } KItemListRoleEditor::~KItemListRoleEditor() { } -void KItemListRoleEditor::setIndex(int index) -{ - m_index = index; -} - -int KItemListRoleEditor::index() const -{ - return m_index; -} - void KItemListRoleEditor::setRole(const QByteArray& role) { m_role = role; @@ -95,7 +83,7 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event) // a roleEditingFinished signal (see KItemListRoleEditor::event), // which is not wanted in this case. m_blockFinishedSignal = true; - emit roleEditingCanceled(m_index, m_role, KIO::encodeFileName(toPlainText())); + emit roleEditingCanceled(m_role, KIO::encodeFileName(toPlainText())); m_blockFinishedSignal = false; event->accept(); return; @@ -104,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; } @@ -139,8 +143,7 @@ void KItemListRoleEditor::autoAdjustSize() void KItemListRoleEditor::emitRoleEditingFinished() { if (!m_blockFinishedSignal) { - emit roleEditingFinished(m_index, m_role, KIO::encodeFileName(toPlainText())); + emit roleEditingFinished(m_role, KIO::encodeFileName(toPlainText())); } } -#include "kitemlistroleeditor.moc"