forked from qt-creator/qt-creator
TextEditor: Move OutlineFactory setup closer to new pattern
This is quite special due to the extra signal, but at least that's hidden in the implementation now. Change-Id: Id1130669fd1fdfb631d89460cfb884fb53858eec Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -7,14 +7,15 @@
|
||||
#include "ioutlinewidget.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/inavigationwidgetfactory.h>
|
||||
|
||||
#include <utils/utilsicons.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/store.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
@@ -25,9 +26,37 @@
|
||||
using namespace Utils;
|
||||
|
||||
namespace TextEditor {
|
||||
namespace Internal {
|
||||
|
||||
class OutlineFactory : public Core::INavigationWidgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OutlineFactory();
|
||||
|
||||
Core::NavigationView createWidget() override;
|
||||
void saveSettings(Utils::QtcSettings *settings, int position, QWidget *widget) override;
|
||||
void restoreSettings(Utils::QtcSettings *settings, int position, QWidget *widget) override;
|
||||
|
||||
signals:
|
||||
void updateOutline();
|
||||
};
|
||||
|
||||
OutlineFactory &outlineFactory()
|
||||
{
|
||||
static OutlineFactory theOutlineFactory;
|
||||
return theOutlineFactory;
|
||||
}
|
||||
|
||||
void setupOutlineFactory()
|
||||
{
|
||||
(void) outlineFactory();
|
||||
}
|
||||
|
||||
} // Internal
|
||||
|
||||
static QList<IOutlineWidgetFactory *> g_outlineWidgetFactories;
|
||||
static QPointer<Internal::OutlineFactory> g_outlineFactory;
|
||||
|
||||
IOutlineWidgetFactory::IOutlineWidgetFactory()
|
||||
{
|
||||
@@ -41,8 +70,7 @@ IOutlineWidgetFactory::~IOutlineWidgetFactory()
|
||||
|
||||
void IOutlineWidgetFactory::updateOutline()
|
||||
{
|
||||
if (QTC_GUARD(!g_outlineFactory.isNull()))
|
||||
emit g_outlineFactory->updateOutline();
|
||||
emit Internal::outlineFactory().updateOutline();
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
@@ -243,8 +271,6 @@ void OutlineWidgetStack::updateEditor(Core::IEditor *editor)
|
||||
|
||||
OutlineFactory::OutlineFactory()
|
||||
{
|
||||
QTC_CHECK(g_outlineFactory.isNull());
|
||||
g_outlineFactory = this;
|
||||
setDisplayName(Tr::tr("Outline"));
|
||||
setId("Outline");
|
||||
setPriority(600);
|
||||
|
@@ -3,24 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/inavigationwidgetfactory.h>
|
||||
|
||||
namespace TextEditor::Internal {
|
||||
|
||||
class OutlineFactory : public Core::INavigationWidgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OutlineFactory();
|
||||
|
||||
// from INavigationWidgetFactory
|
||||
Core::NavigationView createWidget() override;
|
||||
void saveSettings(Utils::QtcSettings *settings, int position, QWidget *widget) override;
|
||||
void restoreSettings(Utils::QtcSettings *settings, int position, QWidget *widget) override;
|
||||
|
||||
signals:
|
||||
void updateOutline();
|
||||
};
|
||||
void setupOutlineFactory();
|
||||
|
||||
} // TextEditor::Internal
|
||||
|
@@ -101,7 +101,6 @@ public:
|
||||
|
||||
TextEditorSettings settings;
|
||||
LineNumberFilter lineNumberFilter; // Goto line functionality for quick open
|
||||
OutlineFactory outlineFactory;
|
||||
|
||||
FindInFiles findInFilesFilter;
|
||||
FindInCurrentFile findInCurrentFileFilter;
|
||||
@@ -284,6 +283,8 @@ TextEditorPlugin *TextEditorPlugin::instance()
|
||||
|
||||
void TextEditorPlugin::initialize()
|
||||
{
|
||||
setupOutlineFactory();
|
||||
|
||||
d = new TextEditorPluginPrivate;
|
||||
|
||||
Context context(TextEditor::Constants::C_TEXTEDITOR);
|
||||
|
Reference in New Issue
Block a user