Commit 5a3a940a authored by Eike Ziller's avatar Eike Ziller
Browse files

Use new mime database



Change-Id: I4305872b6b11ef3e8a364280ffa5209a5a793600
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 365c1ddb
......@@ -33,8 +33,6 @@
#include "highlightdefinitionmetadata.h"
#include <coreplugin/mimedatabase.h>
#include <QString>
#include <QHash>
#include <QSet>
......@@ -51,6 +49,8 @@ class QIODevice;
template <class> class QFutureInterface;
QT_END_NAMESPACE
namespace Utils { class MimeType; }
namespace TextEditor {
namespace Internal {
......@@ -69,9 +69,9 @@ public:
static Manager *instance();
QString definitionIdByName(const QString &name) const;
QString definitionIdByMimeType(const Core::MimeType &mimeType) const;
QString definitionIdByMimeType(const Utils::MimeType &mimeType) const;
QString definitionIdByFile(const QString &filePath) const;
QString definitionIdByMimeTypeAndFile(const Core::MimeType &mimeType,
QString definitionIdByMimeTypeAndFile(const Utils::MimeType &mimeType,
const QString &filePath) const;
DefinitionMetaDataPtr availableDefinitionByName(const QString &name) const;
......
......@@ -33,11 +33,12 @@
#include "generichighlighter/highlightdefinition.h"
#include "generichighlighter/manager.h"
#include <coreplugin/icore.h>
#include <utils/mimetypes/mimetype.h>
using namespace TextEditor;
using namespace Internal;
void TextEditor::setMimeTypeForHighlighter(Highlighter *highlighter, const Core::MimeType &mimeType,
void TextEditor::setMimeTypeForHighlighter(Highlighter *highlighter, const Utils::MimeType &mimeType,
const QString &filePath, QString *foundDefinitionId)
{
QString definitionId = Manager::instance()->definitionIdByMimeTypeAndFile(mimeType, filePath);
......
......@@ -38,13 +38,13 @@
* but due to a very hackish test of that generic highlighter,
* there functions must be outside. */
namespace Core { class MimeType; }
namespace Utils { class MimeType; }
namespace TextEditor {
class Highlighter;
void setMimeTypeForHighlighter(Highlighter *highlighter, const Core::MimeType &mimeType,
void setMimeTypeForHighlighter(Highlighter *highlighter, const Utils::MimeType &mimeType,
const QString &filePath,
QString *foundDefinitionId = 0);
......
......@@ -74,6 +74,7 @@
#include <utils/linecolumnlabel.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <utils/stylehelper.h>
#include <utils/tooltip/tooltip.h>
......@@ -2735,7 +2736,8 @@ void TextEditorWidgetPrivate::updateCodeFoldingVisible()
void TextEditorWidgetPrivate::reconfigure()
{
m_document->setMimeType(MimeDatabase::findByFile(m_document->filePath().toString()).type());
Utils::MimeDatabase mdb;
m_document->setMimeType(mdb.mimeTypeForFile(m_document->filePath().toString()).name());
q->configureGenericHighlighter();
}
......@@ -7109,7 +7111,8 @@ bool BaseTextEditor::open(QString *errorString, const QString &fileName, const Q
{
if (!editorWidget()->open(errorString, fileName, realFileName))
return false;
textDocument()->setMimeType(MimeDatabase::findByFile(QFileInfo(fileName)).type());
Utils::MimeDatabase mdb;
textDocument()->setMimeType(mdb.mimeTypeForFile(fileName).name());
return true;
}
......@@ -7173,8 +7176,9 @@ void TextEditorWidget::configureGenericHighlighter()
setCodeFoldingSupported(false);
const QString type = textDocument()->mimeType();
const MimeType mimeType = MimeDatabase::findByType(type);
if (!mimeType.isNull()) {
Utils::MimeDatabase mdb;
const Utils::MimeType mimeType = mdb.mimeTypeForName(type);
if (mimeType.isValid()) {
d->m_isMissingSyntaxDefinition = true;
QString definitionId;
......
......@@ -59,8 +59,6 @@ class QRect;
class QTextBlock;
QT_END_NAMESPACE
namespace Core { class MimeType; }
namespace TextEditor {
class BaseHoverHandler;
......
......@@ -2,7 +2,6 @@
<qresource prefix="/texteditor">
<file>images/finddocuments.png</file>
<file>images/finddirectory.png</file>
<file>TextEditor.mimetypes.xml</file>
<file>images/refactormarker.png</file>
<file>images/snippet.png</file>
<file>images/f1.png</file>
......
......@@ -91,9 +91,7 @@ TextEditorPlugin::~TextEditorPlugin()
bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments)
if (!MimeDatabase::addMimeTypes(QLatin1String(":/texteditor/TextEditor.mimetypes.xml"), errorMessage))
return false;
Q_UNUSED(errorMessage)
m_settings = new TextEditorSettings(this);
......
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="text/x-patch">
<sub-class-of type="text/plain"/>
<comment>Differences between files</comment>
<glob pattern="*.patch"/>
<glob pattern="*.diff"/>
<!-- Find unified diffs from code pasting utilities by checking for "+++ foo.cpp"
Note that this must have a higher priority than any content
rule for C++ as we want diffs to take preference when looking
at a C++ patch.
-->
<magic priority="60">
<match value="&#x0a;+++ " type="string" offset="0:10000"/>
</magic>
</mime-type>
</mime-info>
<RCC>
<qresource prefix="/vcsbase" >
<file>VcsBase.mimetypes.xml</file>
<qresource prefix="/vcsbase">
<file>images/category_vcs.png</file>
<file>images/diff.png</file>
<file>images/removesubmitfield.png</file>
......
......@@ -41,7 +41,6 @@
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/jsexpander.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/vcsmanager.h>
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
......@@ -77,9 +76,7 @@ VcsPlugin::~VcsPlugin()
bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments)
if (!MimeDatabase::addMimeTypes(QLatin1String(":/vcsbase/VcsBase.mimetypes.xml"), errorMessage))
return false;
Q_UNUSED(errorMessage)
m_coreListener = new CoreListener;
addAutoReleasedObject(m_coreListener);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment