summaryrefslogtreecommitdiff
path: root/src/plugins/diffeditor
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-02-05 17:51:41 +0100
committerhjk <hjk@qt.io>2020-02-10 13:54:39 +0000
commit9c934ed44cd107adcef85898393ffc02e0f29e5d (patch)
treec1219b52429e61fac27c1acc4422c91799c492ad /src/plugins/diffeditor
parente12ba2d68312434f50437c3b01f12834926eeb3b (diff)
downloadqt-creator-9c934ed44cd107adcef85898393ffc02e0f29e5d.tar.gz
TextEditor: De-QObject-ify TextEditorActionHandler
Change-Id: I8c4919b89ce35d421edd4a21a650d5e0df4a7ead Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/diffeditor')
-rw-r--r--src/plugins/diffeditor/diffeditorfactory.cpp50
-rw-r--r--src/plugins/diffeditor/diffeditorfactory.h8
2 files changed, 36 insertions, 22 deletions
diff --git a/src/plugins/diffeditor/diffeditorfactory.cpp b/src/plugins/diffeditor/diffeditorfactory.cpp
index 12a1d58ff9..46c79df29d 100644
--- a/src/plugins/diffeditor/diffeditorfactory.cpp
+++ b/src/plugins/diffeditor/diffeditorfactory.cpp
@@ -33,35 +33,41 @@
#include <QCoreApplication>
+using namespace Core;
+using namespace TextEditor;
+
namespace DiffEditor {
namespace Internal {
-DiffEditorFactory::DiffEditorFactory()
+DiffEditorFactory::DiffEditorFactory() :
+ descriptionHandler {
+ Constants::DIFF_EDITOR_ID,
+ Constants::C_DIFF_EDITOR_DESCRIPTION,
+ TextEditorActionHandler::None,
+ [](IEditor *e) { return static_cast<DiffEditor *>(e)->descriptionWidget(); }
+ },
+ unifiedHandler {
+ Constants::DIFF_EDITOR_ID,
+ Constants::UNIFIED_VIEW_ID,
+ TextEditorActionHandler::None,
+ [](IEditor *e) { return static_cast<DiffEditor *>(e)->unifiedEditorWidget(); }
+ },
+ leftHandler {
+ Constants::DIFF_EDITOR_ID,
+ Id(Constants::SIDE_BY_SIDE_VIEW_ID).withSuffix(1),
+ TextEditorActionHandler::None,
+ [](IEditor *e) { return static_cast<DiffEditor *>(e)->leftEditorWidget(); }
+ },
+ rightHandler {
+ Constants::DIFF_EDITOR_ID,
+ Core::Id(Constants::SIDE_BY_SIDE_VIEW_ID).withSuffix(2),
+ TextEditorActionHandler::None,
+ [](Core::IEditor *e) { return static_cast<DiffEditor *>(e)->rightEditorWidget(); }
+ }
{
setId(Constants::DIFF_EDITOR_ID);
setDisplayName(QCoreApplication::translate("DiffEditorFactory", Constants::DIFF_EDITOR_DISPLAY_NAME));
addMimeType(Constants::DIFF_EDITOR_MIMETYPE);
- auto descriptionHandler = new TextEditor::TextEditorActionHandler(
- this, id(), Constants::C_DIFF_EDITOR_DESCRIPTION);
- descriptionHandler->setTextEditorWidgetResolver([](Core::IEditor *e) {
- return static_cast<DiffEditor *>(e)->descriptionWidget();
- });
- auto unifiedHandler = new TextEditor::TextEditorActionHandler(
- this, id(), Constants::UNIFIED_VIEW_ID);
- unifiedHandler->setTextEditorWidgetResolver([](Core::IEditor *e) {
- return static_cast<DiffEditor *>(e)->unifiedEditorWidget();
- });
- auto leftHandler = new TextEditor::TextEditorActionHandler(
- this, id(), Core::Id(Constants::SIDE_BY_SIDE_VIEW_ID).withSuffix(1));
- leftHandler->setTextEditorWidgetResolver([](Core::IEditor *e) {
- return static_cast<DiffEditor *>(e)->leftEditorWidget();
- });
- auto rightHandler = new TextEditor::TextEditorActionHandler(
- this, id(), Core::Id(Constants::SIDE_BY_SIDE_VIEW_ID).withSuffix(2));
- rightHandler->setTextEditorWidgetResolver([](Core::IEditor *e) {
- return static_cast<DiffEditor *>(e)->rightEditorWidget();
- });
-
setEditorCreator([] { return new DiffEditor(new DiffEditorDocument); });
}
diff --git a/src/plugins/diffeditor/diffeditorfactory.h b/src/plugins/diffeditor/diffeditorfactory.h
index 3f9fbfac64..7a4abbab7a 100644
--- a/src/plugins/diffeditor/diffeditorfactory.h
+++ b/src/plugins/diffeditor/diffeditorfactory.h
@@ -27,6 +27,8 @@
#include <coreplugin/editormanager/ieditorfactory.h>
+#include <texteditor/texteditoractionhandler.h>
+
namespace DiffEditor {
namespace Internal {
@@ -34,6 +36,12 @@ class DiffEditorFactory : public Core::IEditorFactory
{
public:
DiffEditorFactory();
+
+private:
+ TextEditor::TextEditorActionHandler descriptionHandler;
+ TextEditor::TextEditorActionHandler unifiedHandler;
+ TextEditor::TextEditorActionHandler leftHandler;
+ TextEditor::TextEditorActionHandler rightHandler;
};
} // namespace Internal