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
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/x-designer">
<mime-type type="application/vnd.google.android.android_manifest">
<comment>Android manifest file</comment>
<sub-class-of type="application/xml"/>
<comment>Qt Designer file</comment>
<glob pattern="*.ui"/>
<glob pattern="AndroidManifest.xml"/>
</mime-type>
</mime-info>
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="text/x-java">
<sub-class-of type="text/x-csrc"/>
<comment>Java Source file</comment>
<glob pattern="*.java"/>
</mime-type>
</mime-info>
......@@ -2,6 +2,6 @@
<qresource prefix="/android">
<file>images/QtAndroid.png</file>
<file>images/download.png</file>
<file>Java.mimetypes.xml</file>
<file>Android.mimetypes.xml</file>
</qresource>
</RCC>
......@@ -50,10 +50,10 @@
# include "androidqbspropertyprovider.h"
#endif
#include <coreplugin/mimedatabase.h>
#include <coreplugin/icore.h>
#include <projectexplorer/kitmanager.h>
#include <qtsupport/qtversionmanager.h>
#include <utils/mimetypes/mimedatabase.h>
#include <QtPlugin>
......@@ -82,22 +82,9 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa
addAutoReleasedObject(new Internal::JavaEditorFactory);
ProjectExplorer::KitManager::registerKitInformation(new Internal::AndroidGdbServerKitInformation);
// AndroidManifest.xml editor
Core::MimeGlobPattern androidManifestGlobPattern(QLatin1String("AndroidManifest.xml"), Core::MimeGlobPattern::MaxWeight);
Core::MimeType androidManifestMimeType;
androidManifestMimeType.setType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
androidManifestMimeType.setComment(tr("Android Manifest file"));
androidManifestMimeType.setGlobPatterns(QList<Core::MimeGlobPattern>() << androidManifestGlobPattern);
androidManifestMimeType.setSubClassesOf(QStringList() << QLatin1String("application/xml"));
if (!Core::MimeDatabase::addMimeType(androidManifestMimeType)) {
*errorMessage = tr("Could not add mime-type for AndroidManifest.xml editor.");
return false;
}
addAutoReleasedObject(new Internal::AndroidManifestEditorFactory);
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/android/Android.mimetypes.xml"));
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":android/Java.mimetypes.xml"), errorMessage))
return false;
addAutoReleasedObject(new Internal::AndroidManifestEditorFactory);
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()),
this, SLOT(kitsRestored()));
......
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="text/x-makefile">
<sub-class-of type="text/plain"/>
<comment>Automake based Makefile</comment>
<glob weight="10" pattern="Makefile.am"/>
</mime-type>
</mime-info>
......@@ -40,7 +40,6 @@
#include "configurestep.h"
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <projectexplorer/buildinfo.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/kitinformation.h>
......@@ -48,6 +47,7 @@
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <qtsupport/customexecutablerunconfiguration.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
......@@ -104,8 +104,10 @@ QList<BuildInfo *> AutotoolsBuildConfigurationFactory::availableBuilds(const Tar
int AutotoolsBuildConfigurationFactory::priority(const Kit *k, const QString &projectPath) const
{
return (k && Core::MimeDatabase::findByFile(QFileInfo(projectPath))
.matchesType(QLatin1String(Constants::MAKEFILE_MIMETYPE))) ? 0 : -1;
Utils::MimeDatabase mdb;
if (k && mdb.mimeTypeForFile(projectPath).matchesName(QLatin1String(Constants::MAKEFILE_MIMETYPE)))
return 0;
return -1;
}
QList<BuildInfo *> AutotoolsBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const
......
......@@ -29,4 +29,3 @@ SOURCES = autotoolsprojectplugin.cpp\
configurestep.cpp\
makefileparserthread.cpp\
makefileparser.cpp
RESOURCES += autotoolsproject.qrc
......@@ -39,8 +39,6 @@
#include "configurestep.h"
#include "autotoolsprojectconstants.h"
#include <coreplugin/mimedatabase.h>
#include <QStringList>
#include <QtPlugin>
......@@ -57,10 +55,8 @@ void AutotoolsProjectPlugin::extensionsInitialized()
bool AutotoolsProjectPlugin::initialize(const QStringList &arguments,
QString *errorString)
{
Q_UNUSED(arguments);
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":autotoolsproject/AutotoolsProjectManager.mimetypes.xml"), errorString))
return false;
Q_UNUSED(arguments)
Q_UNUSED(errorString)
addAutoReleasedObject(new AutotoolsBuildConfigurationFactory);
addAutoReleasedObject(new MakeStepFactory);
......
......@@ -56,7 +56,6 @@
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/find/ifindsupport.h>
#include <coreplugin/idocument.h>
#include <coreplugin/mimedatabase.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/reloadpromptutils.h>
#include <utils/qtcassert.h>
......
......@@ -34,7 +34,6 @@
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <coreplugin/mimedatabase.h>
#include <cplusplus/BackwardsScanner.h>
#include <cplusplus/ExpressionUnderCursor.h>
......@@ -58,6 +57,7 @@
#include <texteditor/completionsettings.h>
#include <utils/algorithm.h>
#include <utils/mimetypes/mimedatabase.h>
#include <QCoreApplication>
#include <QDirIterator>
......@@ -1095,7 +1095,8 @@ bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
if (!headerPaths.contains(currentFilePath))
headerPaths.append(currentFilePath);
const Core::MimeType mimeType = Core::MimeDatabase::findByType(QLatin1String("text/x-c++hdr"));
Utils::MimeDatabase mdb;
const Utils::MimeType mimeType = mdb.mimeTypeForName(QLatin1String("text/x-c++hdr"));
const QStringList suffixes = mimeType.suffixes();
foreach (const ProjectPart::HeaderPath &headerPath, headerPaths) {
......
......@@ -52,13 +52,13 @@
#include <coreplugin/icore.h>
#include <coreplugin/infobar.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/locator/commandlocator.h>
#include <projectexplorer/session.h>
#include <projectexplorer/project.h>
#include <projectexplorer/iprojectmanager.h>
#include <utils/algorithm.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/synchronousprocess.h>
#include <utils/parameteraction.h>
#include <utils/fileutils.h>
......@@ -441,6 +441,7 @@ static const VcsBaseSubmitEditorParameters submitParameters = {
bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *errorMessage)
{
Q_UNUSED(errorMessage)
using namespace Constants;
using namespace Core::Constants;
......@@ -453,8 +454,7 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
connect(ProgressManager::instance(), SIGNAL(allTasksFinished(Core::Id)),
this, SLOT(tasksFinished(Core::Id)));
if (!MimeDatabase::addMimeTypes(QLatin1String(":/clearcase/ClearCase.mimetypes.xml"), errorMessage))
return false;
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/clearcase/ClearCase.mimetypes.xml"));
m_settings.fromSettings(ICore::settings());
......
......@@ -37,7 +37,6 @@
#include <coreplugin/documentmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/kit.h>
......@@ -45,6 +44,7 @@
#include <projectexplorer/projectmacroexpander.h>
#include <projectexplorer/target.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <QInputDialog>
......@@ -161,8 +161,10 @@ QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableBui
int CMakeBuildConfigurationFactory::priority(const ProjectExplorer::Kit *k, const QString &projectPath) const
{
return (k && Core::MimeDatabase::findByFile(QFileInfo(projectPath))
.matchesType(QLatin1String(Constants::CMAKEPROJECTMIMETYPE))) ? 0 : -1;
Utils::MimeDatabase mdb;
if (k && mdb.mimeTypeForFile(projectPath).matchesName(QLatin1String(Constants::CMAKEPROJECTMIMETYPE)))
return 0;
return -1;
}
QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableSetups(const ProjectExplorer::Kit *k,
......
......@@ -41,7 +41,7 @@
#include "cmakesettingspage.h"
#include <coreplugin/featureprovider.h>
#include <coreplugin/mimedatabase.h>
#include <utils/mimetypes/mimedatabase.h>
#include <QtPlugin>
#include <QDebug>
......@@ -59,8 +59,8 @@ CMakeProjectPlugin::~CMakeProjectPlugin()
bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
{
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":cmakeproject/CMakeProjectManager.mimetypes.xml"), errorMessage))
return false;
Q_UNUSED(errorMessage)
Utils::MimeDatabase::addMimeTypes(QLatin1String(":cmakeproject/CMakeProjectManager.mimetypes.xml"));
CMakeSettingsPage *cmp = new CMakeSettingsPage();
addAutoReleasedObject(cmp);
......
......@@ -34,14 +34,14 @@
#include "icontext.h"
#include "icore.h"
#include "ifilewizardextension.h"
#include "mimedatabase.h"
#include "editormanager/editormanager.h"
#include "dialogs/promptoverwritedialog.h"
#include <extensionsystem/pluginmanager.h>
#include <utils/filewizardpage.h>
#include <utils/wizard.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <utils/wizard.h>
#include <QDir>
#include <QFileInfo>
......@@ -476,7 +476,11 @@ QString BaseFileWizardFactory::buildFileName(const QString &path,
QString BaseFileWizardFactory::preferredSuffix(const QString &mimeType)
{
const QString rc = MimeDatabase::preferredSuffixByType(mimeType);
QString rc;
Utils::MimeDatabase mdb;
Utils::MimeType mt = mdb.mimeTypeForName(mimeType);
if (mt.isValid())
rc = mt.preferredSuffix();
if (rc.isEmpty())
qWarning("%s: WARNING: Unable to find a preferred suffix for %s.",
Q_FUNC_INFO, mimeType.toUtf8().constData());
......
......@@ -63,7 +63,6 @@
<file>images/category_core.png</file>
<file>images/category_texteditor.png</file>
<file>images/category_design.png</file>
<file>editormanager/BinFiles.mimetypes.xml</file>
<file>images/progressbar.png</file>
<file>images/progressbar@2x.png</file>
<file>images/help.png</file>
......
......@@ -30,9 +30,8 @@
#include "corejsextensions.h"
#include "mimedatabase.h"
#include <utils/fileutils.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <QDir>
......@@ -90,7 +89,11 @@ QString UtilsJsExtension::absoluteFilePath(const QString &in) const
QString UtilsJsExtension::preferredSuffix(const QString &mimetype) const
{
return MimeDatabase::preferredSuffixByType(mimetype);
Utils::MimeDatabase mdb;
Utils::MimeType mt = mdb.mimeTypeForName(mimetype);
if (mt.isValid())
return mt.preferredSuffix();
return QString();
}
QString UtilsJsExtension::fileName(const QString &path, const QString &extension) const
......
......@@ -33,7 +33,6 @@
#include "editmode.h"
#include "helpmanager.h"
#include "mainwindow.h"
#include "mimedatabase.h"
#include "modemanager.h"
#include "infobar.h"
#include "iwizardfactory.h"
......@@ -212,7 +211,8 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
void CorePlugin::extensionsInitialized()
{
MimeDatabase::syncUserModifiedMimeTypes();
// TODO
// MimeDatabase::syncUserModifiedMimeTypes();
if (m_designMode->designModeIsRequired())
addObject(m_designMode);
m_findPlugin->extensionsInitialized();
......
......@@ -72,7 +72,6 @@ SOURCES += corejsextensions.cpp \
rightpane.cpp \
sidebar.cpp \
fileiconprovider.cpp \
mimedatabase.cpp \
icore.cpp \
infobar.cpp \
editormanager/ieditor.cpp \
......@@ -196,7 +195,6 @@ HEADERS += corejsextensions.h \
rightpane.h \
sidebar.h \
fileiconprovider.h \
mimedatabase.h \
settingsdatabase.h \
editormanager/systemeditor.h \
designmode.h \
......
......@@ -32,7 +32,6 @@
#include "icore.h"
#include "idocument.h"
#include "mimedatabase.h"
#include "coreconstants.h"
#include <coreplugin/dialogs/readonlyfilesdialog.h>
......@@ -46,6 +45,7 @@
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
#include <utils/pathchooser.h>
#include <utils/reloadpromptutils.h>
......@@ -740,7 +740,9 @@ QString DocumentManager::getSaveAsFileName(const IDocument *document, const QStr
QString filterString;
if (filter.isEmpty()) {
if (const MimeType &mt = MimeDatabase::findByFile(fi))
Utils::MimeDatabase mdb;
const Utils::MimeType &mt = mdb.mimeTypeForFile(fi);
if (mt.isValid())
filterString = mt.filterString();
selectedFilter = &filterString;
} else {
......@@ -1391,7 +1393,9 @@ void DocumentManager::populateOpenWithMenu(QMenu *menu, const QString &fileName)
bool anyMatches = false;
if (const MimeType mt = MimeDatabase::findByFile(QFileInfo(fileName))) {
Utils::MimeDatabase mdb;
const Utils::MimeType mt = mdb.mimeTypeForFile(fileName);
if (mt.isValid()) {
const EditorFactoryList factories = EditorManager::editorFactories(mt, false);
const ExternalEditorList externalEditors = EditorManager::externalEditors(mt, false);
anyMatches = !factories.empty() || !externalEditors.empty();
......
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/octet-stream">
<comment>unknown</comment>
<glob pattern="*.a"/>
<glob pattern="*.dll"/>
<glob pattern="*.exe"/>
<glob pattern="*.lib"/>
<glob pattern="*.o"/>
<glob pattern="*.obj"/>
<glob pattern="*.out"/>
<glob pattern="*.so"/>
<!-- Magic for ELF binaries -->
<magic priority="99">
<match type="byte" offset="0" value="\0x7f\0x45\0x4c\0x46"/>
</magic>
</mime-type>
</mime-info>
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