summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2012-03-27 23:18:46 +0400
committerhjk <qthjk@ovi.com>2012-03-28 08:38:41 +0200
commit7ae82b9f9453251861394ce9bec95d704353f83b (patch)
tree2bfc313abb7e1b0570664d2b9c976c362bdb74e5 /src/plugins/cppeditor
parentaa722e6a608d04a943267514f1f043e37b19e874 (diff)
downloadqt-creator-7ae82b9f9453251861394ce9bec95d704353f83b.tar.gz
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>
Diffstat (limited to 'src/plugins/cppeditor')
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp5
-rw-r--r--src/plugins/cppeditor/cppeditor.h1
-rw-r--r--src/plugins/cppeditor/cppeditorconstants.h1
-rw-r--r--src/plugins/cppeditor/cppplugin.cpp18
-rw-r--r--src/plugins/cppeditor/cppplugin.h1
5 files changed, 3 insertions, 23 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 9bea3f0d4c..b18cc1dacb 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -1485,11 +1485,6 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
return Link();
}
-void CPPEditorWidget::jumpToDefinition()
-{
- openLink(findLinkAt(textCursor()));
-}
-
Symbol *CPPEditorWidget::findDefinition(Symbol *symbol, const Snapshot &snapshot) const
{
if (symbol->isFunction())
diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h
index bcdcf3e15c..b9a75de2ce 100644
--- a/src/plugins/cppeditor/cppeditor.h
+++ b/src/plugins/cppeditor/cppeditor.h
@@ -208,7 +208,6 @@ public Q_SLOTS:
virtual void setTabSettings(const TextEditor::TabSettings &);
void setSortedOutline(bool sort);
void switchDeclarationDefinition();
- void jumpToDefinition();
void renameSymbolUnderCursor();
void renameUsages();
void findUsages();
diff --git a/src/plugins/cppeditor/cppeditorconstants.h b/src/plugins/cppeditor/cppeditorconstants.h
index e2aeff9d68..6ad17f0fda 100644
--- a/src/plugins/cppeditor/cppeditorconstants.h
+++ b/src/plugins/cppeditor/cppeditorconstants.h
@@ -48,7 +48,6 @@ const char SEPARATOR[] = "CppEditor.Separator";
const char SEPARATOR2[] = "CppEditor.Separator2";
const char SEPARATOR3[] = "CppEditor.Separator3";
const char SEPARATOR4[] = "CppEditor.Separator4";
-const char JUMP_TO_DEFINITION[] = "CppEditor.JumpToDefinition";
const char UPDATE_CODEMODEL[] = "CppEditor.UpdateCodeModel";
const int TYPE_HIERARCHY_PRIORITY = 700;
diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp
index b96205e43c..bfc49aafdf 100644
--- a/src/plugins/cppeditor/cppplugin.cpp
+++ b/src/plugins/cppeditor/cppplugin.cpp
@@ -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();
diff --git a/src/plugins/cppeditor/cppplugin.h b/src/plugins/cppeditor/cppplugin.h
index 3b42b0b28b..652c942d76 100644
--- a/src/plugins/cppeditor/cppplugin.h
+++ b/src/plugins/cppeditor/cppplugin.h
@@ -83,7 +83,6 @@ public slots:
private slots:
void switchDeclarationDefinition();
- void jumpToDefinition();
void renameSymbolUnderCursor();
void onTaskStarted(const QString &type);
void onAllTasksFinished(const QString &type);