Commit 9a79a069 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Introduce a Delete Line action that doesn't copy to clipboard

The version that does copy to clipboard is now called Cut Line, and is
still mapped to Shift+Delete by default.
parent 4e7f2f8d
......@@ -3622,8 +3622,7 @@ void BaseTextEditor::changeEvent(QEvent *e)
}
}
// shift+del
void BaseTextEditor::deleteLine()
void BaseTextEditor::maybeSelectLine()
{
QTextCursor cursor = textCursor();
if (!cursor.hasSelection()) {
......@@ -3638,9 +3637,21 @@ void BaseTextEditor::deleteLine()
}
setTextCursor(cursor);
}
}
// shift+del
void BaseTextEditor::cutLine()
{
maybeSelectLine();
cut();
}
void BaseTextEditor::deleteLine()
{
maybeSelectLine();
textCursor().removeSelectedText();
}
void BaseTextEditor::setExtraSelections(ExtraSelectionKind kind, const QList<QTextEdit::ExtraSelection> &selections)
{
if (selections.isEmpty() && d->m_extraSelections[kind].isEmpty())
......
......@@ -370,6 +370,7 @@ public slots:
void zoomIn(int range = 1);
void zoomOut(int range = 1);
void cutLine();
void deleteLine();
void unCollapseAll();
void collapse();
......@@ -406,6 +407,9 @@ protected:
bool canInsertFromMimeData(const QMimeData *source) const;
void insertFromMimeData(const QMimeData *source);
private:
void maybeSelectLine();
public:
void duplicateFrom(BaseTextEditor *editor);
......
......@@ -72,6 +72,7 @@ TextEditorActionHandler::TextEditorActionHandler(const QString &context,
m_unCollapseAllAction = 0;
m_collapseAction = 0;
m_expandAction = 0;
m_cutLineAction = 0;
m_deleteLineAction = 0;
m_selectEncodingAction = 0;
m_increaseFontSizeAction = 0;
......@@ -173,9 +174,13 @@ void TextEditorActionHandler::createActions()
connect(m_unCommentSelectionAction, SIGNAL(triggered()), this, SLOT(unCommentSelection()));
advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
m_cutLineAction = new QAction(tr("Cut &Line"), this);
command = am->registerAction(m_cutLineAction, Constants::CUT_LINE, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Shift+Del")));
connect(m_cutLineAction, SIGNAL(triggered()), this, SLOT(cutLine()));
m_deleteLineAction = new QAction(tr("Delete &Line"), this);
command = am->registerAction(m_deleteLineAction, Constants::DELETE_LINE, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Shift+Del")));
connect(m_deleteLineAction, SIGNAL(triggered()), this, SLOT(deleteLine()));
m_collapseAction = new QAction(tr("Collapse"), this);
......@@ -385,6 +390,7 @@ FUNCTION2(formatAction, format)
FUNCTION2(selectAllAction, selectAll)
FUNCTION(cleanWhitespace)
FUNCTION(unCommentSelection)
FUNCTION(cutLine)
FUNCTION(deleteLine)
FUNCTION(unCollapseAll)
FUNCTION(collapse)
......@@ -416,7 +422,6 @@ void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor)
}
}
const QPointer<BaseTextEditor> &TextEditorActionHandler::currentEditor() const
{
return m_currentEditor;
......
......@@ -98,6 +98,7 @@ private slots:
void unCollapseAll();
void collapse();
void expand();
void cutLine();
void deleteLine();
void selectEncoding();
void increaseFontSize();
......@@ -129,6 +130,7 @@ private:
QAction *m_unCollapseAllAction;
QAction *m_collapseAction;
QAction *m_expandAction;
QAction *m_cutLineAction;
QAction *m_deleteLineAction;
QAction *m_selectEncodingAction;
QAction *m_increaseFontSizeAction;
......
......@@ -51,8 +51,9 @@ const char * const GOTO_BLOCK_END = "TextEditor.GotoBlockEnd";
const char * const GOTO_BLOCK_END_WITH_SELECTION = "TextEditor.GotoBlockEndWithSelection";
const char * const SELECT_BLOCK_UP = "TextEditor.SelectBlockUp";
const char * const SELECT_BLOCK_DOWN = "TextEditor.SelectBlockDown";
const char * const MOVE_LINE_UP = "TextEditor.MoveLineUp";
const char * const MOVE_LINE_DOWN = "TextEditor.MoveLineDown";
const char * const MOVE_LINE_UP = "TextEditor.MoveLineUp";
const char * const MOVE_LINE_DOWN = "TextEditor.MoveLineDown";
const char * const CUT_LINE = "TextEditor.CutLine";
const char * const DELETE_LINE = "TextEditor.DeleteLine";
const char * const DELETE_WORD = "TextEditor.DeleteWord";
const char * const SELECT_ENCODING = "TextEditor.SelectEncoding";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment