TextEditor: Reset mimetype after open() in all BaseTextEditors

This was already done in all major editors and should not harm
all others.

Change-Id: I7e19d285c4b85419a9a1f9afa961addecf682eaf
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
hjk
2014-09-03 13:10:57 +02:00
parent 480efb0254
commit 2e17339b05
7 changed files with 4 additions and 74 deletions

View File

@@ -546,14 +546,6 @@ void CppEditorWidget::keyPressEvent(QKeyEvent *e)
TextEditor::BaseTextEditorWidget::keyPressEvent(e); TextEditor::BaseTextEditorWidget::keyPressEvent(e);
} }
bool CppEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
if (!TextEditor::BaseTextEditor::open(errorString, fileName, realFileName))
return false;
textDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
return true;
}
void CppEditorWidget::applyFontSettings() void CppEditorWidget::applyFontSettings()
{ {
// This also makes the document apply font settings // This also makes the document apply font settings

View File

@@ -56,10 +56,6 @@ class CppEditor : public TextEditor::BaseTextEditor
public: public:
CppEditor(); CppEditor();
bool open(QString *errorString,
const QString &fileName,
const QString &realFileName) QTC_OVERRIDE;
}; };
class CppEditorWidget : public TextEditor::BaseTextEditorWidget class CppEditorWidget : public TextEditor::BaseTextEditorWidget

View File

@@ -47,7 +47,6 @@
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/id.h> #include <coreplugin/id.h>
#include <coreplugin/mimedatabase.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h> #include <extensionsystem/pluginspec.h>
@@ -326,26 +325,6 @@ IAssistInterface *GlslEditorWidget::createAssistInterface(
} }
//
// GlslEditor
//
class GlslEditor : public TextEditor::BaseTextEditor
{
public:
GlslEditor()
{
}
bool open(QString *errorString, const QString &fileName, const QString &realFileName)
{
textDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
bool b = BaseTextEditor::open(errorString, fileName, realFileName);
return b;
}
};
// //
// GlslEditorFactory // GlslEditorFactory
// //
@@ -362,7 +341,6 @@ GlslEditorFactory::GlslEditorFactory()
setDocumentCreator([]() { return new BaseTextDocument(Constants::C_GLSLEDITOR_ID); }); setDocumentCreator([]() { return new BaseTextDocument(Constants::C_GLSLEDITOR_ID); });
setEditorWidgetCreator([]() { return new GlslEditorWidget; }); setEditorWidgetCreator([]() { return new GlslEditorWidget; });
setEditorCreator([]() { return new GlslEditor; });
setIndenterCreator([]() { return new GlslIndenter; }); setIndenterCreator([]() { return new GlslIndenter; });
setSyntaxHighlighterCreator([]() { return new GlslHighlighter; }); setSyntaxHighlighterCreator([]() { return new GlslHighlighter; });
setCommentStyle(Utils::CommentDefinition::CppStyle); setCommentStyle(Utils::CommentDefinition::CppStyle);

View File

@@ -33,46 +33,17 @@
#include "tools/pythonindenter.h" #include "tools/pythonindenter.h"
#include "tools/pythonhighlighter.h" #include "tools/pythonhighlighter.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditoractionhandler.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <texteditor/basetextdocument.h> #include <texteditor/basetextdocument.h>
#include <texteditor/indenter.h>
#include <texteditor/autocompleter.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QFileInfo>
using namespace TextEditor; using namespace TextEditor;
namespace PythonEditor { namespace PythonEditor {
namespace Internal { namespace Internal {
//
// PythonEditor
//
class PythonEditor : public BaseTextEditor
{
public:
PythonEditor()
{
}
bool open(QString *errorString, const QString &fileName, const QString &realFileName)
{
Core::MimeType mimeType = Core::MimeDatabase::findByFile(QFileInfo(fileName));
textDocument()->setMimeType(mimeType.type());
return BaseTextEditor::open(errorString, fileName, realFileName);
}
};
// //
// PythonEditorWidget // PythonEditorWidget
// //
@@ -105,7 +76,6 @@ PythonEditorFactory::PythonEditorFactory()
setDocumentCreator([]() { return new BaseTextDocument(Constants::C_PYTHONEDITOR_ID); }); setDocumentCreator([]() { return new BaseTextDocument(Constants::C_PYTHONEDITOR_ID); });
setEditorWidgetCreator([]() { return new PythonEditorWidget; }); setEditorWidgetCreator([]() { return new PythonEditorWidget; });
setEditorCreator([]() { return new PythonEditor; });
setIndenterCreator([]() { return new PythonIndenter; }); setIndenterCreator([]() { return new PythonIndenter; });
setSyntaxHighlighterCreator([]() { return new PythonHighlighter; }); setSyntaxHighlighterCreator([]() { return new PythonHighlighter; });
setCommentStyle(Utils::CommentDefinition::HashStyle); setCommentStyle(Utils::CommentDefinition::HashStyle);

View File

@@ -56,7 +56,6 @@
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/id.h> #include <coreplugin/id.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/modemanager.h> #include <coreplugin/modemanager.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
@@ -173,13 +172,6 @@ QModelIndex QmlJSEditorWidget::outlineModelIndex()
return m_outlineModelIndex; return m_outlineModelIndex;
} }
bool QmlJSEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
bool b = BaseTextEditor::open(errorString, fileName, realFileName);
textDocument()->setMimeType(MimeDatabase::findByFile(QFileInfo(fileName)).type());
return b;
}
static void appendExtraSelectionsForMessages( static void appendExtraSelectionsForMessages(
QList<QTextEdit::ExtraSelection> *selections, QList<QTextEdit::ExtraSelection> *selections,
const QList<DiagnosticMessage> &messages, const QList<DiagnosticMessage> &messages,

View File

@@ -145,7 +145,6 @@ class QmlJSEditor : public TextEditor::BaseTextEditor
public: public:
QmlJSEditor(); QmlJSEditor();
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
bool isDesignModePreferred() const; bool isDesignModePreferred() const;
}; };

View File

@@ -7024,7 +7024,10 @@ QString BaseTextEditorWidget::foldReplacementText(const QTextBlock &) const
bool BaseTextEditor::open(QString *errorString, const QString &fileName, const QString &realFileName) bool BaseTextEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{ {
return editorWidget()->open(errorString, fileName, realFileName); if (!editorWidget()->open(errorString, fileName, realFileName))
return false;
textDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
return true;
} }
QByteArray BaseTextEditor::saveState() const QByteArray BaseTextEditor::saveState() const