From 7698d95576403dd02eff081f8904f6a151926c84 Mon Sep 17 00:00:00 2001 From: Ivan Donchevskii Date: Fri, 2 Feb 2018 13:01:07 +0100 Subject: [PATCH] CppTools: Get OverviewModel from model manager Move ownership and add the placeholder for future clang based OverviewModel. Change-Id: Ia44d2c1d0db59b40239d1f7934bf37a02e4b14e6 Reviewed-by: Nikolai Kosjar --- src/plugins/clangcodemodel/clangmodelmanagersupport.cpp | 9 +++++++++ src/plugins/clangcodemodel/clangmodelmanagersupport.h | 1 + src/plugins/cpptools/cppeditoroutline.cpp | 2 +- src/plugins/cpptools/cppmodelmanager.cpp | 6 ++++++ src/plugins/cpptools/cppmodelmanager.h | 2 ++ src/plugins/cpptools/cppmodelmanagersupport.h | 4 ++++ src/plugins/cpptools/cppmodelmanagersupportinternal.cpp | 6 ++++++ src/plugins/cpptools/cppmodelmanagersupportinternal.h | 1 + 8 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp index 0371b3a06f5..4859504e29f 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp @@ -35,6 +35,10 @@ #include "clangcurrentdocumentfilter.h" #include + +// TODO: replace with clang based overview model +#include + #include #include #include @@ -144,6 +148,11 @@ CppTools::RefactoringEngineInterface &ModelManagerSupportClang::refactoringEngin return *m_refactoringEngine; } +std::unique_ptr ModelManagerSupportClang::createOverviewModel() +{ + return std::make_unique(); +} + CppTools::BaseEditorDocumentProcessor *ModelManagerSupportClang::createEditorDocumentProcessor( TextEditor::TextDocument *baseTextDocument) { diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.h b/src/plugins/clangcodemodel/clangmodelmanagersupport.h index d8c3e1c9176..3b62aae108f 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.h +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.h @@ -71,6 +71,7 @@ public: TextEditor::TextDocument *baseTextDocument) override; CppTools::FollowSymbolInterface &followSymbolInterface() override; CppTools::RefactoringEngineInterface &refactoringEngineInterface() override; + std::unique_ptr createOverviewModel() override; BackendCommunicator &communicator(); QString dummyUiHeaderOnDiskDirPath() const; diff --git a/src/plugins/cpptools/cppeditoroutline.cpp b/src/plugins/cpptools/cppeditoroutline.cpp index 033f5e9090f..e629ea82305 100644 --- a/src/plugins/cpptools/cppeditoroutline.cpp +++ b/src/plugins/cpptools/cppeditoroutline.cpp @@ -94,7 +94,7 @@ CppEditorOutline::CppEditorOutline(TextEditor::TextEditorWidget *editorWidget) , m_editorWidget(editorWidget) , m_combo(new Utils::TreeViewComboBox) { - m_model = std::make_unique(); + m_model = CppModelManager::instance()->createOverviewModel(); m_proxyModel = new OverviewProxyModel(*m_model, this); m_proxyModel->setSourceModel(m_model.get()); diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 508bf76be46..ed9042b0012 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -26,6 +26,7 @@ #include "cppmodelmanager.h" #include "abstracteditorsupport.h" +#include "abstractoverviewmodel.h" #include "baseeditordocumentprocessor.h" #include "builtinindexingsupport.h" #include "cppclassesfilter.h" @@ -400,6 +401,11 @@ FollowSymbolInterface &CppModelManager::followSymbolInterface() const return d->m_activeModelManagerSupport->followSymbolInterface(); } +std::unique_ptr CppModelManager::createOverviewModel() const +{ + return d->m_activeModelManagerSupport->createOverviewModel(); +} + QString CppModelManager::configurationFileName() { return Preprocessor::configurationFileName(); diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h index 7bd7ce157ad..7dd32fd860d 100644 --- a/src/plugins/cpptools/cppmodelmanager.h +++ b/src/plugins/cpptools/cppmodelmanager.h @@ -54,6 +54,7 @@ class TextDocument; namespace CppTools { class AbstractEditorSupport; +class AbstractOverviewModel; class BaseEditorDocumentProcessor; class CppCompletionAssistProvider; class CppEditorDocumentHandle; @@ -183,6 +184,7 @@ public: TextEditor::TextDocument *baseTextDocument) const; TextEditor::BaseHoverHandler *createHoverHandler() const; FollowSymbolInterface &followSymbolInterface() const; + std::unique_ptr createOverviewModel() const; void setIndexingSupport(CppIndexingSupport *indexingSupport); CppIndexingSupport *indexingSupport(); diff --git a/src/plugins/cpptools/cppmodelmanagersupport.h b/src/plugins/cpptools/cppmodelmanagersupport.h index 06102f6007f..c5457cd51f3 100644 --- a/src/plugins/cpptools/cppmodelmanagersupport.h +++ b/src/plugins/cpptools/cppmodelmanagersupport.h @@ -30,6 +30,8 @@ #include #include +#include + namespace TextEditor { class TextDocument; class BaseHoverHandler; @@ -37,6 +39,7 @@ class BaseHoverHandler; namespace CppTools { +class AbstractOverviewModel; class BaseEditorDocumentProcessor; class CppCompletionAssistProvider; class FollowSymbolInterface; @@ -56,6 +59,7 @@ public: TextEditor::TextDocument *baseTextDocument) = 0; virtual FollowSymbolInterface &followSymbolInterface() = 0; virtual RefactoringEngineInterface &refactoringEngineInterface() = 0; + virtual std::unique_ptr createOverviewModel() = 0; }; class CPPTOOLS_EXPORT ModelManagerSupportProvider diff --git a/src/plugins/cpptools/cppmodelmanagersupportinternal.cpp b/src/plugins/cpptools/cppmodelmanagersupportinternal.cpp index 51919955549..2bf4ac27009 100644 --- a/src/plugins/cpptools/cppmodelmanagersupportinternal.cpp +++ b/src/plugins/cpptools/cppmodelmanagersupportinternal.cpp @@ -27,6 +27,7 @@ #include "cppmodelmanagersupportinternal.h" #include "cppfollowsymbolundercursor.h" #include "cpphoverhandler.h" +#include "cppoverviewmodel.h" #include "cpprefactoringengine.h" #include "builtineditordocumentprocessor.h" @@ -89,3 +90,8 @@ RefactoringEngineInterface &ModelManagerSupportInternal::refactoringEngineInterf { return *m_refactoringEngine; } + +std::unique_ptr ModelManagerSupportInternal::createOverviewModel() +{ + return std::make_unique(); +} diff --git a/src/plugins/cpptools/cppmodelmanagersupportinternal.h b/src/plugins/cpptools/cppmodelmanagersupportinternal.h index e2954792ea4..cfa326e7784 100644 --- a/src/plugins/cpptools/cppmodelmanagersupportinternal.h +++ b/src/plugins/cpptools/cppmodelmanagersupportinternal.h @@ -46,6 +46,7 @@ public: TextEditor::TextDocument *baseTextDocument) final; FollowSymbolInterface &followSymbolInterface() final; RefactoringEngineInterface &refactoringEngineInterface() final; + std::unique_ptr createOverviewModel() final; private: QScopedPointer m_completionAssistProvider;