forked from qt-creator/qt-creator
CppEditor: Move some factory class definitions to .cpp
Change-Id: Icceae7f93ac52fe371813608ecec0de1feed317b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "cppeditortr.h"
|
||||
#include "cpptoolsreuse.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/session.h>
|
||||
|
||||
@@ -185,14 +186,23 @@ bool CppCodeModelSettingsWidget::applyGeneralWidgetsToSettings() const
|
||||
return settingsChanged;
|
||||
}
|
||||
|
||||
CppCodeModelSettingsPage::CppCodeModelSettingsPage()
|
||||
class CppCodeModelSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CppCodeModelSettingsPage()
|
||||
{
|
||||
setId(Constants::CPP_CODE_MODEL_SETTINGS_ID);
|
||||
setDisplayName(Tr::tr("Code Model"));
|
||||
setCategory(Constants::CPP_SETTINGS_CATEGORY);
|
||||
setDisplayCategory(Tr::tr("C++"));
|
||||
setCategoryIconPath(":/projectexplorer/images/settingscategory_cpp.png");
|
||||
setWidgetCreator([] { return new CppCodeModelSettingsWidget; });
|
||||
}
|
||||
};
|
||||
|
||||
void setupCppCodeModelSettings()
|
||||
{
|
||||
static CppCodeModelSettingsPage theCppCodeModelSettingsPage;
|
||||
}
|
||||
|
||||
class ClangdSettingsWidget final : public QWidget
|
||||
|
@@ -3,16 +3,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
namespace CppEditor::Internal {
|
||||
|
||||
class CppCodeModelSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CppCodeModelSettingsPage();
|
||||
};
|
||||
|
||||
void setupCppCodeModelSettings();
|
||||
void setupClangdProjectSettingsPanel();
|
||||
void setupClangdSettingsPage();
|
||||
|
||||
|
@@ -607,12 +607,21 @@ public:
|
||||
|
||||
// CppCodeStyleSettingsPage
|
||||
|
||||
CppCodeStyleSettingsPage::CppCodeStyleSettingsPage()
|
||||
class CppCodeStyleSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CppCodeStyleSettingsPage()
|
||||
{
|
||||
setId(Constants::CPP_CODE_STYLE_SETTINGS_ID);
|
||||
setDisplayName(Tr::tr("Code Style"));
|
||||
setCategory(Constants::CPP_SETTINGS_CATEGORY);
|
||||
setWidgetCreator([] { return new CppCodeStyleSettingsPageWidget; });
|
||||
}
|
||||
};
|
||||
|
||||
void setupCppCodeStyleSettings()
|
||||
{
|
||||
static CppCodeStyleSettingsPage theCppCodeStyleSettingsPage;
|
||||
}
|
||||
|
||||
} // namespace CppEditor::Internal
|
||||
|
@@ -64,12 +64,7 @@ signals:
|
||||
void finishEmitted();
|
||||
};
|
||||
|
||||
|
||||
class CppCodeStyleSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CppCodeStyleSettingsPage();
|
||||
};
|
||||
void setupCppCodeStyleSettings();
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
|
@@ -160,18 +160,12 @@ public:
|
||||
QAction *m_reparseExternallyChangedFiles = nullptr;
|
||||
QAction *m_findRefsCategorizedAction = nullptr;
|
||||
|
||||
CppQuickFixSettingsPage m_quickFixSettingsPage;
|
||||
|
||||
QPointer<CppCodeModelInspectorDialog> m_cppCodeModelInspectorDialog;
|
||||
|
||||
CppOutlineWidgetFactory m_cppOutlineWidgetFactory;
|
||||
CppEditorFactory m_cppEditorFactory;
|
||||
|
||||
CppModelManager modelManager;
|
||||
CppToolsSettings settings;
|
||||
CppCodeModelSettingsPage m_cppCodeModelSettingsPage;
|
||||
CppCodeStyleSettingsPage m_cppCodeStyleSettingsPage;
|
||||
CppProjectUpdaterFactory m_cppProjectUpdaterFactory;
|
||||
};
|
||||
|
||||
class CppEditorPlugin final : public ExtensionSystem::IPlugin
|
||||
@@ -206,6 +200,12 @@ void CppEditorPlugin::initialize()
|
||||
{
|
||||
d = new CppEditorPluginPrivate;
|
||||
|
||||
setupCppQuickFixSettings();
|
||||
setupCppCodeModelSettings();
|
||||
setupCppOutline();
|
||||
setupCppCodeStyleSettings();
|
||||
setupCppProjectUpdater();
|
||||
|
||||
CppModelManager::registerJsExtension();
|
||||
|
||||
setupMenus();
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
|
||||
#include <texteditor/ioutlinewidget.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
@@ -24,6 +25,8 @@
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
namespace CppEditor::Internal {
|
||||
|
||||
class CppOutlineTreeView final : public Utils::NavigationTreeView
|
||||
@@ -255,22 +258,36 @@ bool CppOutlineWidget::syncCursor()
|
||||
return m_enableCursorSync && !m_blockCursorSync;
|
||||
}
|
||||
|
||||
bool CppOutlineWidgetFactory::supportsEditor(Core::IEditor *editor) const
|
||||
class CppOutlineWidgetFactory final : public IOutlineWidgetFactory
|
||||
{
|
||||
const auto cppEditor = qobject_cast<TextEditor::BaseTextEditor*>(editor);
|
||||
public:
|
||||
bool supportsEditor(Core::IEditor *editor) const final
|
||||
{
|
||||
const auto cppEditor = qobject_cast<BaseTextEditor*>(editor);
|
||||
if (!cppEditor || !CppModelManager::isCppEditor(cppEditor))
|
||||
return false;
|
||||
return !CppModelManager::usesClangd(cppEditor->textDocument());
|
||||
}
|
||||
}
|
||||
|
||||
TextEditor::IOutlineWidget *CppOutlineWidgetFactory::createWidget(Core::IEditor *editor)
|
||||
{
|
||||
const auto cppEditor = qobject_cast<TextEditor::BaseTextEditor*>(editor);
|
||||
bool supportsSorting() const final
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
IOutlineWidget *createWidget(Core::IEditor *editor) final
|
||||
{
|
||||
const auto cppEditor = qobject_cast<BaseTextEditor*>(editor);
|
||||
QTC_ASSERT(cppEditor, return nullptr);
|
||||
const auto cppEditorWidget = qobject_cast<CppEditorWidget*>(cppEditor->widget());
|
||||
QTC_ASSERT(cppEditorWidget, return nullptr);
|
||||
|
||||
return new CppOutlineWidget(cppEditorWidget);
|
||||
}
|
||||
};
|
||||
|
||||
void setupCppOutline()
|
||||
{
|
||||
static CppOutlineWidgetFactory theCppOutlineWidgetFactory;
|
||||
}
|
||||
|
||||
} // namespace CppEditor::Internal
|
||||
|
@@ -3,16 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <texteditor/ioutlinewidget.h>
|
||||
|
||||
namespace CppEditor::Internal {
|
||||
|
||||
class CppOutlineWidgetFactory final : public TextEditor::IOutlineWidgetFactory
|
||||
{
|
||||
public:
|
||||
bool supportsEditor(Core::IEditor *editor) const final;
|
||||
bool supportsSorting() const final { return true; }
|
||||
TextEditor::IOutlineWidget *createWidget(Core::IEditor *editor) final;
|
||||
};
|
||||
void setupCppOutline();
|
||||
|
||||
} // namespace CppEditor::Internal
|
||||
} // CppEditor::Internal
|
||||
|
@@ -97,14 +97,19 @@ void CppProjectUpdater::cancel()
|
||||
m_futureSynchronizer.cancelAllFutures();
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
CppProjectUpdaterFactory::CppProjectUpdaterFactory()
|
||||
class CppProjectUpdaterFactory final : public ProjectUpdaterFactory
|
||||
{
|
||||
public:
|
||||
CppProjectUpdaterFactory()
|
||||
{
|
||||
setLanguage(Constants::CXX_LANGUAGE_ID);
|
||||
setCreator([] { return new CppProjectUpdater; });
|
||||
}
|
||||
};
|
||||
|
||||
void setupCppProjectUpdater()
|
||||
{
|
||||
static CppProjectUpdaterFactory theCppProjectUpdaterFactory;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
} // namespace CppEditor
|
||||
|
@@ -16,18 +16,6 @@ namespace ProjectExplorer { class ExtraCompiler; }
|
||||
|
||||
namespace CppEditor {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
// registered in extensionsystem's object pool for plugins with weak dependency to CppEditor
|
||||
class CppProjectUpdaterFactory final
|
||||
: public ProjectExplorer::ProjectUpdaterFactory
|
||||
{
|
||||
public:
|
||||
CppProjectUpdaterFactory();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
class CPPEDITOR_EXPORT CppProjectUpdater final
|
||||
: public QObject, public ProjectExplorer::ProjectUpdater
|
||||
{
|
||||
@@ -43,4 +31,6 @@ private:
|
||||
Tasking::TaskTreeRunner m_taskTreeRunner;
|
||||
};
|
||||
|
||||
void setupCppProjectUpdater();
|
||||
|
||||
} // namespace CppEditor
|
||||
|
@@ -7,14 +7,25 @@
|
||||
#include "cppeditortr.h"
|
||||
#include "cppquickfixsettingswidget.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
namespace CppEditor::Internal {
|
||||
|
||||
CppQuickFixSettingsPage::CppQuickFixSettingsPage()
|
||||
class CppQuickFixSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CppQuickFixSettingsPage()
|
||||
{
|
||||
setId(Constants::QUICK_FIX_SETTINGS_ID);
|
||||
setDisplayName(Tr::tr(Constants::QUICK_FIX_SETTINGS_DISPLAY_NAME));
|
||||
setCategory(Constants::CPP_SETTINGS_CATEGORY);
|
||||
setWidgetCreator([] { return new CppQuickFixSettingsWidget; });
|
||||
}
|
||||
};
|
||||
|
||||
void setupCppQuickFixSettings()
|
||||
{
|
||||
static CppQuickFixSettingsPage theCppQuickFixSettingsPage;
|
||||
}
|
||||
|
||||
} // CppEditor::Internal
|
||||
|
@@ -3,14 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
namespace CppEditor::Internal {
|
||||
|
||||
class CppQuickFixSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CppQuickFixSettingsPage();
|
||||
};
|
||||
void setupCppQuickFixSettings();
|
||||
|
||||
} // CppEditor::Internal
|
||||
|
Reference in New Issue
Block a user