diff options
author | David Schulz <david.schulz@digia.com> | 2013-02-05 14:14:33 +0100 |
---|---|---|
committer | David Schulz <david.schulz@digia.com> | 2013-02-14 09:46:16 +0100 |
commit | 6ef0cf1a30f1c31d24363fa5ab7a3673f7886126 (patch) | |
tree | 6b988785304e03eb728196a98e37e4462c164fde /src/plugins/cpptools/cpptoolsplugin.cpp | |
parent | a37770ba3b05c480338d2a1fe08f9677249aeb8f (diff) | |
download | qt-creator-6ef0cf1a30f1c31d24363fa5ab7a3673f7886126.tar.gz |
Editor: Refactor Open Link in Next Split.
Cleanup code and added shortcuts and menu entries for
- open header/source in next split
- follow symbol under cursor in next split
- open declaration/definition in next split
Change-Id: I2c4347749d26669d88b7c2968f30f60710f442b1
Reviewed-by: Petar Perisin <petar.perisin@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cpptoolsplugin.cpp')
-rw-r--r-- | src/plugins/cpptools/cpptoolsplugin.cpp | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index ac5e0ff2f9..05d604b29c 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -138,6 +138,12 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error) mcpptools->addAction(command); connect(switchAction, SIGNAL(triggered()), this, SLOT(switchHeaderSource())); + QAction *openInNextSplitAction = new QAction(tr("Open corresponding Header/Source in Next Split"), this); + command = Core::ActionManager::registerAction(openInNextSplitAction, Constants::OPEN_HEADER_SOURCE_IN_NEXT_SPLIT, context, true); + command->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_E, Qt::Key_F4)); + mcpptools->addAction(command); + connect(openInNextSplitAction, SIGNAL(triggered()), this, SLOT(switchHeaderSourceInNextSplit())); + return true; } @@ -157,33 +163,18 @@ ExtensionSystem::IPlugin::ShutdownFlag CppToolsPlugin::aboutToShutdown() void CppToolsPlugin::switchHeaderSource() { - Core::IEditor *editor = Core::EditorManager::currentEditor(); - QString otherFile = correspondingHeaderOrSource(editor->document()->fileName()); - if (otherFile.isEmpty()) - return; - - Core::EditorManager* editorManager = Core::EditorManager::instance(); - editorManager->addCurrentPositionToNavigationHistory(); - TextEditor::BaseTextEditorWidget *ed = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget()); - if (editorManager->hasSplitter()) { - if (ed->forceOpenLinksInNextSplit()) { - editorManager->gotoOtherSplit(); - } else if (ed->openLinksInNextSplit()) { - bool isVisible = false; - foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) { - if (visEditor->document() && - (otherFile == visEditor->document()->fileName())) { - isVisible = true; - editorManager->activateEditor(visEditor); - break; - } - } + QString otherFile = correspondingHeaderOrSource( + Core::EditorManager::currentEditor()->document()->fileName()); + if (!otherFile.isEmpty()) + Core::EditorManager::openEditor(otherFile); +} - if (!isVisible) - editorManager->gotoOtherSplit(); - } - } - Core::EditorManager::openEditor(otherFile); +void CppToolsPlugin::switchHeaderSourceInNextSplit() +{ + QString otherFile = correspondingHeaderOrSource( + Core::EditorManager::currentEditor()->document()->fileName()); + if (!otherFile.isEmpty()) + Core::EditorManager::openEditorInNextSplit(otherFile); } static QStringList findFilesInProject(const QString &name, |