forked from qt-creator/qt-creator
Added TextEditor commands FollowSymbol and JumpToFile.
Most of editors have "jump to file" or "follow symbol" actions. This patch reduces amount of related boilerplate code. New actions are made optional to prevent shortcut clash (both use F2). Change-Id: I2af580ed9d6789df25f4487ba001f3b83887c504 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -242,12 +242,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
|
||||
cmd = am->command(Core::Id(CppTools::Constants::SWITCH_HEADER_SOURCE));
|
||||
contextMenu->addAction(cmd);
|
||||
|
||||
QAction *jumpToDefinition = new QAction(tr("Follow Symbol Under Cursor"), this);
|
||||
cmd = am->registerAction(jumpToDefinition,
|
||||
Constants::JUMP_TO_DEFINITION, context, true);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
|
||||
connect(jumpToDefinition, SIGNAL(triggered()),
|
||||
this, SLOT(jumpToDefinition()));
|
||||
cmd = am->command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR);
|
||||
contextMenu->addAction(cmd);
|
||||
cppToolsMenu->addAction(cmd);
|
||||
|
||||
@@ -304,7 +299,8 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
|
||||
m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR,
|
||||
TextEditor::TextEditorActionHandler::Format
|
||||
| TextEditor::TextEditorActionHandler::UnCommentSelection
|
||||
| TextEditor::TextEditorActionHandler::UnCollapseAll);
|
||||
| TextEditor::TextEditorActionHandler::UnCollapseAll
|
||||
| TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
|
||||
|
||||
m_actionHandler->initializeActions();
|
||||
|
||||
@@ -355,14 +351,6 @@ void CppPlugin::switchDeclarationDefinition()
|
||||
editor->switchDeclarationDefinition();
|
||||
}
|
||||
|
||||
void CppPlugin::jumpToDefinition()
|
||||
{
|
||||
Core::EditorManager *em = Core::EditorManager::instance();
|
||||
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget());
|
||||
if (editor)
|
||||
editor->jumpToDefinition();
|
||||
}
|
||||
|
||||
void CppPlugin::renameSymbolUnderCursor()
|
||||
{
|
||||
Core::EditorManager *em = Core::EditorManager::instance();
|
||||
|
||||
Reference in New Issue
Block a user