TextEditor: Simplify configuring generic highlighter

* configureMimeType -> configureGenericHighlighter, since that is what
  it actually does.
* setupAsPlainEditor -> setupGenericHighlighter, since that is what it
  actually does
* avoid multiple highlighting definition lookups
* unify code paths by not separately creating generic highlighters
  through the factories

Change-Id: I9579ca5736bbf08c01b8e41b63c6b9f36bdc725e
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Eike Ziller
2015-02-03 09:18:57 +01:00
parent 2aa315d05c
commit e7fb05e038
12 changed files with 37 additions and 55 deletions

View File

@@ -51,7 +51,10 @@ class PlainTextEditorWidget : public TextEditorWidget
{
public:
PlainTextEditorWidget() {}
void finalizeInitialization() { setupAsPlainEditor(); }
void finalizeInitialization()
{
textDocument()->setMimeType(QLatin1String(Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
}
};
PlainTextEditorFactory::PlainTextEditorFactory()
@@ -65,6 +68,7 @@ PlainTextEditorFactory::PlainTextEditorFactory()
setDocumentCreator([]() { return new TextDocument(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); });
setEditorWidgetCreator([]() { return new PlainTextEditorWidget; });
setIndenterCreator([]() { return new NormalIndenter; });
setUseGenericHighlighter(true);
setEditorActionHandlers(TextEditorActionHandler::Format |
TextEditorActionHandler::UnCommentSelection |