aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppeditordocument.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2022-08-15 13:06:12 +0200
committerDavid Schulz <david.schulz@qt.io>2022-08-18 06:20:10 +0000
commit5b3b1a60a1902762ad1788dbd20a21348da4e822 (patch)
tree08cb62f5280be750c7ef206ff81bf377650ca7bc /src/plugins/cppeditor/cppeditordocument.cpp
parent4a796239594f905644b3459ff93b804d473aa443 (diff)
CppEditor: move outline model to document
This way we only have one model per document instead of one per editor. Additionally we further separate the outline views (combobox and side pane) from the actual model. Change-Id: I9705716b5c9f8f19f75708ec73d7c3b3c5de586f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppeditordocument.cpp')
-rw-r--r--src/plugins/cppeditor/cppeditordocument.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp
index 2b01b86c27..cce259c2d8 100644
--- a/src/plugins/cppeditor/cppeditordocument.cpp
+++ b/src/plugins/cppeditor/cppeditordocument.cpp
@@ -393,6 +393,19 @@ ParseContextModel &CppEditorDocument::parseContextModel()
return m_parseContextModel;
}
+OverviewModel &CppEditorDocument::outlineModel()
+{
+ return m_overviewModel;
+}
+
+void CppEditorDocument::updateOutline()
+{
+ CPlusPlus::Document::Ptr document;
+ if (!usesClangd())
+ document = CppModelManager::instance()->snapshot().document(filePath());
+ m_overviewModel.update(document);
+}
+
QFuture<CursorInfo> CppEditorDocument::cursorInfo(const CursorInfoParams &params)
{
return processor()->cursorInfo(params);
@@ -426,6 +439,8 @@ BaseEditorDocumentProcessor *CppEditorDocument::processor()
auto *highlighter = qobject_cast<CppHighlighter *>(syntaxHighlighter());
highlighter->setLanguageFeatures(document->languageFeatures());
+ m_overviewModel.update(usesClangd() ? nullptr : document);
+
// Forward signal
emit cppDocumentUpdated(document);
@@ -488,6 +503,11 @@ bool CppEditorDocument::save(QString *errorString, const FilePath &filePath, boo
return TextEditor::TextDocument::save(errorString, filePath, autoSave);
}
+bool CppEditorDocument::usesClangd() const
+{
+ return CppModelManager::usesClangd(this);
+}
+
void CppEditorDocument::onDiagnosticsChanged(const QString &fileName, const QString &kind)
{
if (FilePath::fromString(fileName) != filePath())