From d85a4f61550af6d42abbca61e2d2ad1102dc8d27 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 20 Aug 2014 13:52:31 +0200 Subject: [PATCH] TextEditor: Move SnippetsEditor to new editor construction scheme Change-Id: I10612d86b6a634e7370c1a29507f709132f4e54b Reviewed-by: Christian Stenger --- src/plugins/texteditor/snippets/snippeteditor.cpp | 15 +++++++++------ src/plugins/texteditor/snippets/snippeteditor.h | 4 +--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/plugins/texteditor/snippets/snippeteditor.cpp b/src/plugins/texteditor/snippets/snippeteditor.cpp index 3c6d23dc8d1..e43e578f83f 100644 --- a/src/plugins/texteditor/snippets/snippeteditor.cpp +++ b/src/plugins/texteditor/snippets/snippeteditor.cpp @@ -31,10 +31,11 @@ #include #include +#include #include -using namespace TextEditor; +namespace TextEditor { /*! \class TextEditor::SnippetEditorWidget @@ -45,15 +46,15 @@ using namespace TextEditor; SnippetEditor::SnippetEditor() { - setContext(Core::Context(Constants::SNIPPET_EDITOR_ID, Constants::C_TEXTEDITOR)); + addContext(Constants::SNIPPET_EDITOR_ID); + setEditorCreator([]() { return new SnippetEditor; }); + setWidgetCreator([]() { return new SnippetEditorWidget; }); + setDocumentCreator([]() { return new BaseTextDocument(Constants::SNIPPET_EDITOR_ID); }); } SnippetEditorWidget::SnippetEditorWidget(QWidget *parent) : BaseTextEditorWidget(parent) { - BaseTextDocumentPtr doc(new BaseTextDocument); - doc->setId(Constants::SNIPPET_EDITOR_ID); - setTextDocument(doc); setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); setHighlightCurrentLine(false); setLineNumbersVisible(false); @@ -76,5 +77,7 @@ void SnippetEditorWidget::focusOutEvent(QFocusEvent *event) BaseTextEditor *SnippetEditorWidget::createEditor() { - return new SnippetEditor; + QTC_ASSERT("should not happen anymore" && false, return 0); } + +} // namespace diff --git a/src/plugins/texteditor/snippets/snippeteditor.h b/src/plugins/texteditor/snippets/snippeteditor.h index 0fd99d50ad4..d563fd363f5 100644 --- a/src/plugins/texteditor/snippets/snippeteditor.h +++ b/src/plugins/texteditor/snippets/snippeteditor.h @@ -47,8 +47,6 @@ class TEXTEDITOR_EXPORT SnippetEditor : public BaseTextEditor public: SnippetEditor(); - - Core::IEditor *duplicate() { return 0; } }; class TEXTEDITOR_EXPORT SnippetEditorWidget : public BaseTextEditorWidget @@ -56,7 +54,7 @@ class TEXTEDITOR_EXPORT SnippetEditorWidget : public BaseTextEditorWidget Q_OBJECT public: - SnippetEditorWidget(QWidget *parent); + SnippetEditorWidget(QWidget *parent = 0); void setSyntaxHighlighter(SyntaxHighlighter *highlighter);