diff --git a/src/plugins/texteditor/snippets/snippeteditor.cpp b/src/plugins/texteditor/snippets/snippeteditor.cpp index 3c6d23dc8d129561d1ad8c7f3388fec801c14a04..e43e578f83fd9074dbeafeaa6154500d81ce07f4 100644 --- a/src/plugins/texteditor/snippets/snippeteditor.cpp +++ b/src/plugins/texteditor/snippets/snippeteditor.cpp @@ -31,10 +31,11 @@ #include <texteditor/basetextdocument.h> #include <texteditor/texteditorconstants.h> +#include <utils/qtcassert.h> #include <QFocusEvent> -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 0fd99d50ad4a5ce678f4c39bcb49d71967bf2699..d563fd363f57350f9d9dfcf1c21f91c0f1e666af 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);