From 808198c41ca900a4f408f8b0ae134e832282bbd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 20 Jan 2010 17:51:05 +0100 Subject: [PATCH] Removed the "Join Lines Up" action It was a bit confusing, since it reversed the order of the lines. When this would be fixed, the added value of this action is very small, since you can then also simply move your cursor one up before joining the lines. --- src/plugins/texteditor/basetexteditor.cpp | 25 ++++--------------- src/plugins/texteditor/basetexteditor.h | 4 +-- .../texteditor/texteditoractionhandler.cpp | 17 ++++--------- .../texteditor/texteditoractionhandler.h | 6 ++--- src/plugins/texteditor/texteditorconstants.h | 3 +-- 5 files changed, 14 insertions(+), 41 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 9cf2116abca..7c1b7242343 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -877,39 +877,24 @@ void BaseTextEditor::copyLineUpDown(bool up) setTextCursor(move); } -void BaseTextEditor::joinLineUp() -{ - joinLineUpDown(true); -} - -void BaseTextEditor::joinLineDown() -{ - joinLineUpDown(false); -} - -void BaseTextEditor::joinLineUpDown(bool up) +void BaseTextEditor::joinLines() { QTextCursor move = textCursor(); move.beginEditBlock(); - if(up) - move.movePosition(QTextCursor::Up); - else - move.movePosition(QTextCursor::Down); - + move.movePosition(QTextCursor::Down); move.movePosition(QTextCursor::StartOfBlock); move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); QString cutLine = move.selectedText(); + // collapse trailing whitespaces to one or insert whitespace cutLine.replace(QRegExp("^\\s*"), " "); move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor); move.removeSelectedText(); - move.clearSelection(); - - if(!up) - move.movePosition(QTextCursor::Up); + move.movePosition(QTextCursor::Up); move.movePosition(QTextCursor::EndOfBlock); + move.insertText(cutLine); move.endEditBlock(); setTextCursor(move); diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index fb295209149..b876a41457e 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -412,8 +412,7 @@ public slots: void copyLineUp(); void copyLineDown(); - void joinLineUp(); - void joinLineDown(); + void joinLines(); void cleanWhitespace(); @@ -623,7 +622,6 @@ private: void handleBackspaceKey(); void moveLineUpDown(bool up); void copyLineUpDown(bool up); - void joinLineUpDown(bool up); void saveCurrentCursorPositionForNavigation(); void updateCurrentLineHighlight(); diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 374df106867..3cdd55b6d1e 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -86,8 +86,7 @@ TextEditorActionHandler::TextEditorActionHandler(const QString &context, m_moveLineDownAction(0), m_copyLineUpAction(0), m_copyLineDownAction(0), - m_joinLineUpAction(0), - m_joinLineDownAction(0), + m_joinLinesAction(0), m_optionalActions(optionalActions), m_currentEditor(0), m_initialized(false) @@ -285,15 +284,10 @@ void TextEditorActionHandler::createActions() command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Down"))); connect(m_copyLineDownAction, SIGNAL(triggered()), this, SLOT(copyLineDown())); - m_joinLineUpAction= new QAction(tr("Join Line Up"), this); - command = am->registerAction(m_joinLineUpAction, Constants::JOIN_LINE_UP, m_contextId); - command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+J"))); - connect(m_joinLineUpAction, SIGNAL(triggered()), this, SLOT(joinLineUp())); - - m_joinLineDownAction= new QAction(tr("Join Line Down"), this); - command = am->registerAction(m_joinLineDownAction, Constants::JOIN_LINE_DOWN, m_contextId); + m_joinLinesAction= new QAction(tr("Join Lines"), this); + command = am->registerAction(m_joinLinesAction, Constants::JOIN_LINES, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+J"))); - connect(m_joinLineDownAction, SIGNAL(triggered()), this, SLOT(joinLineDown())); + connect(m_joinLinesAction, SIGNAL(triggered()), this, SLOT(joinLines())); } bool TextEditorActionHandler::supportsAction(const QString & /*id */) const @@ -455,8 +449,7 @@ FUNCTION(moveLineUp) FUNCTION(moveLineDown) FUNCTION(copyLineUp) FUNCTION(copyLineDown) -FUNCTION(joinLineUp) -FUNCTION(joinLineDown) +FUNCTION(joinLines) void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor) { diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index daa30275438..f15ff98e992 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -115,8 +115,7 @@ private slots: void moveLineDown(); void copyLineUp(); void copyLineDown(); - void joinLineUp(); - void joinLineDown(); + void joinLines(); void updateCurrentEditor(Core::IEditor *editor); private: @@ -153,8 +152,7 @@ private: QAction *m_moveLineDownAction; QAction *m_copyLineUpAction; QAction *m_copyLineDownAction; - QAction *m_joinLineUpAction; - QAction *m_joinLineDownAction; + QAction *m_joinLinesAction; uint m_optionalActions; QPointer m_currentEditor; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 0c75f95ec97..be73a014303 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -60,8 +60,7 @@ const char * const MOVE_LINE_UP = "TextEditor.MoveLineUp"; const char * const MOVE_LINE_DOWN = "TextEditor.MoveLineDown"; const char * const COPY_LINE_UP = "TextEditor.CopyLineUp"; const char * const COPY_LINE_DOWN = "TextEditor.CopyLineDown"; -const char * const JOIN_LINE_UP = "TextEditor.JoinLineUp"; -const char * const JOIN_LINE_DOWN = "TextEditor.JoinLineDown"; +const char * const JOIN_LINES = "TextEditor.JoinLines"; const char * const CUT_LINE = "TextEditor.CutLine"; const char * const DELETE_LINE = "TextEditor.DeleteLine"; const char * const DELETE_WORD = "TextEditor.DeleteWord";