From 494f71c71aa1ac2da93ed8e60a2956ee56d8b159 Mon Sep 17 00:00:00 2001 From: Leandro Melo <leandro.melo@nokia.com> Date: Fri, 21 May 2010 14:18:34 +0200 Subject: [PATCH] Generic highlighter: Making highlighting available for desinger XML editor. --- src/plugins/designer/formwindoweditor.cpp | 11 +++++++++++ src/plugins/designer/formwindoweditor.h | 1 + src/plugins/texteditor/TextEditor.mimetypes.xml | 1 + 3 files changed, 13 insertions(+) diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp index 895ac3aae16..76d606a9a23 100644 --- a/src/plugins/designer/formwindoweditor.cpp +++ b/src/plugins/designer/formwindoweditor.cpp @@ -39,6 +39,7 @@ #include <coreplugin/icore.h> #include <coreplugin/coreconstants.h> #include <coreplugin/uniqueidmanager.h> +#include <coreplugin/mimedatabase.h> #include <texteditor/basetextdocument.h> #include <texteditor/plaintexteditor.h> @@ -82,6 +83,7 @@ FormWindowEditor::FormWindowEditor(Internal::DesignerXmlEditor *editor, // Force update of open editors model. connect(&(d->m_file), SIGNAL(saved()), this, SIGNAL(changed())); connect(&(d->m_file), SIGNAL(changed()), this, SIGNAL(changed())); + connect(this, SIGNAL(changed()), this, SLOT(configureXmlEditor())); } FormWindowEditor::~FormWindowEditor() @@ -164,6 +166,15 @@ void FormWindowEditor::syncXmlEditor() syncXmlEditor(contents()); } +void FormWindowEditor::configureXmlEditor() const +{ + TextEditor::PlainTextEditor *editor = + qobject_cast<TextEditor::PlainTextEditor *>(d->m_textEditable.editor()); + if (editor) + editor->configure(Core::ICore::instance()->mimeDatabase()->findByFile( + d->m_file.fileName())); +} + void FormWindowEditor::syncXmlEditor(const QString &contents) { d->m_textEditable.editor()->setPlainText(contents); diff --git a/src/plugins/designer/formwindoweditor.h b/src/plugins/designer/formwindoweditor.h index d85845e7d2d..d432189d294 100644 --- a/src/plugins/designer/formwindoweditor.h +++ b/src/plugins/designer/formwindoweditor.h @@ -102,6 +102,7 @@ public: public slots: void syncXmlEditor(); + void configureXmlEditor() const; private slots: void slotOpen(const QString &fileName); diff --git a/src/plugins/texteditor/TextEditor.mimetypes.xml b/src/plugins/texteditor/TextEditor.mimetypes.xml index 913b9fe0eba..c2b7765b316 100644 --- a/src/plugins/texteditor/TextEditor.mimetypes.xml +++ b/src/plugins/texteditor/TextEditor.mimetypes.xml @@ -6,6 +6,7 @@ <glob pattern="*.txt"/> </mime-type> <mime-type type="application/xml"> + <alias type="text/xml"/> <sub-class-of type="text/plain"/> <comment>XML document</comment> <glob pattern="*.xml"/> -- GitLab