diff options
author | hjk <hjk121@nokiamail.com> | 2014-08-20 13:52:31 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-08-20 16:10:21 +0200 |
commit | d85a4f61550af6d42abbca61e2d2ad1102dc8d27 (patch) | |
tree | 61028fa3eeb4f6eef78ecfdfde73be1d4fc4bf7c /src/plugins/texteditor/snippets | |
parent | 96b18db8546ac5d18deff8cb8ad9dc148dc4154c (diff) |
TextEditor: Move SnippetsEditor to new editor construction scheme
Change-Id: I10612d86b6a634e7370c1a29507f709132f4e54b
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src/plugins/texteditor/snippets')
-rw-r--r-- | src/plugins/texteditor/snippets/snippeteditor.cpp | 15 | ||||
-rw-r--r-- | 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 <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 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); |