forked from qt-creator/qt-creator
TextEditor: Move SnippetsEditor to new editor construction scheme
Change-Id: I10612d86b6a634e7370c1a29507f709132f4e54b Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -31,10 +31,11 @@
|
|||||||
|
|
||||||
#include <texteditor/basetextdocument.h>
|
#include <texteditor/basetextdocument.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QFocusEvent>
|
#include <QFocusEvent>
|
||||||
|
|
||||||
using namespace TextEditor;
|
namespace TextEditor {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class TextEditor::SnippetEditorWidget
|
\class TextEditor::SnippetEditorWidget
|
||||||
@@ -45,15 +46,15 @@ using namespace TextEditor;
|
|||||||
|
|
||||||
SnippetEditor::SnippetEditor()
|
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)
|
SnippetEditorWidget::SnippetEditorWidget(QWidget *parent)
|
||||||
: BaseTextEditorWidget(parent)
|
: BaseTextEditorWidget(parent)
|
||||||
{
|
{
|
||||||
BaseTextDocumentPtr doc(new BaseTextDocument);
|
|
||||||
doc->setId(Constants::SNIPPET_EDITOR_ID);
|
|
||||||
setTextDocument(doc);
|
|
||||||
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
||||||
setHighlightCurrentLine(false);
|
setHighlightCurrentLine(false);
|
||||||
setLineNumbersVisible(false);
|
setLineNumbersVisible(false);
|
||||||
@@ -76,5 +77,7 @@ void SnippetEditorWidget::focusOutEvent(QFocusEvent *event)
|
|||||||
|
|
||||||
BaseTextEditor *SnippetEditorWidget::createEditor()
|
BaseTextEditor *SnippetEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
return new SnippetEditor;
|
QTC_ASSERT("should not happen anymore" && false, return 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ class TEXTEDITOR_EXPORT SnippetEditor : public BaseTextEditor
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
SnippetEditor();
|
SnippetEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate() { return 0; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TEXTEDITOR_EXPORT SnippetEditorWidget : public BaseTextEditorWidget
|
class TEXTEDITOR_EXPORT SnippetEditorWidget : public BaseTextEditorWidget
|
||||||
@@ -56,7 +54,7 @@ class TEXTEDITOR_EXPORT SnippetEditorWidget : public BaseTextEditorWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SnippetEditorWidget(QWidget *parent);
|
SnippetEditorWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
void setSyntaxHighlighter(SyntaxHighlighter *highlighter);
|
void setSyntaxHighlighter(SyntaxHighlighter *highlighter);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user