diff options
author | hjk <hjk@qt.io> | 2020-02-04 18:16:57 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2020-02-05 11:41:29 +0000 |
commit | d7ae3b79f89f91f6b15f807b5c894da7e06c3013 (patch) | |
tree | ebbd5ded1ddd1fa035e99ebe98b384e676cfebb4 /src/plugins/bineditor | |
parent | ccc2a347a75c3fd06d8f2028a17a3477c40e0a13 (diff) | |
download | qt-creator-d7ae3b79f89f91f6b15f807b5c894da7e06c3013.tar.gz |
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/bineditor')
-rw-r--r-- | src/plugins/bineditor/bineditorplugin.cpp | 41 | ||||
-rw-r--r-- | src/plugins/bineditor/bineditorplugin.h | 6 |
2 files changed, 21 insertions, 26 deletions
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 |