forked from qt-creator/qt-creator
Fix follow symbol in next split, and simplify code
Follow symbol in next split broke with fd9b2af921
because the flag was no longer handled through EditorManager::openEditorAt
Also remove the flag NoNewSplits which is no longer used, and simplify
how links are opened from the C++ editor.
Change-Id: I845cc3a0a43d82b79d5c46a273232b69fd6e3ea9
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -2221,12 +2221,8 @@ EditorManager::ExternalEditorList
|
|||||||
IEditor *EditorManager::openEditor(const QString &fileName, Id editorId,
|
IEditor *EditorManager::openEditor(const QString &fileName, Id editorId,
|
||||||
OpenEditorFlags flags, bool *newEditor)
|
OpenEditorFlags flags, bool *newEditor)
|
||||||
{
|
{
|
||||||
if (flags & EditorManager::OpenInOtherSplit) {
|
if (flags & EditorManager::OpenInOtherSplit)
|
||||||
if (flags & EditorManager::NoNewSplits)
|
|
||||||
EditorManagerPrivate::gotoNextSplit();
|
|
||||||
else
|
|
||||||
EditorManager::gotoOtherSplit();
|
EditorManager::gotoOtherSplit();
|
||||||
}
|
|
||||||
|
|
||||||
return EditorManagerPrivate::openEditor(EditorManagerPrivate::currentEditorView(),
|
return EditorManagerPrivate::openEditor(EditorManagerPrivate::currentEditorView(),
|
||||||
fileName, editorId, flags, newEditor);
|
fileName, editorId, flags, newEditor);
|
||||||
@@ -2235,6 +2231,9 @@ IEditor *EditorManager::openEditor(const QString &fileName, Id editorId,
|
|||||||
IEditor *EditorManager::openEditorAt(const QString &fileName, int line, int column,
|
IEditor *EditorManager::openEditorAt(const QString &fileName, int line, int column,
|
||||||
Id editorId, OpenEditorFlags flags, bool *newEditor)
|
Id editorId, OpenEditorFlags flags, bool *newEditor)
|
||||||
{
|
{
|
||||||
|
if (flags & EditorManager::OpenInOtherSplit)
|
||||||
|
EditorManager::gotoOtherSplit();
|
||||||
|
|
||||||
return EditorManagerPrivate::openEditorAt(EditorManagerPrivate::currentEditorView(),
|
return EditorManagerPrivate::openEditorAt(EditorManagerPrivate::currentEditorView(),
|
||||||
fileName, line, column, editorId, flags, newEditor);
|
fileName, line, column, editorId, flags, newEditor);
|
||||||
}
|
}
|
||||||
@@ -2297,12 +2296,8 @@ IEditor *EditorManager::openEditorWithContents(Id editorId,
|
|||||||
if (debugEditorManager)
|
if (debugEditorManager)
|
||||||
qDebug() << Q_FUNC_INFO << editorId.name() << titlePattern << contents;
|
qDebug() << Q_FUNC_INFO << editorId.name() << titlePattern << contents;
|
||||||
|
|
||||||
if (flags & EditorManager::OpenInOtherSplit) {
|
if (flags & EditorManager::OpenInOtherSplit)
|
||||||
if (flags & EditorManager::NoNewSplits)
|
|
||||||
EditorManagerPrivate::gotoNextSplit();
|
|
||||||
else
|
|
||||||
EditorManager::gotoOtherSplit();
|
EditorManager::gotoOtherSplit();
|
||||||
}
|
|
||||||
|
|
||||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||||
|
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ public:
|
|||||||
IgnoreNavigationHistory = 2,
|
IgnoreNavigationHistory = 2,
|
||||||
DoNotMakeVisible = 4,
|
DoNotMakeVisible = 4,
|
||||||
CanContainLineNumber = 8,
|
CanContainLineNumber = 8,
|
||||||
OpenInOtherSplit = 16,
|
OpenInOtherSplit = 16
|
||||||
NoNewSplits = 32
|
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(OpenEditorFlags, OpenEditorFlag)
|
Q_DECLARE_FLAGS(OpenEditorFlags, OpenEditorFlag)
|
||||||
|
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ void CppEditorWidget::switchDeclarationDefinition(bool inNextSplit)
|
|||||||
|
|
||||||
// Open Editor at link position
|
// Open Editor at link position
|
||||||
if (symbolLink.hasValidTarget())
|
if (symbolLink.hasValidTarget())
|
||||||
openCppEditorAt(symbolLink, inNextSplit != alwaysOpenLinksInNextSplit());
|
openLink(symbolLink, inNextSplit != alwaysOpenLinksInNextSplit());
|
||||||
}
|
}
|
||||||
|
|
||||||
CppEditorWidget::Link CppEditorWidget::findLinkAt(const QTextCursor &cursor, bool resolveTarget,
|
CppEditorWidget::Link CppEditorWidget::findLinkAt(const QTextCursor &cursor, bool resolveTarget,
|
||||||
@@ -576,21 +576,6 @@ CppEditorWidget::Link CppEditorWidget::linkToSymbol(CPlusPlus::Symbol *symbol)
|
|||||||
return Link(filename, line, column);
|
return Link(filename, line, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppEditorWidget::openCppEditorAt(const Link &link, bool inNextSplit)
|
|
||||||
{
|
|
||||||
if (!link.hasValidTarget())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
EditorManager::OpenEditorFlags flags;
|
|
||||||
if (inNextSplit)
|
|
||||||
flags |= EditorManager::OpenInOtherSplit;
|
|
||||||
return EditorManager::openEditorAt(link.targetFileName,
|
|
||||||
link.targetLine,
|
|
||||||
link.targetColumn,
|
|
||||||
Constants::CPPEDITOR_ID,
|
|
||||||
flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo,
|
void CppEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo,
|
||||||
bool updateUseSelectionSynchronously)
|
bool updateUseSelectionSynchronously)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -104,9 +104,6 @@ protected:
|
|||||||
|
|
||||||
void applyFontSettings() Q_DECL_OVERRIDE;
|
void applyFontSettings() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
bool openLink(const Link &link, bool inNextSplit) Q_DECL_OVERRIDE
|
|
||||||
{ return openCppEditorAt(link, inNextSplit); }
|
|
||||||
|
|
||||||
Link findLinkAt(const QTextCursor &, bool resolveTarget = true,
|
Link findLinkAt(const QTextCursor &, bool resolveTarget = true,
|
||||||
bool inNextSplit = false) Q_DECL_OVERRIDE;
|
bool inNextSplit = false) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
@@ -140,8 +137,6 @@ private:
|
|||||||
void finalizeInitialization() Q_DECL_OVERRIDE;
|
void finalizeInitialization() Q_DECL_OVERRIDE;
|
||||||
void finalizeInitializationAfterDuplication(BaseTextEditorWidget *other) Q_DECL_OVERRIDE;
|
void finalizeInitializationAfterDuplication(BaseTextEditorWidget *other) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
static bool openCppEditorAt(const Link &, bool inNextSplit = false);
|
|
||||||
|
|
||||||
unsigned documentRevision() const;
|
unsigned documentRevision() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -5334,16 +5334,18 @@ bool BaseTextEditorWidget::openLink(const Link &link, bool inNextSplit)
|
|||||||
if (!link.hasValidTarget())
|
if (!link.hasValidTarget())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (inNextSplit) {
|
if (!inNextSplit && textDocument()->filePath() == link.targetFileName) {
|
||||||
EditorManager::gotoOtherSplit();
|
|
||||||
} else if (textDocument()->filePath() == link.targetFileName) {
|
|
||||||
EditorManager::addCurrentPositionToNavigationHistory();
|
EditorManager::addCurrentPositionToNavigationHistory();
|
||||||
gotoLine(link.targetLine, link.targetColumn);
|
gotoLine(link.targetLine, link.targetColumn);
|
||||||
setFocus();
|
setFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
EditorManager::OpenEditorFlags flags;
|
||||||
|
if (inNextSplit)
|
||||||
|
flags |= EditorManager::OpenInOtherSplit;
|
||||||
|
|
||||||
return EditorManager::openEditorAt(link.targetFileName, link.targetLine, link.targetColumn);
|
return EditorManager::openEditorAt(link.targetFileName, link.targetLine, link.targetColumn,
|
||||||
|
Id(), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextEditorWidgetPrivate::updateLink(QMouseEvent *e)
|
void BaseTextEditorWidgetPrivate::updateLink(QMouseEvent *e)
|
||||||
|
|||||||
@@ -580,10 +580,9 @@ protected:
|
|||||||
bool inNextSplit = false);
|
bool inNextSplit = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Reimplement this function if you want to customize the way a link is
|
Returns whether the link was opened successfully.
|
||||||
opened. Returns whether the link was opened successfully.
|
|
||||||
*/
|
*/
|
||||||
virtual bool openLink(const Link &link, bool inNextSplit = false);
|
bool openLink(const Link &link, bool inNextSplit = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Reimplement this function to change the default replacement text.
|
Reimplement this function to change the default replacement text.
|
||||||
|
|||||||
Reference in New Issue
Block a user