summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cpptoolsplugin.cpp
diff options
context:
space:
mode:
authorPetar Perisin <petar.perisin@gmail.com>2012-11-01 03:43:28 +0100
committerDavid Schulz <david.schulz@digia.com>2013-01-11 12:48:44 +0100
commit39e9c5ef20df0b75eb8b5a1b27af609fa7ff20e3 (patch)
tree7d5fe369677aa4b2f2360ec3c359ecb7a346640f /src/plugins/cpptools/cpptoolsplugin.cpp
parentc0e7b65db3dafcd6e50756133b39b31701903494 (diff)
downloadqt-creator-39e9c5ef20df0b75eb8b5a1b27af609fa7ff20e3.tar.gz
Editor: Allow to open links in a new split.
This changes current behavior while opening links. Link is now opened in next split by default. If you use CTRL+Click to open links, it will also open in next split. However, by using CTRL+ALT+click it will open in current split. There are two new checkboxes in Tools/Options/Text Editor/Display: - "Open Links in New Split" - if it is checked, links will not be opened in current split. However, if document with link is already opened, it will be used to open the split - "Force open links in next split" - Links will always open in next split, even if their document is already opened somewhere else. Task-number: QTCREATORBUG-8117 Change-Id: Ib99075b55d9e9683ed2c2386767227457de0a3fc Reviewed-by: David Schulz <david.schulz@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cpptoolsplugin.cpp')
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp
index 8c9b35d893..db50b07380 100644
--- a/src/plugins/cpptools/cpptoolsplugin.cpp
+++ b/src/plugins/cpptools/cpptoolsplugin.cpp
@@ -55,6 +55,7 @@
#include <coreplugin/vcsmanager.h>
#include <coreplugin/documentmanager.h>
#include <cppeditor/cppeditorconstants.h>
+#include <texteditor/basetexteditor.h>
#include <QtConcurrentRun>
#include <QFutureSynchronizer>
@@ -158,8 +159,31 @@ void CppToolsPlugin::switchHeaderSource()
{
Core::IEditor *editor = Core::EditorManager::currentEditor();
QString otherFile = correspondingHeaderOrSource(editor->document()->fileName());
- if (!otherFile.isEmpty())
- Core::EditorManager::openEditor(otherFile);
+ 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;
+ }
+ }
+
+ if (!isVisible)
+ editorManager->gotoOtherSplit();
+ }
+ }
+ Core::EditorManager::openEditor(otherFile);
}
static QStringList findFilesInProject(const QString &name,