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
......@@ -59,6 +59,7 @@
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <utils/macroexpander.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <QtPlugin>
......@@ -270,24 +271,25 @@ static QStringList findFilesInProject(const QString &name,
// source belonging to a header and vice versa
static QStringList matchingCandidateSuffixes(ProjectFile::Kind kind)
{
Utils::MimeDatabase mdb;
switch (kind) {
// Note that C/C++ headers are undistinguishable
case ProjectFile::CHeader:
case ProjectFile::CXXHeader:
case ProjectFile::ObjCHeader:
case ProjectFile::ObjCXXHeader:
return MimeDatabase::findByType(QLatin1String(Constants::C_SOURCE_MIMETYPE)).suffixes()
+ MimeDatabase::findByType(QLatin1String(Constants::CPP_SOURCE_MIMETYPE)).suffixes()
+ MimeDatabase::findByType(QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE)).suffixes()
+ MimeDatabase::findByType(QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE)).suffixes();
return mdb.mimeTypeForName(QLatin1String(Constants::C_SOURCE_MIMETYPE)).suffixes()
+ mdb.mimeTypeForName(QLatin1String(Constants::CPP_SOURCE_MIMETYPE)).suffixes()
+ mdb.mimeTypeForName(QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE)).suffixes()
+ mdb.mimeTypeForName(QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE)).suffixes();
case ProjectFile::CSource:
case ProjectFile::ObjCSource:
return MimeDatabase::findByType(QLatin1String(Constants::C_HEADER_MIMETYPE)).suffixes();
return mdb.mimeTypeForName(QLatin1String(Constants::C_HEADER_MIMETYPE)).suffixes();
case ProjectFile::CXXSource:
case ProjectFile::ObjCXXSource:
case ProjectFile::CudaSource:
case ProjectFile::OpenCLSource:
return MimeDatabase::findByType(QLatin1String(Constants::CPP_HEADER_MIMETYPE)).suffixes();
return mdb.mimeTypeForName(QLatin1String(Constants::CPP_HEADER_MIMETYPE)).suffixes();
default:
return QStringList();
}
......
......@@ -52,7 +52,6 @@
#include <coreplugin/documentmanager.h>
#include <coreplugin/messagebox.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
......@@ -60,8 +59,9 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/locator/commandlocator.h>
#include <coreplugin/vcsmanager.h>
#include <utils/stringutils.h>
#include <utils/fileutils.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/stringutils.h>
#include <QDebug>
#include <QDate>
......@@ -230,7 +230,8 @@ static const VcsBaseSubmitEditorParameters submitParameters = {
bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments);
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
using namespace Constants;
using namespace Core::Constants;
......@@ -240,8 +241,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_cvsPluginInstance = this;
if (!MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.cvs/CVS.mimetypes.xml"), errorMessage))
return false;
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.cvs/CVS.mimetypes.xml"));
m_settings.readSettings(ICore::settings());
m_client = new CvsClient(&m_settings);
......
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="text/plain">
<comment>Plain text document</comment>
<sub-class-of type="application/octet-stream"/>
<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" weight="50"/><!-- reduce weight to allow application/vnd.rim.qnx.bar_descriptor to override by content -->
<glob pattern="*.xsl"/>
<glob pattern="*.xslt"/>
<glob pattern="*.xbl"/>
<alias type="text/xml"/>
</mime-type>
<mime-type type="text/x-asm">
<sub-class-of type="text/plain"/>
<comment>Assembler</comment>
......
......@@ -38,5 +38,6 @@
<file>images/qml/apply-on-save.png</file>
<file>images/debugger_restart.png</file>
<file>images/debugger_restart_small.png</file>
<file>Debugger.mimetypes.xml</file>
</qresource>
</RCC>
......@@ -106,6 +106,7 @@
#include <utils/basetreeview.h>
#include <utils/hostosinfo.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/proxyaction.h>
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
......@@ -1269,6 +1270,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
QString *errorMessage)
{
Q_UNUSED(errorMessage);
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/debugger/Debugger.mimetypes.xml"));
m_arguments = arguments;
if (!m_arguments.isEmpty())
connect(KitManager::instance(), &KitManager::kitsLoaded,
......
......@@ -41,11 +41,11 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditor.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <QTextBlock>
......@@ -237,8 +237,9 @@ void DisassemblerAgentPrivate::configureMimeType()
document->setMimeType(mimeType);
MimeType mtype = MimeDatabase::findByType(mimeType);
if (mtype) {
Utils::MimeDatabase mdb;
Utils::MimeType mtype = mdb.mimeTypeForName(mimeType);
if (mtype.isValid()) {
foreach (IEditor *editor, DocumentModel::editorsForDocument(document))
if (TextEditorWidget *widget = qobject_cast<TextEditorWidget *>(editor->widget()))
widget->configureGenericHighlighter();
......
......@@ -35,9 +35,9 @@
#include <utils/wizard.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <cpptools/cpptoolsconstants.h>
#include <utils/mimetypes/mimedatabase.h>
#
#include <QDebug>
#include <QMessageBox>
......@@ -84,8 +84,13 @@ bool FormClassWizardPage::lowercaseHeaderFiles()
// Set up new class widget from settings
void FormClassWizardPage::initFileGenerationSettings()
{
m_ui->newClassWidget->setHeaderExtension(Core::MimeDatabase::preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE)));
m_ui->newClassWidget->setSourceExtension(Core::MimeDatabase::preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE)));
Utils::MimeDatabase mdb;
m_ui->newClassWidget->setHeaderExtension(
mdb.mimeTypeForName(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE))
.preferredSuffix());
m_ui->newClassWidget->setSourceExtension(
mdb.mimeTypeForName(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE))
.preferredSuffix());
m_ui->newClassWidget->setLowerCaseFiles(lowercaseHeaderFiles());
}
......
<RCC>
<qresource prefix="/formeditor" >
<qresource prefix="/formeditor">
<file>images/qt_ui.png</file>
<file>Designer.mimetypes.xml</file>
</qresource>
</RCC>
......@@ -45,14 +45,15 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/designmode.h>
#include <cpptools/cpptoolsconstants.h>
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
#include <utils/mimetypes/mimedatabase.h>
#
#include <QApplication>
#include <QDebug>
#include <QFileInfo>
#include <QLibraryInfo>
#include <QTranslator>
#include <QtPlugin>
......@@ -80,9 +81,6 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
{
Q_UNUSED(arguments)
if (!MimeDatabase::addMimeTypes(QLatin1String(":/formeditor/Designer.mimetypes.xml"), error))
return false;
initializeTemplates();
ProjectExplorer::JsonWizardFactory::registerPageFactory(new Internal::FormPageFactory);
......@@ -162,17 +160,19 @@ static QString otherFile()
const QString current = currentFile();
if (current.isEmpty())
return QString();
const MimeType currentMimeType = MimeDatabase::findByFile(current);
if (!currentMimeType)
Utils::MimeDatabase mdb;
const Utils::MimeType currentMimeType = mdb.mimeTypeForFile(current);
if (!currentMimeType.isValid())
return QString();
// Determine potential suffixes of candidate files
// 'ui' -> 'cpp', 'cpp/h' -> 'ui'.
QStringList candidateSuffixes;
if (currentMimeType.type() == QLatin1String(FORM_MIMETYPE)) {
candidateSuffixes += MimeDatabase::findByType(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE)).suffixes();
} else if (currentMimeType.type() == QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE)
|| currentMimeType.type() == QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE)) {
candidateSuffixes += MimeDatabase::findByType(QLatin1String(FORM_MIMETYPE)).suffixes();
if (currentMimeType.matchesName(QLatin1String(FORM_MIMETYPE))) {
candidateSuffixes += mdb.mimeTypeForName(
QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE)).suffixes();
} else if (currentMimeType.matchesName(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE))
|| currentMimeType.matchesName(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE))) {
candidateSuffixes += mdb.mimeTypeForName(QLatin1String(FORM_MIMETYPE)).suffixes();
} else {
return QString();
}
......
......@@ -49,7 +49,6 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/outputpane.h>
#include <utils/qtcassert.h>
......
......@@ -45,6 +45,7 @@
#include <texteditor/texteditor.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <QDesignerFormWindowInterface>
......@@ -641,6 +642,7 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
void QtCreatorIntegration::slotSyncSettingsToDesigner()
{
// Set promotion-relevant parameters on integration.
setHeaderSuffix(Core::MimeDatabase::preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE)));
Utils::MimeDatabase mdb;
setHeaderSuffix(mdb.mimeTypeForName(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE)).preferredSuffix());
setHeaderLowercase(FormClassWizardPage::lowercaseHeaderFiles());
}
......@@ -56,7 +56,6 @@
#include <coreplugin/icore.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/patchtool.h>
#include <extensionsystem/pluginmanager.h>
......
......@@ -55,7 +55,6 @@
#include <coreplugin/icore.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/patchtool.h>
#include <extensionsystem/pluginmanager.h>
......
......@@ -33,7 +33,6 @@
#include "genericprojectwizard.h"
#include "genericprojectconstants.h"
#include <coreplugin/mimedatabase.h>
#include <coreplugin/icore.h>
#include <projectexplorer/selectablefilesmodel.h>
......
......@@ -35,12 +35,12 @@
#include "genericprojectconstants.h"
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <projectexplorer/buildinfo.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/toolchain.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
......@@ -103,8 +103,10 @@ QList<BuildInfo *> GenericBuildConfigurationFactory::availableBuilds(const Targe
int GenericBuildConfigurationFactory::priority(const Kit *k, const QString &projectPath) const
{
return (k && Core::MimeDatabase::findByFile(QFileInfo(projectPath))
.matchesType(QLatin1String(Constants::GENERICMIMETYPE))) ? 0 : -1;
Utils::MimeDatabase mdb;
if (k && mdb.mimeTypeForFile(projectPath).matchesName(QLatin1String(Constants::GENERICMIMETYPE)))
return 0;
return -1;
}
QList<BuildInfo *> GenericBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const
......
......@@ -37,7 +37,6 @@
#include <coreplugin/documentmanager.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cppmodelmanager.h>
#include <extensionsystem/pluginmanager.h>
......
......@@ -39,7 +39,6 @@
#include "genericproject.h"
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
......@@ -47,6 +46,8 @@
#include <projectexplorer/projecttree.h>
#include <projectexplorer/selectablefilesmodel.h>
#include <utils/mimetypes/mimedatabase.h>
#include <QtPlugin>
#include <QDebug>
......@@ -62,10 +63,8 @@ GenericProjectPlugin::GenericProjectPlugin()
bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage)
{
const QLatin1String mimetypesXml(":genericproject/GenericProjectManager.mimetypes.xml");
if (!MimeDatabase::addMimeTypes(mimetypesXml, errorMessage))
return false;
Q_UNUSED(errorMessage)
Utils::MimeDatabase::addMimeTypes(QLatin1String(":genericproject/GenericProjectManager.mimetypes.xml"));
addAutoReleasedObject(new Manager);
addAutoReleasedObject(new ProjectFilesFactory);
......
......@@ -32,11 +32,11 @@
#include "filesselectionwizardpage.h"
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/customwizard/customwizard.h>
#include <utils/filewizardpage.h>
#include <utils/mimetypes/mimedatabase.h>
#include <QApplication>
#include <QDebug>
......@@ -156,11 +156,10 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
const QString configFileName = QFileInfo(dir, projectName + QLatin1String(".config")).absoluteFilePath();
const QStringList paths = wizard->selectedPaths();
Core::MimeType headerTy = Core::MimeDatabase::findByType(QLatin1String("text/x-chdr"));
Utils::MimeDatabase mdb;
Utils::MimeType headerTy = mdb.mimeTypeForName(QLatin1String("text/x-chdr"));
QStringList nameFilters;
foreach (const Core::MimeGlobPattern &gp, headerTy.globPatterns())
nameFilters.append(gp.pattern());
QStringList nameFilters = headerTy.globPatterns();
QStringList includePaths;
foreach (const QString &path, paths) {
......
......@@ -59,11 +59,11 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/locator/commandlocator.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/messagebox.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <utils/parameteraction.h>
......@@ -269,6 +269,7 @@ QAction *GitPlugin::createRepositoryAction(ActionContainer *ac,
bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
Context context(Constants::GIT_CONTEXT);
......@@ -655,8 +656,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(VcsManager::instance(), SIGNAL(repositoryChanged(QString)),
this, SLOT(updateBranches(QString)), Qt::QueuedConnection);
if (!MimeDatabase::addMimeTypes(QLatin1String(RC_GIT_MIME_XML), errorMessage))
return false;
Utils::MimeDatabase::addMimeTypes(QLatin1String(RC_GIT_MIME_XML));
/* "Gerrit" */
m_gerritPlugin = new Gerrit::Internal::GerritPlugin(this);
......
......@@ -46,12 +46,12 @@
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/icore.h>
#include <coreplugin/id.h>
#include <coreplugin/mimedatabase.h>
#include <extensionsystem/pluginmanager.h>
#include <texteditor/texteditorconstants.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <QAction>
......@@ -122,8 +122,7 @@ GlslEditorPlugin::~GlslEditorPlugin()
bool GlslEditorPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
{
if (!MimeDatabase::addMimeTypes(QLatin1String(":/glsleditor/GLSLEditor.mimetypes.xml"), errorMessage))
return false;
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/glsleditor/GLSLEditor.mimetypes.xml"));
addAutoReleasedObject(new GlslEditorFactory);
addAutoReleasedObject(new GlslCompletionAssistProvider);
......
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