diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 8af95a69825b369a3f8dcbe4fa40cf481cad0028..7a25b43c7fcf1cf5524550f7a3a007035fbef5f3 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -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()) diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index c93cd86123b81ae671973ef135f510793c37e20b..e45ab281f953b2faef8e59a4c162a12f9f3ebc82 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -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); diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 0c4821992cc2aa98d59a48d16c5cf59980b1b0a1..9aa4e1609b2253956520c2f58acf7ee5b7ea3270 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -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; diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index 4b216a5290b3e8dabdf80695733670c4bcd579fb..1061b7a9674c6eaf60abe361477b981b0c33b893 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -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; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index a8dfac2b5c055cab713c5930abd9f0ac45f1229d..8278a224fc549c31ff299835d4484f5baa7478e0 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -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";