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>
This commit is contained in:
hjk
2020-02-04 18:16:57 +01:00
parent ccc2a347a7
commit d7ae3b79f8
24 changed files with 104 additions and 175 deletions

View File

@@ -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