aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@digia.com>2013-02-05 14:14:33 +0100
committerDavid Schulz <david.schulz@digia.com>2013-02-14 09:46:16 +0100
commit6ef0cf1a30f1c31d24363fa5ab7a3673f7886126 (patch)
tree6b988785304e03eb728196a98e37e4462c164fde /src
parenta37770ba3b05c480338d2a1fe08f9677249aeb8f (diff)
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')
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp46
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.h2
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp86
-rw-r--r--src/plugins/cppeditor/cppeditor.h6
-rw-r--r--src/plugins/cppeditor/cppeditorconstants.h1
-rw-r--r--src/plugins/cppeditor/cppplugin.cpp21
-rw-r--r--src/plugins/cppeditor/cppplugin.h1
-rw-r--r--src/plugins/cpptools/cpptoolsconstants.h1
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.cpp43
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.h1
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp85
-rw-r--r--src/plugins/texteditor/basetexteditor.h10
-rw-r--r--src/plugins/texteditor/displaysettings.cpp3
-rw-r--r--src/plugins/texteditor/displaysettingspage.cpp13
-rw-r--r--src/plugins/texteditor/displaysettingspage.h3
-rw-r--r--src/plugins/texteditor/displaysettingspage.ui29
-rw-r--r--src/plugins/texteditor/texteditoractionhandler.cpp15
-rw-r--r--src/plugins/texteditor/texteditoractionhandler.h3
-rw-r--r--src/plugins/texteditor/texteditorconstants.h2
19 files changed, 148 insertions, 223 deletions
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index d961e59132..e9e94de347 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1268,7 +1268,18 @@ Core::Id EditorManager::getOpenWithEditorId(const QString &fileName,
IEditor *EditorManager::openEditor(const QString &fileName, const Id &editorId,
OpenEditorFlags flags, bool *newEditor)
{
- return m_instance->openEditor(m_instance->currentEditorView(), fileName, editorId, flags, newEditor);
+ return m_instance->openEditor(m_instance->currentEditorView(),
+ fileName, editorId, flags, newEditor);
+}
+
+IEditor *EditorManager::openEditorInNextSplit(const QString &fileName, const Id &editorId, OpenEditorFlags flags, bool *newEditor)
+{
+ if (!m_instance->hasSplitter())
+ m_instance->splitSideBySide();
+
+ m_instance->gotoOtherSplit();
+ return m_instance->openEditor(m_instance->currentEditorView(),
+ fileName, editorId, flags, newEditor);
}
static int extractLineNumber(QString *fileName)
@@ -2237,22 +2248,23 @@ void EditorManager::removeAllSplits()
void EditorManager::gotoOtherSplit()
{
- if (d->m_splitter->isSplitter()) {
- SplitterOrView *currentView = d->m_currentView;
- if (!currentView && d->m_currentEditor)
- currentView = d->m_splitter->findView(d->m_currentEditor);
- if (!currentView)
- currentView = d->m_splitter->findFirstView();
- SplitterOrView *view = d->m_splitter->findNextView(currentView);
- if (!view)
- view = d->m_splitter->findFirstView();
- if (view) {
- if (IEditor *editor = view->editor()) {
- setCurrentEditor(editor, true);
- editor->widget()->setFocus();
- } else {
- setCurrentView(view);
- }
+ if (!d->m_splitter->isSplitter())
+ splitSideBySide();
+
+ SplitterOrView *currentView = d->m_currentView;
+ if (!currentView && d->m_currentEditor)
+ currentView = d->m_splitter->findView(d->m_currentEditor);
+ if (!currentView)
+ currentView = d->m_splitter->findFirstView();
+ SplitterOrView *view = d->m_splitter->findNextView(currentView);
+ if (!view)
+ view = d->m_splitter->findFirstView();
+ if (view) {
+ if (IEditor *editor = view->editor()) {
+ setCurrentEditor(editor, true);
+ editor->widget()->setFocus();
+ } else {
+ setCurrentView(view);
}
}
}
diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h
index 3a54a38501..87ffc48cf5 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.h
+++ b/src/plugins/coreplugin/editormanager/editormanager.h
@@ -117,6 +117,8 @@ public:
static QString splitLineNumber(QString *fileName);
static IEditor *openEditor(const QString &fileName, const Id &editorId = Id(),
OpenEditorFlags flags = 0, bool *newEditor = 0);
+ static IEditor *openEditorInNextSplit(const QString &fileName, const Id &editorId = Id(),
+ OpenEditorFlags flags = 0, bool *newEditor = 0);
static IEditor *openEditorWithContents(const Id &editorId,
QString *titlePattern = 0, const QString &contents = QString());
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 18485a9616..3b95620620 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -1127,7 +1127,7 @@ void CPPEditorWidget::finishHighlightSymbolUsages()
}
-void CPPEditorWidget::switchDeclarationDefinition()
+void CPPEditorWidget::switchDeclarationDefinition(bool inNextSplit)
{
if (! m_modelManager)
return;
@@ -1146,7 +1146,7 @@ void CPPEditorWidget::switchDeclarationDefinition()
if (! function)
function = lastVisibleSymbol->enclosingFunction();
- Core::EditorManager* editorManager = Core::EditorManager::instance();
+ CPPEditorWidget::Link symbolLink;
if (function) {
LookupContext context(thisDocument, snapshot);
@@ -1168,62 +1168,18 @@ void CPPEditorWidget::switchDeclarationDefinition()
}
}
}
- 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.targetFileName == 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)) {
- Core::IEditor *editor = editorManager->currentEditor();
- CPPEditorWidget::Link symbolLink = linkToSymbol(def);
- if (editorManager->hasSplitter() && (editor->document()->fileName() != symbolLink.targetFileName)) {
- if (forceOpenLinksInNextSplit()) {
- editorManager->gotoOtherSplit();
- } else if (openLinksInNextSplit()) {
- bool isVisible = false;
- foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
- if (visEditor->document()
- && (symbolLink.targetFileName == visEditor->document()->fileName())
- && (visEditor != editor)) {
- isVisible = true;
- editorManager->activateEditor(visEditor);
- break;
- }
- }
-
- if (!isVisible)
- editorManager->gotoOtherSplit();
- } else {
- editorManager->addCurrentPositionToNavigationHistory();
- }
- }
-
- openCppEditorAt(symbolLink);
- }
+ if (best.isEmpty())
+ return;
+
+ symbolLink = linkToSymbol(best.first());
+ } else if (lastVisibleSymbol
+ && lastVisibleSymbol->isDeclaration()
+ && lastVisibleSymbol->type()->isFunctionType()) {
+ symbolLink = linkToSymbol(symbolFinder()->findMatchingDefinition(lastVisibleSymbol, snapshot));
}
+
+ if (symbolLink.hasValidTarget())
+ openCppEditorAt(symbolLink, inNextSplit != alwaysOpenLinksInNextSplit());
}
}
@@ -1937,11 +1893,23 @@ CPPEditorWidget::Link CPPEditorWidget::linkToSymbol(CPlusPlus::Symbol *symbol)
return Link(filename, line, column);
}
-bool CPPEditorWidget::openCppEditorAt(const Link &link)
+bool CPPEditorWidget::openCppEditorAt(const Link &link, bool inNextSplit)
{
- if (link.targetFileName.isEmpty())
+ if (!link.hasValidTarget())
return false;
+ Core::EditorManager *editorManager = Core::EditorManager::instance();
+ if (inNextSplit) {
+ if (!editorManager->hasSplitter())
+ editorManager->splitSideBySide();
+ editorManager->gotoOtherSplit();
+ } else if (baseTextDocument()->fileName() == link.targetFileName) {
+ editorManager->addCurrentPositionToNavigationHistory();
+ gotoLine(link.targetLine, link.targetColumn);
+ setFocus();
+ return true;
+ }
+
return TextEditor::BaseTextEditorWidget::openEditorAt(link.targetFileName,
link.targetLine,
link.targetColumn,
diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h
index 51ab415ba2..d471f7a425 100644
--- a/src/plugins/cppeditor/cppeditor.h
+++ b/src/plugins/cppeditor/cppeditor.h
@@ -186,7 +186,7 @@ public:
void setObjCEnabled(bool onoff);
bool isObjCEnabled() const;
- bool openLink(const Link &link) { return openCppEditorAt(link); }
+ bool openLink(const Link &link, bool inNextSplit) { return openCppEditorAt(link, inNextSplit); }
static Link linkToSymbol(CPlusPlus::Symbol *symbol);
@@ -205,7 +205,7 @@ public Q_SLOTS:
virtual void setFontSettings(const TextEditor::FontSettings &);
virtual void setTabSettings(const TextEditor::TabSettings &);
void setSortedOutline(bool sort);
- void switchDeclarationDefinition();
+ void switchDeclarationDefinition(bool inNextSplit);
void renameSymbolUnderCursor();
void renameUsages();
void findUsages();
@@ -281,7 +281,7 @@ private:
Link findMacroLink(const QByteArray &name, CPlusPlus::Document::Ptr doc, const CPlusPlus::Snapshot &snapshot,
QSet<QString> *processed) const;
QString identifierUnderCursor(QTextCursor *macroCursor) const;
- bool openCppEditorAt(const Link &);
+ bool openCppEditorAt(const Link &, bool inNextSplit = false);
QModelIndex indexForPosition(int line, int column, const QModelIndex &rootIndex = QModelIndex()) const;
diff --git a/src/plugins/cppeditor/cppeditorconstants.h b/src/plugins/cppeditor/cppeditorconstants.h
index 9f5d6b315d..f8263f4a9b 100644
--- a/src/plugins/cppeditor/cppeditorconstants.h
+++ b/src/plugins/cppeditor/cppeditorconstants.h
@@ -38,6 +38,7 @@ const char C_CPPEDITOR[] = "CppPlugin.C++Editor";
const char CPPEDITOR_ID[] = "CppPlugin.C++Editor";
const char CPPEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "C++ Editor");
const char SWITCH_DECLARATION_DEFINITION[] = "CppEditor.SwitchDeclarationDefinition";
+const char OPEN_DECLARATION_DEFINITION_IN_NEXT_SPLIT[] = "CppEditor.OpenDeclarationDefinitionInNextSplit";
const char RENAME_SYMBOL_UNDER_CURSOR[] = "CppEditor.RenameSymbolUnderCursor";
const char FIND_USAGES[] = "CppEditor.FindUsages";
const char M_REFACTORING_MENU_INSERTION_POINT[] = "CppEditor.RefactorGroup";
diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp
index b0cfea6c72..0210d8a8df 100644
--- a/src/plugins/cppeditor/cppplugin.cpp
+++ b/src/plugins/cppeditor/cppplugin.cpp
@@ -235,6 +235,18 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
+ cmd = Core::ActionManager::command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR_IN_NEXT_SPLIT);
+ cppToolsMenu->addAction(cmd);
+
+ QAction *openDeclarationDefinitionInNextSplit =
+ new QAction(tr("Open Method Declaration/Definition In Next Split"), this);
+ cmd = Core::ActionManager::registerAction(openDeclarationDefinitionInNextSplit,
+ Constants::OPEN_DECLARATION_DEFINITION_IN_NEXT_SPLIT, context, true);
+ cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_E, Qt::Key_Shift + Qt::Key_F2));
+ connect(openDeclarationDefinitionInNextSplit, SIGNAL(triggered()),
+ this, SLOT(openDeclarationDefinitionInNextSplit()));
+ cppToolsMenu->addAction(cmd);
+
m_findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = Core::ActionManager::registerAction(m_findUsagesAction, Constants::FIND_USAGES, context);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
@@ -324,7 +336,14 @@ void CppPlugin::switchDeclarationDefinition()
{
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(Core::EditorManager::currentEditor()->widget());
if (editor)
- editor->switchDeclarationDefinition();
+ editor->switchDeclarationDefinition(/*inNextSplit*/ false);
+}
+
+void CppPlugin::openDeclarationDefinitionInNextSplit()
+{
+ CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(Core::EditorManager::currentEditor()->widget());
+ if (editor)
+ editor->switchDeclarationDefinition(/*inNextSplit*/ true);
}
void CppPlugin::renameSymbolUnderCursor()
diff --git a/src/plugins/cppeditor/cppplugin.h b/src/plugins/cppeditor/cppplugin.h
index 9441403f83..fca9c54de8 100644
--- a/src/plugins/cppeditor/cppplugin.h
+++ b/src/plugins/cppeditor/cppplugin.h
@@ -80,6 +80,7 @@ public slots:
private slots:
void switchDeclarationDefinition();
+ void openDeclarationDefinitionInNextSplit();
void renameSymbolUnderCursor();
void onTaskStarted(const QString &type);
void onAllTasksFinished(const QString &type);
diff --git a/src/plugins/cpptools/cpptoolsconstants.h b/src/plugins/cpptools/cpptoolsconstants.h
index 62d214dce8..746936d600 100644
--- a/src/plugins/cpptools/cpptoolsconstants.h
+++ b/src/plugins/cpptools/cpptoolsconstants.h
@@ -37,6 +37,7 @@ namespace Constants {
const char M_TOOLS_CPP[] = "CppTools.Tools.Menu";
const char SWITCH_HEADER_SOURCE[] = "CppTools.SwitchHeaderSource";
+const char OPEN_HEADER_SOURCE_IN_NEXT_SPLIT[] = "CppTools.OpenHeaderSourceInNextSplit";
const char TASK_INDEX[] = "CppTools.Task.Index";
const char TASK_SEARCH[] = "CppTools.Task.Search";
const char C_SOURCE_MIMETYPE[] = "text/x-csrc";
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,
diff --git a/src/plugins/cpptools/cpptoolsplugin.h b/src/plugins/cpptools/cpptoolsplugin.h
index 9bb89b6707..d132ecce67 100644
--- a/src/plugins/cpptools/cpptoolsplugin.h
+++ b/src/plugins/cpptools/cpptoolsplugin.h
@@ -74,6 +74,7 @@ public:
private slots:
void switchHeaderSource();
+ void switchHeaderSourceInNextSplit();
#ifdef WITH_TESTS
void test_codegen_public_in_empty_class();
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 5b9cf4d86d..ee04b52f4d 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -1079,35 +1079,16 @@ void BaseTextEditorWidget::unindent()
void BaseTextEditorWidget::openLinkUnderCursor()
{
- Core::EditorManager* editorManager = Core::EditorManager::instance();
Link symbolLink = findLinkAt(textCursor());
- if (!openLinksInNextSplit() || !editorManager->hasSplitter()) {
- openLink(symbolLink);
- return;
- }
-
- Core::IEditor *editor = Core::EditorManager::currentEditor();
+ openLink(symbolLink, alwaysOpenLinksInNextSplit());
+}
- if (forceOpenLinksInNextSplit()) {
- editorManager->gotoOtherSplit();
- } else {
- bool isVisible = false;
- foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
- if (visEditor->document() &&
- (symbolLink.targetFileName == visEditor->document()->fileName()) &&
- (visEditor != editor)) {
- isVisible = true;
- editorManager->activateEditor(visEditor);
- break;
- }
- }
+void BaseTextEditorWidget::openLinkUnderCursorInNextSplit()
+{
+ Link symbolLink = findLinkAt(textCursor());
- if (!isVisible)
- editorManager->gotoOtherSplit();
- }
- openLink(symbolLink);
- editorManager->activateEditor(editor);
+ openLink(symbolLink, !alwaysOpenLinksInNextSplit());
}
void BaseTextEditorWidget::moveLineUpDown(bool up)
@@ -2336,25 +2317,16 @@ bool BaseTextEditorWidget::lineNumbersVisible() const
return d->m_lineNumbersVisible;
}
-void BaseTextEditorWidget::setOpenLinksInNextSplit(bool b)
+void BaseTextEditorWidget::setAlwaysOpenLinksInNextSplit(bool b)
{
d->m_displaySettings.m_openLinksInNextSplit = b;
}
-bool BaseTextEditorWidget::openLinksInNextSplit() const
+bool BaseTextEditorWidget::alwaysOpenLinksInNextSplit() const
{
return d->m_displaySettings.m_openLinksInNextSplit;
}
-void BaseTextEditorWidget::setForceOpenLinksInNextSplit(bool b)
-{
- d->m_displaySettings.m_forceOpenLinksInNextSplit = b;
-}
-
-bool BaseTextEditorWidget::forceOpenLinksInNextSplit() const
-{
- return d->m_displaySettings.m_forceOpenLinksInNextSplit;
-}
void BaseTextEditorWidget::setMarksVisible(bool b)
{
@@ -4315,32 +4287,10 @@ void BaseTextEditorWidget::mouseReleaseEvent(QMouseEvent *e)
&& e->button() == Qt::LeftButton
) {
- Core::EditorManager* editorManager = Core::EditorManager::instance();
- editorManager->addCurrentPositionToNavigationHistory();
- Core::IEditor *editor = Core::EditorManager::currentEditor();
- const QTextCursor cursor = cursorForPosition(e->pos());
- Link symbolLink = findLinkAt(cursor);
- if (((!(e->modifiers() & Qt::AltModifier)) == openLinksInNextSplit()) &&
- (editorManager->hasSplitter())) {
- if (forceOpenLinksInNextSplit()) {
- editorManager->gotoOtherSplit();
- } else {
- bool isVisible = false;
- foreach (Core::IEditor *visEditor, editorManager->visibleEditors())
- if (visEditor->document() &&
- (symbolLink.targetFileName == visEditor->document()->fileName()) &&
- (editor != visEditor)) {
- isVisible = true;
- editorManager->activateEditor(visEditor);
- break;
- }
-
- if (!isVisible)
- editorManager->gotoOtherSplit();
- }
- }
-
- if (openLink(symbolLink)) {
+ Core::EditorManager::instance()->addCurrentPositionToNavigationHistory();
+ bool inNextSplit = ((e->modifiers() & Qt::AltModifier) && !alwaysOpenLinksInNextSplit())
+ || (alwaysOpenLinksInNextSplit() && !(e->modifiers() & Qt::AltModifier));
+ if (openLink(findLinkAt(cursorForPosition(e->pos())), inNextSplit)) {
clearLink();
return;
}
@@ -4909,13 +4859,18 @@ BaseTextEditorWidget::Link BaseTextEditorWidget::findLinkAt(const QTextCursor &,
return Link();
}
-bool BaseTextEditorWidget::openLink(const Link &link)
+bool BaseTextEditorWidget::openLink(const Link &link, bool inNextSplit)
{
if (!link.hasValidTarget())
return false;
- if (baseTextDocument()->fileName() == link.targetFileName) {
- Core::EditorManager::instance()->addCurrentPositionToNavigationHistory();
+ Core::EditorManager *editorManager = Core::EditorManager::instance();
+ if (inNextSplit) {
+ if (!editorManager->hasSplitter())
+ editorManager->splitSideBySide();
+ editorManager->gotoOtherSplit();
+ } else if (baseTextDocument()->fileName() == link.targetFileName) {
+ editorManager->addCurrentPositionToNavigationHistory();
gotoLine(link.targetLine, link.targetColumn);
setFocus();
return true;
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index 2fc63eb394..ffc9782cb1 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -181,11 +181,8 @@ public:
void setLineNumbersVisible(bool b);
bool lineNumbersVisible() const;
- void setOpenLinksInNextSplit(bool b);
- bool openLinksInNextSplit() const;
-
- void setForceOpenLinksInNextSplit(bool b);
- bool forceOpenLinksInNextSplit() const;
+ void setAlwaysOpenLinksInNextSplit(bool b);
+ bool alwaysOpenLinksInNextSplit() const;
void setMarksVisible(bool b);
bool marksVisible() const;
@@ -333,6 +330,7 @@ public slots:
void unindent();
void openLinkUnderCursor();
+ void openLinkUnderCursorInNextSplit();
signals:
void changed();
@@ -530,7 +528,7 @@ protected:
Reimplement this function if you want to customize the way a link is
opened. Returns whether the link was opened successfully.
*/
- virtual bool openLink(const Link &link);
+ virtual bool openLink(const Link &link, bool inNextSplit = false);
void maybeClearSomeExtraSelections(const QTextCursor &cursor);
diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp
index 709a85fa23..7d2569bed1 100644
--- a/src/plugins/texteditor/displaysettings.cpp
+++ b/src/plugins/texteditor/displaysettings.cpp
@@ -46,7 +46,6 @@ static const char markTextChangesKey[] = "MarkTextChanges";
static const char autoFoldFirstCommentKey[] = "AutoFoldFirstComment";
static const char centerCursorOnScrollKey[] = "CenterCursorOnScroll";
static const char openLinksInNextSplitKey[] = "OpenLinksInNextSplitKey";
-static const char forceOpenLinksInNextSplitKey[] = "ForceOpenLinksInNextSplitKey";
static const char groupPostfix[] = "DisplaySettings";
namespace TextEditor {
@@ -90,7 +89,6 @@ void DisplaySettings::toSettings(const QString &category, QSettings *s) const
s->setValue(QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment);
s->setValue(QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll);
s->setValue(QLatin1String(openLinksInNextSplitKey), m_openLinksInNextSplit);
- s->setValue(QLatin1String(forceOpenLinksInNextSplitKey), m_forceOpenLinksInNextSplit);
s->endGroup();
}
@@ -117,7 +115,6 @@ void DisplaySettings::fromSettings(const QString &category, const QSettings *s)
m_autoFoldFirstComment = s->value(group + QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment).toBool();
m_centerCursorOnScroll = s->value(group + QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll).toBool();
m_openLinksInNextSplit = s->value(group + QLatin1String(openLinksInNextSplitKey), m_openLinksInNextSplit).toBool();
- m_forceOpenLinksInNextSplit = s->value(group + QLatin1String(forceOpenLinksInNextSplitKey), m_forceOpenLinksInNextSplit).toBool();
}
bool DisplaySettings::equals(const DisplaySettings &ds) const
diff --git a/src/plugins/texteditor/displaysettingspage.cpp b/src/plugins/texteditor/displaysettingspage.cpp
index ed3904db25..dddd5e2535 100644
--- a/src/plugins/texteditor/displaysettingspage.cpp
+++ b/src/plugins/texteditor/displaysettingspage.cpp
@@ -74,7 +74,6 @@ QWidget *DisplaySettingsPage::createPage(QWidget *parent)
QWidget *w = new QWidget(parent);
d->m_page = new Internal::Ui::DisplaySettingsPage;
d->m_page->setupUi(w);
- connect(d->m_page->openLinksInNextSplit, SIGNAL(toggled(bool)), this, SLOT(updateForceOpenLinksInNextSplit(bool)));
settingsToUI();
if (d->m_searchKeywords.isEmpty()) {
QTextStream(&d->m_searchKeywords) << d->m_page->displayLineNumbers->text()
@@ -87,8 +86,7 @@ QWidget *DisplaySettingsPage::createPage(QWidget *parent)
<< ' ' << d->m_page->enableTextWrapping->text()
<< ' ' << d->m_page->autoFoldFirstComment->text()
<< ' ' << d->m_page->centerOnScroll->text()
- << ' ' << d->m_page->openLinksInNextSplit->text()
- << ' ' << d->m_page->forceOpenLinksInNextSplit->text();
+ << ' ' << d->m_page->openLinksInNextSplit->text();
d->m_searchKeywords.remove(QLatin1Char('&'));
}
return w;
@@ -112,13 +110,6 @@ void DisplaySettingsPage::finish()
d->m_page = 0;
}
-void DisplaySettingsPage::updateForceOpenLinksInNextSplit(bool openLinksInNextSplitChecked)
-{
- d->m_page->forceOpenLinksInNextSplit->setEnabled(openLinksInNextSplitChecked);
- if (!openLinksInNextSplitChecked)
- d->m_page->forceOpenLinksInNextSplit->setChecked(openLinksInNextSplitChecked);
-}
-
void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
{
displaySettings.m_displayLineNumbers = d->m_page->displayLineNumbers->isChecked();
@@ -135,7 +126,6 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
displaySettings.m_autoFoldFirstComment = d->m_page->autoFoldFirstComment->isChecked();
displaySettings.m_centerCursorOnScroll = d->m_page->centerOnScroll->isChecked();
displaySettings.m_openLinksInNextSplit = d->m_page->openLinksInNextSplit->isChecked();
- displaySettings.m_forceOpenLinksInNextSplit = d->m_page->forceOpenLinksInNextSplit->isChecked();
}
void DisplaySettingsPage::settingsToUI()
@@ -155,7 +145,6 @@ void DisplaySettingsPage::settingsToUI()
d->m_page->autoFoldFirstComment->setChecked(displaySettings.m_autoFoldFirstComment);
d->m_page->centerOnScroll->setChecked(displaySettings.m_centerCursorOnScroll);
d->m_page->openLinksInNextSplit->setChecked(displaySettings.m_openLinksInNextSplit);
- d->m_page->forceOpenLinksInNextSplit->setChecked(displaySettings.m_forceOpenLinksInNextSplit);
}
const DisplaySettings &DisplaySettingsPage::displaySettings() const
diff --git a/src/plugins/texteditor/displaysettingspage.h b/src/plugins/texteditor/displaysettingspage.h
index 2b4886dd3e..802e303277 100644
--- a/src/plugins/texteditor/displaysettingspage.h
+++ b/src/plugins/texteditor/displaysettingspage.h
@@ -65,9 +65,6 @@ public:
signals:
void displaySettingsChanged(const TextEditor::DisplaySettings &);
-private slots:
- void updateForceOpenLinksInNextSplit(bool openLinksInNextSplitChecked);
-
private:
void settingsFromUI(DisplaySettings &displaySettings) const;
void settingsToUI();
diff --git a/src/plugins/texteditor/displaysettingspage.ui b/src/plugins/texteditor/displaysettingspage.ui
index 61527ec1d1..ce3697ad3d 100644
--- a/src/plugins/texteditor/displaysettingspage.ui
+++ b/src/plugins/texteditor/displaysettingspage.ui
@@ -156,37 +156,10 @@
<item row="5" column="1">
<widget class="QCheckBox" name="openLinksInNextSplit">
<property name="text">
- <string>Open links in another split</string>
+ <string>Always open links in another split</string>
</property>
</widget>
</item>
- <item row="6" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QCheckBox" name="forceOpenLinksInNextSplit">
- <property name="text">
- <string>Force open links in next split</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</widget>
</item>
diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp
index 80c90d9012..6c1b47d875 100644
--- a/src/plugins/texteditor/texteditoractionhandler.cpp
+++ b/src/plugins/texteditor/texteditoractionhandler.cpp
@@ -103,7 +103,9 @@ TextEditorActionHandler::TextEditorActionHandler(const char *context,
m_indentAction(0),
m_unindentAction(0),
m_followSymbolAction(0),
+ m_followSymbolInNextSplitAction(0),
m_jumpToFileAction(0),
+ m_jumpToFileInNextSplitAction(0),
m_optionalActions(optionalActions),
m_currentEditor(0),
m_contextId(context),
@@ -389,11 +391,21 @@ void TextEditorActionHandler::createActions()
command->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
connect(m_followSymbolAction, SIGNAL(triggered()), this, SLOT(openLinkUnderCursor()));
+ m_followSymbolInNextSplitAction = new QAction(tr("Follow Symbol Under Cursor In Next Split"), this);
+ command = Core::ActionManager::registerAction(m_followSymbolInNextSplitAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR_IN_NEXT_SPLIT, m_contextId, true);
+ command->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_E, Qt::Key_F2));
+ connect(m_followSymbolInNextSplitAction, SIGNAL(triggered()), this, SLOT(openLinkUnderCursorInNextSplit()));
+
m_jumpToFileAction = new QAction(tr("Jump To File Under Cursor"), this);
command = Core::ActionManager::registerAction(m_jumpToFileAction, Constants::JUMP_TO_FILE_UNDER_CURSOR, m_contextId, true);
command->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
connect(m_jumpToFileAction, SIGNAL(triggered()), this, SLOT(openLinkUnderCursor()));
+ m_jumpToFileInNextSplitAction = new QAction(tr("Jump To File Under Cursor In Next Split"), this);
+ command = Core::ActionManager::registerAction(m_jumpToFileInNextSplitAction, Constants::JUMP_TO_FILE_UNDER_CURSOR_IN_NEXT_SPLIT, m_contextId, true);
+ command->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_E, Qt::Key_F2));
+ connect(m_jumpToFileInNextSplitAction, SIGNAL(triggered()), this, SLOT(openLinkUnderCursorInNextSplit()));
+
QAction *a = 0;
a = new QAction(tr("Go to Line Start"), this);
command = Core::ActionManager::registerAction(a, Constants::GOTO_LINE_START, m_contextId, true);
@@ -508,7 +520,9 @@ void TextEditorActionHandler::updateActions(UpdateMode um)
m_formatAction->setEnabled((m_optionalActions & Format) && um != ReadOnlyMode);
m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && um != ReadOnlyMode);
m_followSymbolAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor);
+ m_followSymbolInNextSplitAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor);
m_jumpToFileAction->setEnabled(m_optionalActions & JumpToFileUnderCursor);
+ m_jumpToFileInNextSplitAction->setEnabled(m_optionalActions & JumpToFileUnderCursor);
m_unfoldAllAction->setEnabled((m_optionalActions & UnCollapseAll));
m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace);
@@ -632,6 +646,7 @@ FUNCTION(insertLineBelow)
FUNCTION(indent)
FUNCTION(unindent)
FUNCTION(openLinkUnderCursor)
+FUNCTION(openLinkUnderCursorInNextSplit)
FUNCTION(gotoLineStart)
FUNCTION(gotoLineStartWithSelection)
diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h
index 5d40cd8a58..0a8f510b43 100644
--- a/src/plugins/texteditor/texteditoractionhandler.h
+++ b/src/plugins/texteditor/texteditoractionhandler.h
@@ -141,6 +141,7 @@ private slots:
void indent();
void unindent();
void openLinkUnderCursor();
+ void openLinkUnderCursorInNextSplit();
void gotoLineStart();
void gotoLineStartWithSelection();
@@ -213,7 +214,9 @@ private:
QAction *m_indentAction;
QAction *m_unindentAction;
QAction *m_followSymbolAction;
+ QAction *m_followSymbolInNextSplitAction;
QAction *m_jumpToFileAction;
+ QAction *m_jumpToFileInNextSplitAction;
QList<QAction *> m_modifyingActions;
uint m_optionalActions;
diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h
index fc487f7c4c..39e656afcd 100644
--- a/src/plugins/texteditor/texteditorconstants.h
+++ b/src/plugins/texteditor/texteditorconstants.h
@@ -159,7 +159,9 @@ const char SWITCH_UTF8BOM[] = "TextEditor.SwitchUtf8bom";
const char INDENT[] = "TextEditor.Indent";
const char UNINDENT[] = "TextEditor.Unindent";
const char FOLLOW_SYMBOL_UNDER_CURSOR[] = "TextEditor.FollowSymbolUnderCursor";
+const char FOLLOW_SYMBOL_UNDER_CURSOR_IN_NEXT_SPLIT[] = "TextEditor.FollowSymbolUnderCursorInNextSplit";
const char JUMP_TO_FILE_UNDER_CURSOR[] = "TextEditor.JumpToFileUnderCursor";
+const char JUMP_TO_FILE_UNDER_CURSOR_IN_NEXT_SPLIT[] = "TextEditor.JumpToFileUnderCursorInNextSplit";
const char *nameForStyle(TextStyle style);
TextStyle styleFromName(const char *name);