aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-02-04 18:16:57 +0100
committerhjk <hjk@qt.io>2020-02-05 11:41:29 +0000
commitd7ae3b79f89f91f6b15f807b5c894da7e06c3013 (patch)
treeebbd5ded1ddd1fa035e99ebe98b384e676cfebb4 /src/plugins
parentccc2a347a75c3fd06d8f2028a17a3477c40e0a13 (diff)
Core: Make IEditorFactory::createEditor use a function object
Also, replace or remove unneeded Q_OBJECTs, and make base setters and adders protected. Change-Id: I212257ef53984d8852dc8c478537199fc9483486 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/android/androidmanifesteditorfactory.cpp12
-rw-r--r--src/plugins/android/androidmanifesteditorfactory.h6
-rw-r--r--src/plugins/bineditor/bineditorplugin.cpp41
-rw-r--r--src/plugins/bineditor/bineditorplugin.h6
-rw-r--r--src/plugins/coreplugin/editormanager/ieditorfactory.cpp11
-rw-r--r--src/plugins/coreplugin/editormanager/ieditorfactory.h15
-rw-r--r--src/plugins/designer/formeditorfactory.cpp6
-rw-r--r--src/plugins/designer/formeditorfactory.h6
-rw-r--r--src/plugins/diffeditor/diffeditorfactory.cpp5
-rw-r--r--src/plugins/diffeditor/diffeditorfactory.h7
-rw-r--r--src/plugins/imageviewer/imageviewerfactory.cpp8
-rw-r--r--src/plugins/imageviewer/imageviewerfactory.h7
-rw-r--r--src/plugins/modeleditor/modeleditorfactory.cpp23
-rw-r--r--src/plugins/modeleditor/modeleditorfactory.h11
-rw-r--r--src/plugins/nim/editor/nimeditorfactory.cpp5
-rw-r--r--src/plugins/nim/editor/nimeditorfactory.h1
-rw-r--r--src/plugins/resourceeditor/resourceeditorfactory.cpp11
-rw-r--r--src/plugins/resourceeditor/resourceeditorfactory.h12
-rw-r--r--src/plugins/scxmleditor/scxmleditorfactory.cpp19
-rw-r--r--src/plugins/scxmleditor/scxmleditorfactory.h6
-rw-r--r--src/plugins/texteditor/texteditor.cpp39
-rw-r--r--src/plugins/texteditor/texteditor.h2
-rw-r--r--src/plugins/vcsbase/basevcssubmiteditorfactory.cpp15
-rw-r--r--src/plugins/vcsbase/basevcssubmiteditorfactory.h3
24 files changed, 103 insertions, 174 deletions
diff --git a/src/plugins/android/androidmanifesteditorfactory.cpp b/src/plugins/android/androidmanifesteditorfactory.cpp
index ce78388537..1a412bac49 100644
--- a/src/plugins/android/androidmanifesteditorfactory.cpp
+++ b/src/plugins/android/androidmanifesteditorfactory.cpp
@@ -38,17 +38,15 @@ using namespace Android::Internal;
AndroidManifestEditorFactory::AndroidManifestEditorFactory()
{
setId(Constants::ANDROID_MANIFEST_EDITOR_ID);
- setDisplayName(tr("Android Manifest editor"));
+ setDisplayName(AndroidManifestEditorWidget::tr("Android Manifest editor"));
addMimeType(Constants::ANDROID_MANIFEST_MIME_TYPE);
auto actionHandler = new TextEditor::TextEditorActionHandler(
this, id(), Constants::ANDROID_MANIFEST_EDITOR_CONTEXT);
actionHandler->setTextEditorWidgetResolver([](Core::IEditor *editor) {
return static_cast<AndroidManifestEditor *>(editor)->textEditor();
});
-}
-
-Core::IEditor *AndroidManifestEditorFactory::createEditor()
-{
- auto androidManifestEditorWidget = new AndroidManifestEditorWidget();
- return androidManifestEditorWidget->editor();
+ setEditorCreator([] {
+ auto androidManifestEditorWidget = new AndroidManifestEditorWidget;
+ return androidManifestEditorWidget->editor();
+ });
}
diff --git a/src/plugins/android/androidmanifesteditorfactory.h b/src/plugins/android/androidmanifesteditorfactory.h
index 82d26b2f4a..b73eab9ecb 100644
--- a/src/plugins/android/androidmanifesteditorfactory.h
+++ b/src/plugins/android/androidmanifesteditorfactory.h
@@ -30,14 +30,10 @@
namespace Android {
namespace Internal {
-class AndroidManifestEditorFactory : public Core::IEditorFactory
+class AndroidManifestEditorFactory final : public Core::IEditorFactory
{
- Q_OBJECT
-
public:
AndroidManifestEditorFactory();
-
- Core::IEditor *createEditor() override;
};
} // namespace Internal
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index 81de2b5690..06506cd8bc 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -471,33 +471,32 @@ BinEditorFactory::BinEditorFactory()
setId(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::C_BINEDITOR_DISPLAY_NAME));
addMimeType(Constants::C_BINEDITOR_MIMETYPE);
-}
-IEditor *BinEditorFactory::createEditor()
-{
- auto widget = new BinEditorWidget();
- auto editor = new BinEditor(widget);
+ setEditorCreator([] {
+ auto widget = new BinEditorWidget();
+ auto editor = new BinEditor(widget);
- connect(dd->m_undoAction, &QAction::triggered, widget, &BinEditorWidget::undo);
- connect(dd->m_redoAction, &QAction::triggered, widget, &BinEditorWidget::redo);
- connect(dd->m_copyAction, &QAction::triggered, widget, &BinEditorWidget::copy);
- connect(dd->m_selectAllAction, &QAction::triggered, widget, &BinEditorWidget::selectAll);
+ connect(dd->m_undoAction, &QAction::triggered, widget, &BinEditorWidget::undo);
+ connect(dd->m_redoAction, &QAction::triggered, widget, &BinEditorWidget::redo);
+ connect(dd->m_copyAction, &QAction::triggered, widget, &BinEditorWidget::copy);
+ connect(dd->m_selectAllAction, &QAction::triggered, widget, &BinEditorWidget::selectAll);
- auto updateActions = [widget] {
- dd->m_selectAllAction->setEnabled(true);
- dd->m_undoAction->setEnabled(widget->isUndoAvailable());
- dd->m_redoAction->setEnabled(widget->isRedoAvailable());
- };
+ auto updateActions = [widget] {
+ dd->m_selectAllAction->setEnabled(true);
+ dd->m_undoAction->setEnabled(widget->isUndoAvailable());
+ dd->m_redoAction->setEnabled(widget->isRedoAvailable());
+ };
- connect(widget, &BinEditorWidget::undoAvailable, widget, updateActions);
- connect(widget, &BinEditorWidget::redoAvailable, widget, updateActions);
+ connect(widget, &BinEditorWidget::undoAvailable, widget, updateActions);
+ connect(widget, &BinEditorWidget::redoAvailable, widget, updateActions);
- auto aggregate = new Aggregation::Aggregate;
- auto binEditorFind = new BinEditorFind(widget);
- aggregate->add(binEditorFind);
- aggregate->add(widget);
+ auto aggregate = new Aggregation::Aggregate;
+ auto binEditorFind = new BinEditorFind(widget);
+ aggregate->add(binEditorFind);
+ aggregate->add(widget);
- return editor;
+ return editor;
+ });
}
///////////////////////////////// BinEditor Services //////////////////////////////////
diff --git a/src/plugins/bineditor/bineditorplugin.h b/src/plugins/bineditor/bineditorplugin.h
index 14460d8287..e17fedfa17 100644
--- a/src/plugins/bineditor/bineditorplugin.h
+++ b/src/plugins/bineditor/bineditorplugin.h
@@ -44,14 +44,10 @@ class BinEditorPlugin : public ExtensionSystem::IPlugin
void extensionsInitialized() final {}
};
-class BinEditorFactory : public Core::IEditorFactory
+class BinEditorFactory final : public Core::IEditorFactory
{
- Q_OBJECT
-
public:
BinEditorFactory();
-
- Core::IEditor *createEditor() final;
};
class FactoryServiceImpl : public QObject, public FactoryService
diff --git a/src/plugins/coreplugin/editormanager/ieditorfactory.cpp b/src/plugins/coreplugin/editormanager/ieditorfactory.cpp
index c889e39404..82a2ad5227 100644
--- a/src/plugins/coreplugin/editormanager/ieditorfactory.cpp
+++ b/src/plugins/coreplugin/editormanager/ieditorfactory.cpp
@@ -96,6 +96,17 @@ const EditorFactoryList IEditorFactory::preferredEditorFactories(const QString &
return factories;
}
+IEditor *IEditorFactory::createEditor() const
+{
+ QTC_ASSERT(m_creator, return nullptr);
+ return m_creator();
+}
+
+void IEditorFactory::setEditorCreator(const std::function<IEditor *()> &creator)
+{
+ m_creator = creator;
+}
+
QHash<Utils::MimeType, Core::IEditorFactory *> Core::Internal::userPreferredEditorFactories()
{
return g_userPreferredEditorFactories;
diff --git a/src/plugins/coreplugin/editormanager/ieditorfactory.h b/src/plugins/coreplugin/editormanager/ieditorfactory.h
index a759854e72..cc4e6f72a5 100644
--- a/src/plugins/coreplugin/editormanager/ieditorfactory.h
+++ b/src/plugins/coreplugin/editormanager/ieditorfactory.h
@@ -52,22 +52,25 @@ public:
static const EditorFactoryList defaultEditorFactories(const Utils::MimeType &mimeType);
static const EditorFactoryList preferredEditorFactories(const QString &fileName);
- QString displayName() const { return m_displayName; }
- void setDisplayName(const QString &displayName) { m_displayName = displayName; }
-
Id id() const { return m_id; }
- void setId(Id id) { m_id = id; }
+ QString displayName() const { return m_displayName; }
+ QStringList mimeTypes() const { return m_mimeTypes; }
- virtual IEditor *createEditor() = 0;
+ IEditor *createEditor() const;
- QStringList mimeTypes() const { return m_mimeTypes; }
+protected:
+ void setId(Id id) { m_id = id; }
+ void setDisplayName(const QString &displayName) { m_displayName = displayName; }
void setMimeTypes(const QStringList &mimeTypes) { m_mimeTypes = mimeTypes; }
void addMimeType(const char *mimeType) { m_mimeTypes.append(QLatin1String(mimeType)); }
void addMimeType(const QString &mimeType) { m_mimeTypes.append(mimeType); }
+ void setEditorCreator(const std::function<IEditor *()> &creator);
+
private:
Id m_id;
QString m_displayName;
QStringList m_mimeTypes;
+ std::function<IEditor *()> m_creator;
};
} // namespace Core
diff --git a/src/plugins/designer/formeditorfactory.cpp b/src/plugins/designer/formeditorfactory.cpp
index ae4d38c3ac..5d0cc0438b 100644
--- a/src/plugins/designer/formeditorfactory.cpp
+++ b/src/plugins/designer/formeditorfactory.cpp
@@ -45,14 +45,10 @@ FormEditorFactory::FormEditorFactory()
setId(K_DESIGNER_XML_EDITOR_ID);
setDisplayName(QCoreApplication::translate("Designer", C_DESIGNER_XML_DISPLAY_NAME));
addMimeType(FORM_MIMETYPE);
+ setEditorCreator([] { return FormEditorW::createEditor(); });
FileIconProvider::registerIconOverlayForSuffix(ProjectExplorer::Constants::FILEOVERLAY_UI, "ui");
}
-IEditor *FormEditorFactory::createEditor()
-{
- return FormEditorW::createEditor();
-}
-
} // namespace Internal
} // namespace Designer
diff --git a/src/plugins/designer/formeditorfactory.h b/src/plugins/designer/formeditorfactory.h
index 8c8b898a7e..bf7fb8e868 100644
--- a/src/plugins/designer/formeditorfactory.h
+++ b/src/plugins/designer/formeditorfactory.h
@@ -30,14 +30,10 @@
namespace Designer {
namespace Internal {
-class FormEditorFactory : public Core::IEditorFactory
+class FormEditorFactory final : public Core::IEditorFactory
{
- Q_OBJECT
-
public:
FormEditorFactory();
-
- Core::IEditor *createEditor() override;
};
} // namespace Internal
diff --git a/src/plugins/diffeditor/diffeditorfactory.cpp b/src/plugins/diffeditor/diffeditorfactory.cpp
index 9944bec558..c02199c629 100644
--- a/src/plugins/diffeditor/diffeditorfactory.cpp
+++ b/src/plugins/diffeditor/diffeditorfactory.cpp
@@ -62,11 +62,8 @@ DiffEditorFactory::DiffEditorFactory(QObject *parent)
rightHandler->setTextEditorWidgetResolver([](Core::IEditor *e) {
return static_cast<DiffEditor *>(e)->rightEditorWidget();
});
-}
-Core::IEditor *DiffEditorFactory::createEditor()
-{
- return new DiffEditor(new DiffEditorDocument);
+ setEditorCreator([] { return new DiffEditor(new DiffEditorDocument); });
}
} // namespace Internal
diff --git a/src/plugins/diffeditor/diffeditorfactory.h b/src/plugins/diffeditor/diffeditorfactory.h
index 2f89ac6ba3..64795b1971 100644
--- a/src/plugins/diffeditor/diffeditorfactory.h
+++ b/src/plugins/diffeditor/diffeditorfactory.h
@@ -25,22 +25,15 @@
#pragma once
-#include "diffeditor_global.h"
-
#include <coreplugin/editormanager/ieditorfactory.h>
namespace DiffEditor {
-
namespace Internal {
class DiffEditorFactory : public Core::IEditorFactory
{
- Q_OBJECT
-
public:
explicit DiffEditorFactory(QObject *parent);
-
- Core::IEditor *createEditor() override;
};
} // namespace Internal
diff --git a/src/plugins/imageviewer/imageviewerfactory.cpp b/src/plugins/imageviewer/imageviewerfactory.cpp
index a09ede55a1..4dc37a4dcd 100644
--- a/src/plugins/imageviewer/imageviewerfactory.cpp
+++ b/src/plugins/imageviewer/imageviewerfactory.cpp
@@ -38,16 +38,12 @@ ImageViewerFactory::ImageViewerFactory()
{
setId(Constants::IMAGEVIEWER_ID);
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::IMAGEVIEWER_DISPLAY_NAME));
+ setEditorCreator([] { return new ImageViewer; });
const QList<QByteArray> supportedMimeTypes = QImageReader::supportedMimeTypes();
- foreach (const QByteArray &format, supportedMimeTypes)
+ for (const QByteArray &format : supportedMimeTypes)
addMimeType(format.constData());
}
-Core::IEditor *ImageViewerFactory::createEditor()
-{
- return new ImageViewer();
-}
-
} // namespace Internal
} // namespace ImageViewer
diff --git a/src/plugins/imageviewer/imageviewerfactory.h b/src/plugins/imageviewer/imageviewerfactory.h
index b0f45a0efa..816de2ffe6 100644
--- a/src/plugins/imageviewer/imageviewerfactory.h
+++ b/src/plugins/imageviewer/imageviewerfactory.h
@@ -27,19 +27,14 @@
#pragma once
#include <coreplugin/editormanager/ieditorfactory.h>
-#include <coreplugin/editormanager/ieditor.h>
-#include <coreplugin/idocument.h>
namespace ImageViewer {
namespace Internal {
-class ImageViewerFactory : public Core::IEditorFactory
+class ImageViewerFactory final : public Core::IEditorFactory
{
- Q_OBJECT
public:
ImageViewerFactory();
-
- Core::IEditor *createEditor() override;
};
} // namespace Internal
diff --git a/src/plugins/modeleditor/modeleditorfactory.cpp b/src/plugins/modeleditor/modeleditorfactory.cpp
index 355f4e2be1..821df72110 100644
--- a/src/plugins/modeleditor/modeleditorfactory.cpp
+++ b/src/plugins/modeleditor/modeleditorfactory.cpp
@@ -34,37 +34,24 @@
namespace ModelEditor {
namespace Internal {
-class ModelEditorFactory::ModelEditorFactoryPrivate
-{
-public:
- UiController *uiController = nullptr;
- ActionHandler *actionHandler = nullptr;
-};
-
ModelEditorFactory::ModelEditorFactory(UiController *uiController)
- : d(new ModelEditorFactoryPrivate())
{
setId(Constants::MODEL_EDITOR_ID);
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::MODEL_EDITOR_DISPLAY_NAME));
addMimeType(Constants::MIME_TYPE_MODEL);
- d->uiController = uiController;
- d->actionHandler = new ActionHandler(Core::Context(Constants::MODEL_EDITOR_ID), this);
+ m_uiController = uiController;
+ m_actionHandler = new ActionHandler(Core::Context(Constants::MODEL_EDITOR_ID), this);
+ setEditorCreator([this] { return new ModelEditor(m_uiController, m_actionHandler); });
}
ModelEditorFactory::~ModelEditorFactory()
{
- delete d->actionHandler;
- delete d;
-}
-
-Core::IEditor *ModelEditorFactory::createEditor()
-{
- return new ModelEditor(d->uiController, d->actionHandler);
+ delete m_actionHandler;
}
void ModelEditorFactory::extensionsInitialized()
{
- d->actionHandler->createActions();
+ m_actionHandler->createActions();
}
} // namespace Internal
diff --git a/src/plugins/modeleditor/modeleditorfactory.h b/src/plugins/modeleditor/modeleditorfactory.h
index a14479cc3f..5ae8ab563d 100644
--- a/src/plugins/modeleditor/modeleditorfactory.h
+++ b/src/plugins/modeleditor/modeleditorfactory.h
@@ -30,24 +30,21 @@
namespace ModelEditor {
namespace Internal {
+class ActionHandler;
class ModelEditor;
class UiController;
-class ModelEditorFactory :
- public Core::IEditorFactory
+class ModelEditorFactory : public Core::IEditorFactory
{
- Q_OBJECT
- class ModelEditorFactoryPrivate;
-
public:
explicit ModelEditorFactory(UiController *uiController);
~ModelEditorFactory();
- Core::IEditor *createEditor() override;
void extensionsInitialized();
private:
- ModelEditorFactoryPrivate *d;
+ UiController *m_uiController = nullptr;
+ ActionHandler *m_actionHandler = nullptr;
};
} // namespace Internal
diff --git a/src/plugins/nim/editor/nimeditorfactory.cpp b/src/plugins/nim/editor/nimeditorfactory.cpp
index 48a3631162..51d6c22f4b 100644
--- a/src/plugins/nim/editor/nimeditorfactory.cpp
+++ b/src/plugins/nim/editor/nimeditorfactory.cpp
@@ -71,11 +71,6 @@ NimEditorFactory::NimEditorFactory()
setCodeFoldingSupported(true);
}
-Core::IEditor *NimEditorFactory::createEditor()
-{
- return TextEditorFactory::createEditor();
-}
-
void NimEditorFactory::decorateEditor(TextEditorWidget *editor)
{
editor->textDocument()->setSyntaxHighlighter(new NimHighlighter());
diff --git a/src/plugins/nim/editor/nimeditorfactory.h b/src/plugins/nim/editor/nimeditorfactory.h
index bfb15ecd3e..ac60a3593d 100644
--- a/src/plugins/nim/editor/nimeditorfactory.h
+++ b/src/plugins/nim/editor/nimeditorfactory.h
@@ -36,7 +36,6 @@ class NimEditorFactory : public TextEditor::TextEditorFactory
public:
NimEditorFactory();
- Core::IEditor *createEditor() override;
static void decorateEditor(TextEditor::TextEditorWidget *editor);
};
diff --git a/src/plugins/resourceeditor/resourceeditorfactory.cpp b/src/plugins/resourceeditor/resourceeditorfactory.cpp
index 3b81616328..0b326d4a46 100644
--- a/src/plugins/resourceeditor/resourceeditorfactory.cpp
+++ b/src/plugins/resourceeditor/resourceeditorfactory.cpp
@@ -40,8 +40,7 @@ using namespace ResourceEditor::Internal;
using namespace ResourceEditor::Constants;
ResourceEditorFactory::ResourceEditorFactory(ResourceEditorPlugin *plugin) :
- Core::IEditorFactory(plugin),
- m_plugin(plugin)
+ Core::IEditorFactory(plugin)
{
setId(RESOURCEEDITOR_ID);
setMimeTypes(QStringList(QLatin1String(C_RESOURCE_MIMETYPE)));
@@ -49,10 +48,8 @@ ResourceEditorFactory::ResourceEditorFactory(ResourceEditorPlugin *plugin) :
Core::FileIconProvider::registerIconOverlayForSuffix(
ProjectExplorer::Constants::FILEOVERLAY_QRC, "qrc");
-}
-Core::IEditor *ResourceEditorFactory::createEditor()
-{
- Core::Context context(C_RESOURCEEDITOR);
- return new ResourceEditorW(context, m_plugin);
+ setEditorCreator([plugin] {
+ return new ResourceEditorW(Core::Context(C_RESOURCEEDITOR), plugin);
+ });
}
diff --git a/src/plugins/resourceeditor/resourceeditorfactory.h b/src/plugins/resourceeditor/resourceeditorfactory.h
index ed15110d2f..1a54515a47 100644
--- a/src/plugins/resourceeditor/resourceeditorfactory.h
+++ b/src/plugins/resourceeditor/resourceeditorfactory.h
@@ -26,26 +26,16 @@
#pragma once
#include <coreplugin/editormanager/ieditorfactory.h>
-#include <coreplugin/icontext.h>
-
-#include <QStringList>
namespace ResourceEditor {
namespace Internal {
class ResourceEditorPlugin;
-class ResourceEditorFactory : public Core::IEditorFactory
+class ResourceEditorFactory final : public Core::IEditorFactory
{
- Q_OBJECT
-
public:
explicit ResourceEditorFactory(ResourceEditorPlugin *plugin);
-
- Core::IEditor *createEditor() override;
-
-private:
- ResourceEditorPlugin *m_plugin;
};
} // namespace Internal
diff --git a/src/plugins/scxmleditor/scxmleditorfactory.cpp b/src/plugins/scxmleditor/scxmleditorfactory.cpp
index 013ce959e7..a7120e71df 100644
--- a/src/plugins/scxmleditor/scxmleditorfactory.cpp
+++ b/src/plugins/scxmleditor/scxmleditorfactory.cpp
@@ -46,15 +46,14 @@ ScxmlEditorFactory::ScxmlEditorFactory(QObject *parent)
addMimeType(ProjectExplorer::Constants::SCXML_MIMETYPE);
Core::FileIconProvider::registerIconOverlayForSuffix(":/projectexplorer/images/fileoverlay_scxml.png", "scxml");
-}
-Core::IEditor *ScxmlEditorFactory::createEditor()
-{
- if (!m_editorData) {
- m_editorData = new ScxmlEditorData(this);
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
- m_editorData->fullInit();
- QGuiApplication::restoreOverrideCursor();
- }
- return m_editorData->createEditor();
+ setEditorCreator([this] {
+ if (!m_editorData) {
+ m_editorData = new ScxmlEditorData(this);
+ QGuiApplication::setOverrideCursor(Qt::WaitCursor);
+ m_editorData->fullInit();
+ QGuiApplication::restoreOverrideCursor();
+ }
+ return m_editorData->createEditor();
+ });
}
diff --git a/src/plugins/scxmleditor/scxmleditorfactory.h b/src/plugins/scxmleditor/scxmleditorfactory.h
index 8732d94acc..42135ec64b 100644
--- a/src/plugins/scxmleditor/scxmleditorfactory.h
+++ b/src/plugins/scxmleditor/scxmleditorfactory.h
@@ -32,15 +32,11 @@ namespace Internal {
class ScxmlEditorData;
-class ScxmlEditorFactory : public Core::IEditorFactory
+class ScxmlEditorFactory final : public Core::IEditorFactory
{
- Q_OBJECT
-
public:
explicit ScxmlEditorFactory(QObject *parent);
- Core::IEditor *createEditor() override;
-
private:
ScxmlEditorData* m_editorData = nullptr;
};
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index 0bb5a7c5ee..77e5e50bf8 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -8506,8 +8506,7 @@ class TextEditorFactoryPrivate
public:
TextEditorFactoryPrivate(TextEditorFactory *parent) :
q(parent),
- m_widgetCreator([]() { return new TextEditorWidget; }),
- m_editorCreator([]() { return new BaseTextEditor; })
+ m_widgetCreator([]() { return new TextEditorWidget; })
{}
BaseTextEditor *duplicateTextEditor(BaseTextEditor *other)
@@ -8540,7 +8539,9 @@ public:
TextEditorFactory::TextEditorFactory(QObject *parent)
: IEditorFactory(parent), d(new TextEditorFactoryPrivate(this))
-{}
+{
+ setEditorCreator([]() { return new BaseTextEditor; });
+}
TextEditorFactory::~TextEditorFactory()
{
@@ -8562,6 +8563,21 @@ void TextEditorFactory::setEditorWidgetCreator(const EditorWidgetCreator &creato
void TextEditorFactory::setEditorCreator(const EditorCreator &creator)
{
d->m_editorCreator = creator;
+ IEditorFactory::setEditorCreator([this] {
+ static DocumentContentCompletionProvider basicSnippetProvider;
+ TextDocumentPtr doc(d->m_documentCreator());
+
+ if (d->m_indenterCreator)
+ doc->setIndenter(d->m_indenterCreator(doc->document()));
+
+ if (d->m_syntaxHighlighterCreator)
+ doc->setSyntaxHighlighter(d->m_syntaxHighlighterCreator());
+
+ doc->setCompletionAssistProvider(d->m_completionAssistProvider ? d->m_completionAssistProvider
+ : &basicSnippetProvider);
+
+ return d->createEditorHelper(doc);
+ });
}
void TextEditorFactory::setIndenterCreator(const IndenterCreator &creator)
@@ -8629,23 +8645,6 @@ void TextEditorFactory::setParenthesesMatchingEnabled(bool on)
d->m_paranthesesMatchinEnabled = on;
}
-IEditor *TextEditorFactory::createEditor()
-{
- static DocumentContentCompletionProvider basicSnippetProvider;
- TextDocumentPtr doc(d->m_documentCreator());
-
- if (d->m_indenterCreator)
- doc->setIndenter(d->m_indenterCreator(doc->document()));
-
- if (d->m_syntaxHighlighterCreator)
- doc->setSyntaxHighlighter(d->m_syntaxHighlighterCreator());
-
- doc->setCompletionAssistProvider(d->m_completionAssistProvider ? d->m_completionAssistProvider
- : &basicSnippetProvider);
-
- return d->createEditorHelper(doc);
-}
-
BaseTextEditor *TextEditorFactoryPrivate::createEditorHelper(const TextDocumentPtr &document)
{
TextEditorWidget *widget = m_widgetCreator();
diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h
index 42d3c78dc0..6b2156cb25 100644
--- a/src/plugins/texteditor/texteditor.h
+++ b/src/plugins/texteditor/texteditor.h
@@ -666,8 +666,6 @@ public:
void setParenthesesMatchingEnabled(bool on);
void setCodeFoldingSupported(bool on);
- Core::IEditor *createEditor() override;
-
private:
friend class BaseTextEditor;
friend class PlainTextEditorFactory;
diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
index e366d8e56a..f278b8a0eb 100644
--- a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
+++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
@@ -44,12 +44,18 @@ VcsSubmitEditorFactory::VcsSubmitEditorFactory
(const VcsBaseSubmitEditorParameters *parameters,
const EditorCreator &editorCreator,
VcsBasePluginPrivate *plugin)
- : IEditorFactory(plugin), m_editorCreator(editorCreator)
+ : IEditorFactory(plugin)
{
setId(parameters->id);
setDisplayName(QLatin1String(parameters->displayName));
addMimeType(parameters->mimeType);
+ setEditorCreator([this, editorCreator] {
+ VcsBaseSubmitEditor *editor = editorCreator();
+ editor->registerActions(m_undoAction, m_redoAction, m_submitAction, m_diffAction);
+ return editor;
+ });
+
Context context(parameters->id);
m_undoAction = new QAction(tr("&Undo"), this);
ActionManager::registerAction(m_undoAction, Core::Constants::UNDO, context);
@@ -68,11 +74,4 @@ VcsSubmitEditorFactory::VcsSubmitEditorFactory
ActionManager::registerAction(m_diffAction, DIFF_SELECTED, context);
}
-Core::IEditor *VcsSubmitEditorFactory::createEditor()
-{
- VcsBaseSubmitEditor *editor = m_editorCreator();
- editor->registerActions(m_undoAction, m_redoAction, m_submitAction, m_diffAction);
- return editor;
-}
-
} // namespace VcsBase
diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.h b/src/plugins/vcsbase/basevcssubmiteditorfactory.h
index 5cb7e84bcb..da648eeb17 100644
--- a/src/plugins/vcsbase/basevcssubmiteditorfactory.h
+++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.h
@@ -51,10 +51,7 @@ public:
const EditorCreator &editorCreator,
VcsBasePluginPrivate *plugin);
- Core::IEditor *createEditor() override;
-
private:
- EditorCreator m_editorCreator;
QAction *m_submitAction = nullptr;
QAction *m_diffAction = nullptr;
QAction *m_undoAction = nullptr;