From 87b3755b6f1e016fe9634657f20697a2f86e6648 Mon Sep 17 00:00:00 2001 From: mae <qt-info@nokia.com> Date: Fri, 7 May 2010 15:24:30 +0200 Subject: [PATCH] Missing actions in keyboard options Task-number: QTCREATORBUG-61 --- src/plugins/texteditor/basetexteditor.cpp | 83 +++++++++++++++++++ src/plugins/texteditor/basetexteditor.h | 17 ++++ .../texteditor/texteditoractionhandler.cpp | 71 ++++++++++++++++ .../texteditor/texteditoractionhandler.h | 18 ++++ src/plugins/texteditor/texteditorconstants.h | 16 ++++ 5 files changed, 205 insertions(+) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index d4e496c22b5..45c8580fd6e 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -739,6 +739,89 @@ void BaseTextEditor::gotoBlockEndWithSelection() } } + +void BaseTextEditor::gotoLineStart() +{ + handleHomeKey(false); +} + +void BaseTextEditor::gotoLineStartWithSelection() +{ + handleHomeKey(true); +} + +void BaseTextEditor::gotoLineEnd() +{ + moveCursor(QTextCursor::EndOfLine); +} + +void BaseTextEditor::gotoLineEndWithSelection() +{ + moveCursor(QTextCursor::EndOfLine, QTextCursor::KeepAnchor); +} + +void BaseTextEditor::gotoNextLine() +{ + moveCursor(QTextCursor::NextRow); +} + +void BaseTextEditor::gotoNextLineWithSelection() +{ + moveCursor(QTextCursor::NextRow, QTextCursor::KeepAnchor); +} + +void BaseTextEditor::gotoPreviousLine() +{ + moveCursor(QTextCursor::PreviousRow); +} + +void BaseTextEditor::gotoPreviousLineWithSelection() +{ + moveCursor(QTextCursor::PreviousRow, QTextCursor::KeepAnchor); +} + +void BaseTextEditor::gotoPreviousCharacter() +{ + moveCursor(QTextCursor::PreviousCharacter); +} + +void BaseTextEditor::gotoPreviousCharacterWithSelection() +{ + moveCursor(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor); +} + +void BaseTextEditor::gotoNextCharacter() +{ + moveCursor(QTextCursor::NextCharacter); +} + +void BaseTextEditor::gotoNextCharacterWithSelection() +{ + moveCursor(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); +} + +void BaseTextEditor::gotoPreviousWord() +{ + moveCursor(QTextCursor::PreviousWord); +} + +void BaseTextEditor::gotoPreviousWordWithSelection() +{ + moveCursor(QTextCursor::PreviousWord, QTextCursor::KeepAnchor); +} + +void BaseTextEditor::gotoNextWord() +{ + moveCursor(QTextCursor::NextWord); +} + +void BaseTextEditor::gotoNextWordWithSelection() +{ + moveCursor(QTextCursor::NextWord, QTextCursor::KeepAnchor); +} + + + static QTextCursor flippedCursor(const QTextCursor &cursor) { QTextCursor flipped = cursor; diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 67ef63858d6..8a3466735f7 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -231,6 +231,23 @@ public slots: void gotoBlockStartWithSelection(); void gotoBlockEndWithSelection(); + void gotoLineStart(); + void gotoLineStartWithSelection(); + void gotoLineEnd(); + void gotoLineEndWithSelection(); + void gotoNextLine(); + void gotoNextLineWithSelection(); + void gotoPreviousLine(); + void gotoPreviousLineWithSelection(); + void gotoPreviousCharacter(); + void gotoPreviousCharacterWithSelection(); + void gotoNextCharacter(); + void gotoNextCharacterWithSelection(); + void gotoPreviousWord(); + void gotoPreviousWordWithSelection(); + void gotoNextWord(); + void gotoNextWordWithSelection(); + void selectBlockUp(); void selectBlockDown(); diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index d08912fe9d7..81ab291ab9d 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -292,6 +292,59 @@ void TextEditorActionHandler::createActions() command = am->registerAction(m_joinLinesAction, Constants::JOIN_LINES, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+J"))); connect(m_joinLinesAction, SIGNAL(triggered()), this, SLOT(joinLines())); + + + QAction *a = 0; + a = new QAction(tr("Goto Line Start"), this); + command = am->registerAction(a, Constants::GOTO_LINE_START, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoLineStart())); + a = new QAction(tr("Goto Line End"), this); + command = am->registerAction(a, Constants::GOTO_LINE_END, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoLineEnd())); + a = new QAction(tr("Goto Next Line"), this); + command = am->registerAction(a, Constants::GOTO_NEXT_LINE, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoNextLine())); + a = new QAction(tr("Goto Previous Line"), this); + command = am->registerAction(a, Constants::GOTO_PREVIOUS_LINE, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousLine())); + a = new QAction(tr("Goto Previous Character"), this); + command = am->registerAction(a, Constants::GOTO_PREVIOUS_CHARACTER, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousCharacter())); + a = new QAction(tr("Goto Next Character"), this); + command = am->registerAction(a, Constants::GOTO_NEXT_CHARACTER, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoNextCharacter())); + a = new QAction(tr("Goto Previous Word"), this); + command = am->registerAction(a, Constants::GOTO_PREVIOUS_WORD, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousWord())); + a = new QAction(tr("Goto Next Word"), this); + command = am->registerAction(a, Constants::GOTO_NEXT_WORD, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWord())); + + a = new QAction(tr("Goto Line Start With Selection"), this); + command = am->registerAction(a, Constants::GOTO_LINE_START_WITH_SELECTION, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoLineStartWithSelection())); + a = new QAction(tr("Goto Line End With Selection"), this); + command = am->registerAction(a, Constants::GOTO_LINE_END_WITH_SELECTION, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoLineEndWithSelection())); + a = new QAction(tr("Goto Next Line With Selection"), this); + command = am->registerAction(a, Constants::GOTO_NEXT_LINE_WITH_SELECTION, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoNextLineWithSelection())); + a = new QAction(tr("Goto Previous Line With Selection"), this); + command = am->registerAction(a, Constants::GOTO_PREVIOUS_LINE_WITH_SELECTION, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousLineWithSelection())); + a = new QAction(tr("Goto Previous Character With Selection"), this); + command = am->registerAction(a, Constants::GOTO_PREVIOUS_CHARACTER_WITH_SELECTION, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousCharacterWithSelection())); + a = new QAction(tr("Goto Next Character With Selection"), this); + command = am->registerAction(a, Constants::GOTO_NEXT_CHARACTER_WITH_SELECTION, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoNextCharacterWithSelection())); + a = new QAction(tr("Goto Previous Word With Selection"), this); + command = am->registerAction(a, Constants::GOTO_PREVIOUS_WORD_WITH_SELECTION, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousWordWithSelection())); + a = new QAction(tr("Goto Next Word With Selection"), this); + command = am->registerAction(a, Constants::GOTO_NEXT_WORD_WITH_SELECTION, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWordWithSelection())); + } bool TextEditorActionHandler::supportsAction(const QString & /*id */) const @@ -455,6 +508,24 @@ FUNCTION(copyLineUp) FUNCTION(copyLineDown) FUNCTION(joinLines) +FUNCTION(gotoLineStart) +FUNCTION(gotoLineStartWithSelection) +FUNCTION(gotoLineEnd) +FUNCTION(gotoLineEndWithSelection) +FUNCTION(gotoNextLine) +FUNCTION(gotoNextLineWithSelection) +FUNCTION(gotoPreviousLine) +FUNCTION(gotoPreviousLineWithSelection) +FUNCTION(gotoPreviousCharacter) +FUNCTION(gotoPreviousCharacterWithSelection) +FUNCTION(gotoNextCharacter) +FUNCTION(gotoNextCharacterWithSelection) +FUNCTION(gotoPreviousWord) +FUNCTION(gotoPreviousWordWithSelection) +FUNCTION(gotoNextWord) +FUNCTION(gotoNextWordWithSelection) + + void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor) { m_currentEditor = 0; diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index 2b8b7a039c0..667ce575086 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -118,6 +118,24 @@ private slots: void joinLines(); void updateCurrentEditor(Core::IEditor *editor); + void gotoLineStart(); + void gotoLineStartWithSelection(); + void gotoLineEnd(); + void gotoLineEndWithSelection(); + void gotoNextLine(); + void gotoNextLineWithSelection(); + void gotoPreviousLine(); + void gotoPreviousLineWithSelection(); + void gotoPreviousCharacter(); + void gotoPreviousCharacterWithSelection(); + void gotoNextCharacter(); + void gotoNextCharacterWithSelection(); + void gotoPreviousWord(); + void gotoPreviousWordWithSelection(); + void gotoNextWord(); + void gotoNextWordWithSelection(); + + private: QAction *m_undoAction; QAction *m_redoAction; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 7fc41a9f888..b0af1e7df0e 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -68,6 +68,22 @@ const char * const SELECT_ENCODING = "TextEditor.SelectEncoding"; const char * const REWRAP_PARAGRAPH = "TextEditor.RewrapParagraph"; const char * const GOTO_OPENING_PARENTHESIS = "TextEditor.GotoOpeningParenthesis"; const char * const GOTO_CLOSING_PARENTHESIS = "TextEditor.GotoClosingParenthesis"; +const char * const GOTO_LINE_START = "TextEditor.GotoLineStart"; +const char * const GOTO_LINE_END = "TextEditor.GotoLineEnd"; +const char * const GOTO_NEXT_LINE = "TextEditor.GotoNextLine"; +const char * const GOTO_PREVIOUS_LINE = "TextEditor.GotoPreviousLine"; +const char * const GOTO_PREVIOUS_CHARACTER = "TextEditor.GotoPreviousCharacter"; +const char * const GOTO_NEXT_CHARACTER = "TextEditor.GotoNextCharacter"; +const char * const GOTO_PREVIOUS_WORD = "TextEditor.GotoPreviousWord"; +const char * const GOTO_NEXT_WORD = "TextEditor.GotoNextWord"; +const char * const GOTO_LINE_START_WITH_SELECTION = "TextEditor.GotoLineStartWithSelection"; +const char * const GOTO_LINE_END_WITH_SELECTION = "TextEditor.GotoLineEndWithSelection"; +const char * const GOTO_NEXT_LINE_WITH_SELECTION = "TextEditor.GotoNextLineWithSelection"; +const char * const GOTO_PREVIOUS_LINE_WITH_SELECTION = "TextEditor.GotoPreviousLineWithSelection"; +const char * const GOTO_PREVIOUS_CHARACTER_WITH_SELECTION = "TextEditor.GotoPreviousCharacterWithSelection"; +const char * const GOTO_NEXT_CHARACTER_WITH_SELECTION = "TextEditor.GotoNextCharacterWithSelection"; +const char * const GOTO_PREVIOUS_WORD_WITH_SELECTION = "TextEditor.GotoPreviousWordWithSelection"; +const char * const GOTO_NEXT_WORD_WITH_SELECTION = "TextEditor.GotoNextWordWithSelection"; const char * const C_TEXTEDITOR_MIMETYPE_TEXT = "text/plain"; const char * const C_TEXTEDITOR_MIMETYPE_XML = "application/xml"; -- GitLab