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>
This commit is contained in:
Petar Perisin
2012-11-01 03:43:28 +01:00
committed by David Schulz
parent c0e7b65db3
commit 39e9c5ef20
10 changed files with 276 additions and 51 deletions

View File

@@ -1108,6 +1108,8 @@ void CPPEditorWidget::switchDeclarationDefinition()
if (! function)
function = lastVisibleSymbol->enclosingFunction();
Core::EditorManager* editorManager = Core::EditorManager::instance();
if (function) {
LookupContext context(thisDocument, snapshot);
@@ -1128,12 +1130,61 @@ void CPPEditorWidget::switchDeclarationDefinition()
}
}
}
if (! best.isEmpty())
openCppEditorAt(linkToSymbol(best.first()));
if (! best.isEmpty()) {
Core::IEditor *editor = editorManager->currentEditor();
CPPEditorWidget::Link symbolLink = linkToSymbol(best.first());
if (editorManager->hasSplitter()) {
if (forceOpenLinksInNextSplit()) {
editorManager->gotoOtherSplit();
} else if (openLinksInNextSplit()) {
bool isVisible = false;
foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
if (visEditor->document() &&
(symbolLink.fileName == visEditor->document()->fileName()) &&
(visEditor != editor)) {
isVisible = true;
editorManager->activateEditor(visEditor);
break;
}
}
if (!isVisible)
editorManager->gotoOtherSplit();
} else {
editorManager->addCurrentPositionToNavigationHistory();
}
}
openCppEditorAt(symbolLink);
}
} else if (lastVisibleSymbol && lastVisibleSymbol->isDeclaration() && lastVisibleSymbol->type()->isFunctionType()) {
if (Symbol *def = symbolFinder()->findMatchingDefinition(lastVisibleSymbol, snapshot, true))
openCppEditorAt(linkToSymbol(def));
if (Symbol *def = symbolFinder()->findMatchingDefinition(lastVisibleSymbol, snapshot)) {
Core::IEditor *editor = editorManager->currentEditor();
CPPEditorWidget::Link symbolLink = linkToSymbol(def);
if (editorManager->hasSplitter() && (editor->document()->fileName() != symbolLink.fileName)) {
if (forceOpenLinksInNextSplit()) {
editorManager->gotoOtherSplit();
} else if (openLinksInNextSplit()) {
bool isVisible = false;
foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
if (visEditor->document() &&
(symbolLink.fileName == visEditor->document()->fileName()) &&
(visEditor != editor)) {
isVisible = true;
editorManager->activateEditor(visEditor);
break;
}
}
if (!isVisible)
editorManager->gotoOtherSplit();
} else {
editorManager->addCurrentPositionToNavigationHistory();
}
}
openCppEditorAt(symbolLink);
}
}
}
}