forked from qt-creator/qt-creator
Use new mime database
Change-Id: I4305872b6b11ef3e8a364280ffa5209a5a793600 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
8
src/plugins/android/Android.mimetypes.xml
Normal file
8
src/plugins/android/Android.mimetypes.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="application/vnd.google.android.android_manifest">
|
||||
<comment>Android manifest file</comment>
|
||||
<sub-class-of type="application/xml"/>
|
||||
<glob pattern="AndroidManifest.xml"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
@@ -1,8 +0,0 @@
|
||||
<?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,23 +82,10 @@ 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"));
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/android/Android.mimetypes.xml"));
|
||||
|
||||
if (!Core::MimeDatabase::addMimeType(androidManifestMimeType)) {
|
||||
*errorMessage = tr("Could not add mime-type for AndroidManifest.xml editor.");
|
||||
return false;
|
||||
}
|
||||
addAutoReleasedObject(new Internal::AndroidManifestEditorFactory);
|
||||
|
||||
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":android/Java.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
|
||||
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()),
|
||||
this, SLOT(kitsRestored()));
|
||||
|
||||
|
@@ -1,8 +0,0 @@
|
||||
<?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();
|
||||
|
@@ -1,18 +0,0 @@
|
||||
<?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>
|
@@ -54,7 +54,6 @@
|
||||
#include <coreplugin/imode.h>
|
||||
#include <coreplugin/infobar.h>
|
||||
#include <coreplugin/iversioncontrol.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <coreplugin/outputpane.h>
|
||||
#include <coreplugin/outputpanemanager.h>
|
||||
@@ -68,6 +67,7 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QClipboard>
|
||||
@@ -774,10 +774,11 @@ void EditorManagerPrivate::showPopupOrSelectDocument()
|
||||
Id EditorManagerPrivate::getOpenWithEditorId(const QString &fileName, bool *isExternalEditor)
|
||||
{
|
||||
// Collect editors that can open the file
|
||||
MimeType mt = MimeDatabase::findByFile(fileName);
|
||||
Utils::MimeDatabase mdb;
|
||||
Utils::MimeType mt = mdb.mimeTypeForFile(fileName);
|
||||
//Unable to determine mime type of fileName. Falling back to text/plain",
|
||||
if (!mt)
|
||||
mt = MimeDatabase::findByType(QLatin1String("text/plain"));
|
||||
if (!mt.isValid())
|
||||
mt = mdb.mimeTypeForName(QLatin1String("text/plain"));
|
||||
QList<Id> allEditorIds;
|
||||
QStringList allEditorDisplayNames;
|
||||
QList<Id> externalEditorIds;
|
||||
@@ -889,16 +890,17 @@ IEditor *EditorManagerPrivate::createEditor(Id editorId, const QString &fileName
|
||||
if (!editorId.isValid()) {
|
||||
const QFileInfo fileInfo(fileName);
|
||||
// Find by mime type
|
||||
MimeType mimeType = MimeDatabase::findByFile(fileInfo);
|
||||
if (!mimeType) {
|
||||
Utils::MimeDatabase mdb;
|
||||
Utils::MimeType mimeType = mdb.mimeTypeForFile(fileInfo);
|
||||
if (!mimeType.isValid()) {
|
||||
qWarning("%s unable to determine mime type of %s/%s. Falling back to text/plain",
|
||||
Q_FUNC_INFO, fileName.toUtf8().constData(), editorId.name().constData());
|
||||
mimeType = MimeDatabase::findByType(QLatin1String("text/plain"));
|
||||
mimeType = mdb.mimeTypeForName(QLatin1String("text/plain"));
|
||||
}
|
||||
// open text files > 48 MB in binary editor
|
||||
if (fileInfo.size() > EditorManager::maxTextFileSize()
|
||||
&& mimeType.type().startsWith(QLatin1String("text"))) {
|
||||
mimeType = MimeDatabase::findByType(QLatin1String("application/octet-stream"));
|
||||
&& mimeType.name().startsWith(QLatin1String("text"))) {
|
||||
mimeType = mdb.mimeTypeForName(QLatin1String("application/octet-stream"));
|
||||
}
|
||||
factories = EditorManager::editorFactories(mimeType, true);
|
||||
} else {
|
||||
@@ -1692,11 +1694,12 @@ bool EditorManagerPrivate::saveDocumentAs(IDocument *document)
|
||||
if (!document)
|
||||
return false;
|
||||
|
||||
const QString filter = MimeDatabase::allFiltersString();
|
||||
Utils::MimeDatabase mdb;
|
||||
const QString filter = Utils::MimeDatabase::allFiltersString();
|
||||
QString selectedFilter =
|
||||
MimeDatabase::findByFile(document->filePath().toFileInfo()).filterString();
|
||||
mdb.mimeTypeForFile(document->filePath().toFileInfo()).filterString();
|
||||
if (selectedFilter.isEmpty())
|
||||
selectedFilter = MimeDatabase::findByType(document->mimeType()).filterString();
|
||||
selectedFilter = mdb.mimeTypeForName(document->mimeType()).filterString();
|
||||
const QString &absoluteFilePath =
|
||||
DocumentManager::getSaveAsFileName(document, filter, &selectedFilter);
|
||||
|
||||
@@ -2192,54 +2195,58 @@ IEditor *EditorManager::activateEditorForDocument(IDocument *document, OpenEdito
|
||||
* or IExternalEditor), find the one best matching the mimetype passed in.
|
||||
* Recurse over the parent classes of the mimetype to find them. */
|
||||
template <class EditorFactoryLike>
|
||||
static void mimeTypeFactoryRecursion(const MimeType &mimeType,
|
||||
static void mimeTypeFactoryRecursion(const Utils::MimeType &mimeType,
|
||||
const QList<EditorFactoryLike*> &allFactories,
|
||||
bool firstMatchOnly,
|
||||
QList<EditorFactoryLike*> *list)
|
||||
{
|
||||
typedef typename QList<EditorFactoryLike*>::const_iterator EditorFactoryLikeListConstIterator;
|
||||
// Loop factories to find type
|
||||
const QString type = mimeType.type();
|
||||
const EditorFactoryLikeListConstIterator fcend = allFactories.constEnd();
|
||||
for (EditorFactoryLikeListConstIterator fit = allFactories.constBegin(); fit != fcend; ++fit) {
|
||||
// Exclude duplicates when recursing over xml or C++ -> C -> text.
|
||||
EditorFactoryLike *factory = *fit;
|
||||
if (!list->contains(factory) && factory->mimeTypes().contains(type)) {
|
||||
if (!list->contains(factory)) {
|
||||
foreach (const QString &mt, factory->mimeTypes()) {
|
||||
if (mimeType.matchesName(mt)) {
|
||||
list->push_back(*fit);
|
||||
if (firstMatchOnly)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Any parent mime type classes? -> recurse
|
||||
QStringList parentTypes = mimeType.subClassesOf();
|
||||
if (parentTypes.empty())
|
||||
QStringList parentNames = mimeType.parentMimeTypes();
|
||||
if (parentNames.empty())
|
||||
return;
|
||||
const QStringList::const_iterator pcend = parentTypes .constEnd();
|
||||
for (QStringList::const_iterator pit = parentTypes .constBegin(); pit != pcend; ++pit) {
|
||||
if (const MimeType parent = MimeDatabase::findByType(*pit))
|
||||
Utils::MimeDatabase mdb;
|
||||
foreach (const QString &parentName, parentNames) {
|
||||
const Utils::MimeType parent = mdb.mimeTypeForName(parentName);
|
||||
if (parent.isValid())
|
||||
mimeTypeFactoryRecursion(parent, allFactories, firstMatchOnly, list);
|
||||
}
|
||||
}
|
||||
|
||||
EditorManager::EditorFactoryList
|
||||
EditorManager::editorFactories(const MimeType &mimeType, bool bestMatchOnly)
|
||||
EditorManager::editorFactories(const Utils::MimeType &mimeType, bool bestMatchOnly)
|
||||
{
|
||||
EditorFactoryList rc;
|
||||
const EditorFactoryList allFactories = ExtensionSystem::PluginManager::getObjects<IEditorFactory>();
|
||||
mimeTypeFactoryRecursion(mimeType, allFactories, bestMatchOnly, &rc);
|
||||
if (debugEditorManager)
|
||||
qDebug() << Q_FUNC_INFO << mimeType.type() << " returns " << rc;
|
||||
qDebug() << Q_FUNC_INFO << mimeType.name() << " returns " << rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
EditorManager::ExternalEditorList
|
||||
EditorManager::externalEditors(const MimeType &mimeType, bool bestMatchOnly)
|
||||
EditorManager::externalEditors(const Utils::MimeType &mimeType, bool bestMatchOnly)
|
||||
{
|
||||
ExternalEditorList rc;
|
||||
const ExternalEditorList allEditors = ExtensionSystem::PluginManager::getObjects<IExternalEditor>();
|
||||
mimeTypeFactoryRecursion(mimeType, allEditors, bestMatchOnly, &rc);
|
||||
if (debugEditorManager)
|
||||
qDebug() << Q_FUNC_INFO << mimeType.type() << " returns " << rc;
|
||||
qDebug() << Q_FUNC_INFO << mimeType.name() << " returns " << rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -2308,7 +2315,7 @@ bool EditorManager::openExternalEditor(const QString &fileName, Id editorId)
|
||||
QStringList EditorManager::getOpenFileNames()
|
||||
{
|
||||
QString selectedFilter;
|
||||
const QString &fileFilters = MimeDatabase::allFiltersString(&selectedFilter);
|
||||
const QString &fileFilters = Utils::MimeDatabase::allFiltersString(&selectedFilter);
|
||||
return DocumentManager::getOpenFileNames(fileFilters, QString(), &selectedFilter);
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/idocument.h> // enumerations
|
||||
#include <utils/mimetypes/mimetype.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
@@ -53,7 +54,6 @@ class IContext;
|
||||
class IEditor;
|
||||
class IEditorFactory;
|
||||
class IExternalEditor;
|
||||
class MimeType;
|
||||
class IDocument;
|
||||
class IMode;
|
||||
class IVersionControl;
|
||||
@@ -157,8 +157,8 @@ public:
|
||||
QObject *object = 0, const char *member = 0);
|
||||
static void hideEditorStatusBar(const QString &id);
|
||||
|
||||
static EditorFactoryList editorFactories(const MimeType &mimeType, bool bestMatchOnly = true);
|
||||
static ExternalEditorList externalEditors(const MimeType &mimeType, bool bestMatchOnly = true);
|
||||
static EditorFactoryList editorFactories(const Utils::MimeType &mimeType, bool bestMatchOnly = true);
|
||||
static ExternalEditorList externalEditors(const Utils::MimeType &mimeType, bool bestMatchOnly = true);
|
||||
|
||||
static bool isAutoSaveFile(const QString &fileName);
|
||||
|
||||
|
@@ -29,9 +29,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "fileiconprovider.h"
|
||||
#include "mimedatabase.h"
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QApplication>
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
m_cache.insert(suffix, fileIconPixmap);
|
||||
}
|
||||
|
||||
void registerIconOverlayForMimeType(const QIcon &icon, const MimeType &mimeType)
|
||||
void registerIconOverlayForMimeType(const QIcon &icon, const Utils::MimeType &mimeType)
|
||||
{
|
||||
foreach (const QString &suffix, mimeType.suffixes())
|
||||
registerIconOverlayForSuffix(icon, suffix);
|
||||
@@ -181,7 +181,9 @@ void registerIconOverlayForSuffix(const char *path, const char *suffix)
|
||||
*/
|
||||
void registerIconOverlayForMimeType(const QIcon &icon, const char *mimeType)
|
||||
{
|
||||
instance()->registerIconOverlayForMimeType(icon, MimeDatabase::findByType(QString::fromLatin1(mimeType)));
|
||||
Utils::MimeDatabase mdb;
|
||||
instance()->registerIconOverlayForMimeType(icon,
|
||||
mdb.mimeTypeForName(QString::fromLatin1(mimeType)));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -189,7 +191,9 @@ void registerIconOverlayForMimeType(const QIcon &icon, const char *mimeType)
|
||||
*/
|
||||
void registerIconOverlayForMimeType(const char *path, const char *mimeType)
|
||||
{
|
||||
instance()->registerIconOverlayForMimeType(QIcon(QLatin1String(path)), MimeDatabase::findByType(QString::fromLatin1(mimeType)));
|
||||
Utils::MimeDatabase mdb;
|
||||
instance()->registerIconOverlayForMimeType(QIcon(QLatin1String(path)),
|
||||
mdb.mimeTypeForName(QString::fromLatin1(mimeType)));
|
||||
}
|
||||
|
||||
} // namespace FileIconProvider
|
||||
|
@@ -38,8 +38,6 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
class MimeType;
|
||||
|
||||
namespace FileIconProvider {
|
||||
|
||||
// Access to the single instance
|
||||
|
@@ -100,12 +100,6 @@
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn MimeDatabase *ICore::mimeDatabase()
|
||||
|
||||
Uses the MIME database to manage MIME types.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QSettings *ICore::settings(QSettings::Scope scope = QSettings::UserScope)
|
||||
|
||||
|
@@ -40,7 +40,6 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
class MimeType;
|
||||
class InfoBar;
|
||||
|
||||
namespace Internal {
|
||||
|
@@ -42,7 +42,6 @@
|
||||
#include "idocumentfactory.h"
|
||||
#include "messagemanager.h"
|
||||
#include "modemanager.h"
|
||||
#include "mimedatabase.h"
|
||||
#include "outputpanemanager.h"
|
||||
#include "plugindialog.h"
|
||||
#include "vcsmanager.h"
|
||||
@@ -77,6 +76,7 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/historycompleter.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/theme/theme.h>
|
||||
@@ -124,7 +124,6 @@ MainWindow::MainWindow() :
|
||||
m_vcsManager(new VcsManager),
|
||||
m_statusBarManager(0),
|
||||
m_modeManager(0),
|
||||
m_mimeDatabase(new MimeDatabase),
|
||||
m_helpManager(new HelpManager),
|
||||
m_modeStack(new FancyTabWidget(this)),
|
||||
m_navigationWidget(0),
|
||||
@@ -298,8 +297,6 @@ MainWindow::~MainWindow()
|
||||
|
||||
delete m_modeManager;
|
||||
m_modeManager = 0;
|
||||
delete m_mimeDatabase;
|
||||
m_mimeDatabase = 0;
|
||||
|
||||
delete m_helpManager;
|
||||
m_helpManager = 0;
|
||||
@@ -311,9 +308,6 @@ bool MainWindow::init(QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
if (!MimeDatabase::addMimeTypes(QLatin1String(":/core/editormanager/BinFiles.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
|
||||
PluginManager::addObject(m_coreImpl);
|
||||
m_statusBarManager->init();
|
||||
m_modeManager->init();
|
||||
@@ -751,10 +745,12 @@ void MainWindow::openFile()
|
||||
static IDocumentFactory *findDocumentFactory(const QList<IDocumentFactory*> &fileFactories,
|
||||
const QFileInfo &fi)
|
||||
{
|
||||
if (const MimeType mt = MimeDatabase::findByFile(fi)) {
|
||||
const QString type = mt.type();
|
||||
Utils::MimeDatabase mdb;
|
||||
const Utils::MimeType mt = mdb.mimeTypeForFile(fi);
|
||||
if (mt.isValid()) {
|
||||
const QString typeName = mt.name();
|
||||
foreach (IDocumentFactory *factory, fileFactories) {
|
||||
if (factory->mimeTypes().contains(type))
|
||||
if (factory->mimeTypes().contains(typeName))
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
|
@@ -58,7 +58,6 @@ class IDocument;
|
||||
class IWizardFactory;
|
||||
class JsExpander;
|
||||
class MessageManager;
|
||||
class MimeDatabase;
|
||||
class ModeManager;
|
||||
class ProgressManager;
|
||||
class NavigationWidget;
|
||||
@@ -172,7 +171,6 @@ private:
|
||||
VcsManager *m_vcsManager;
|
||||
StatusBarManager *m_statusBarManager;
|
||||
ModeManager *m_modeManager;
|
||||
MimeDatabase *m_mimeDatabase;
|
||||
HelpManager *m_helpManager;
|
||||
FancyTabWidget *m_modeStack;
|
||||
NavigationWidget *m_navigationWidget;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,318 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef MIMEDATABASE_H
|
||||
#define MIMEDATABASE_H
|
||||
|
||||
#include <coreplugin/core_global.h>
|
||||
#include <QStringList>
|
||||
#include <QSharedDataPointer>
|
||||
#include <QSharedPointer>
|
||||
#include <QByteArray>
|
||||
#include <QMutex>
|
||||
#include <QFileInfo>
|
||||
#include <QPair>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QIODevice;
|
||||
class QDebug;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class MimeTypeData;
|
||||
class MimeDatabasePrivate;
|
||||
|
||||
namespace Internal {
|
||||
class BaseMimeTypeParser;
|
||||
class FileMatchContext;
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class CORE_EXPORT IMagicMatcher
|
||||
{
|
||||
Q_DISABLE_COPY(IMagicMatcher)
|
||||
|
||||
protected:
|
||||
IMagicMatcher() {}
|
||||
|
||||
public:
|
||||
typedef QSharedPointer<IMagicMatcher> IMagicMatcherSharedPointer;
|
||||
typedef QList<IMagicMatcherSharedPointer> IMagicMatcherList;
|
||||
|
||||
// Check for a match on contents of a file
|
||||
virtual bool matches(const QByteArray &data) const = 0;
|
||||
// Return a priority value from 1..100
|
||||
virtual int priority() const = 0;
|
||||
virtual ~IMagicMatcher() {}
|
||||
};
|
||||
|
||||
class CORE_EXPORT MagicRule
|
||||
{
|
||||
Q_DISABLE_COPY(MagicRule)
|
||||
public:
|
||||
MagicRule(int startPos, int endPos);
|
||||
virtual ~MagicRule();
|
||||
|
||||
virtual QString matchType() const = 0;
|
||||
virtual QString matchValue() const = 0;
|
||||
virtual bool matches(const QByteArray &data) const = 0;
|
||||
|
||||
int startPos() const;
|
||||
int endPos() const;
|
||||
|
||||
static QString toOffset(const QPair<int, int> &startEnd);
|
||||
static QPair<int, int> fromOffset(const QString &offset);
|
||||
|
||||
private:
|
||||
static const QChar kColon;
|
||||
|
||||
const int m_startPos;
|
||||
const int m_endPos;
|
||||
};
|
||||
|
||||
class CORE_EXPORT MagicStringRule : public MagicRule
|
||||
{
|
||||
public:
|
||||
MagicStringRule(const QString &s, int startPos, int endPos);
|
||||
virtual ~MagicStringRule();
|
||||
|
||||
virtual QString matchType() const;
|
||||
virtual QString matchValue() const;
|
||||
virtual bool matches(const QByteArray &data) const;
|
||||
|
||||
static const QString kMatchType;
|
||||
|
||||
private:
|
||||
const QByteArray m_pattern;
|
||||
};
|
||||
|
||||
class CORE_EXPORT MagicByteRule : public MagicRule
|
||||
{
|
||||
public:
|
||||
MagicByteRule(const QString &s, int startPos, int endPos);
|
||||
virtual ~MagicByteRule();
|
||||
|
||||
virtual QString matchType() const;
|
||||
virtual QString matchValue() const;
|
||||
virtual bool matches(const QByteArray &data) const;
|
||||
|
||||
static bool validateByteSequence(const QString &sequence, QList<int> *bytes = 0);
|
||||
|
||||
static const QString kMatchType;
|
||||
|
||||
private:
|
||||
int m_bytesSize;
|
||||
QList<int> m_bytes;
|
||||
};
|
||||
|
||||
class CORE_EXPORT MagicRuleMatcher : public IMagicMatcher
|
||||
{
|
||||
Q_DISABLE_COPY(MagicRuleMatcher)
|
||||
public:
|
||||
typedef QSharedPointer<MagicRule> MagicRuleSharedPointer;
|
||||
typedef QList<MagicRuleSharedPointer> MagicRuleList;
|
||||
|
||||
MagicRuleMatcher();
|
||||
|
||||
void add(const MagicRuleSharedPointer &rule);
|
||||
void add(const MagicRuleList &ruleList);
|
||||
MagicRuleList magicRules() const;
|
||||
|
||||
virtual bool matches(const QByteArray &data) const;
|
||||
|
||||
virtual int priority() const;
|
||||
void setPriority(int p);
|
||||
|
||||
// Create a list of MagicRuleMatchers from a hash of rules indexed by priorities.
|
||||
static IMagicMatcher::IMagicMatcherList createMatchers(const QHash<int, MagicRuleList> &);
|
||||
|
||||
private:
|
||||
MagicRuleList m_list;
|
||||
int m_priority;
|
||||
};
|
||||
|
||||
class CORE_EXPORT MimeGlobPattern
|
||||
{
|
||||
public:
|
||||
static const unsigned MaxWeight = 100;
|
||||
static const unsigned MinWeight = 1;
|
||||
|
||||
explicit MimeGlobPattern(const QString &pattern, unsigned weight = MaxWeight);
|
||||
~MimeGlobPattern();
|
||||
|
||||
bool matches(const QString &fileName) const;
|
||||
unsigned weight() const { return m_weight; }
|
||||
QString pattern() const { return m_pattern; }
|
||||
|
||||
private:
|
||||
enum { Suffix, Exact, Glob } m_type;
|
||||
QString m_pattern;
|
||||
QRegExp m_regexp; // Will be used in \c Glob case only.
|
||||
unsigned m_weight;
|
||||
};
|
||||
|
||||
|
||||
class CORE_EXPORT MimeType
|
||||
{
|
||||
public:
|
||||
typedef IMagicMatcher::IMagicMatcherList IMagicMatcherList;
|
||||
typedef IMagicMatcher::IMagicMatcherSharedPointer IMagicMatcherSharedPointer;
|
||||
|
||||
MimeType();
|
||||
MimeType(const MimeType&);
|
||||
MimeType &operator=(const MimeType&);
|
||||
~MimeType();
|
||||
|
||||
void clear();
|
||||
bool isNull() const;
|
||||
operator bool() const;
|
||||
|
||||
bool isTopLevel() const;
|
||||
|
||||
QString type() const;
|
||||
void setType(const QString &type);
|
||||
|
||||
QStringList aliases() const;
|
||||
void setAliases(const QStringList &);
|
||||
|
||||
QString comment() const;
|
||||
void setComment(const QString &comment);
|
||||
|
||||
QString localeComment(const QString &locale = QString() /* en, de...*/) const;
|
||||
void setLocaleComment(const QString &locale, const QString &comment);
|
||||
|
||||
QList<MimeGlobPattern> globPatterns() const;
|
||||
void setGlobPatterns(const QList<MimeGlobPattern> &);
|
||||
|
||||
QStringList subClassesOf() const;
|
||||
void setSubClassesOf(const QStringList &);
|
||||
|
||||
// Extension over standard mime data
|
||||
QStringList suffixes() const;
|
||||
QString preferredSuffix() const;
|
||||
bool setPreferredSuffix(const QString&);
|
||||
|
||||
// Check for type or one of the aliases
|
||||
bool matchesType(const QString &type) const;
|
||||
|
||||
// Check glob patterns weights and magic priorities so the highest
|
||||
// value is returned. A 0 (zero) indicates no match.
|
||||
unsigned matchesFile(const QFileInfo &file) const;
|
||||
|
||||
// Return a filter string usable for a file dialog
|
||||
QString filterString() const;
|
||||
|
||||
void addMagicMatcher(const IMagicMatcherSharedPointer &matcher);
|
||||
|
||||
const IMagicMatcherList &magicMatchers() const;
|
||||
void setMagicMatchers(const IMagicMatcherList &matchers);
|
||||
|
||||
// Convenience for rule-base matchers.
|
||||
IMagicMatcherList magicRuleMatchers() const;
|
||||
void setMagicRuleMatchers(const IMagicMatcherList &matchers);
|
||||
|
||||
friend QDebug operator<<(QDebug d, const MimeType &mt);
|
||||
|
||||
static QString formatFilterString(const QString &description,
|
||||
const QList<MimeGlobPattern> &globs);
|
||||
|
||||
private:
|
||||
explicit MimeType(const MimeTypeData &d);
|
||||
unsigned matchesFileBySuffix(Internal::FileMatchContext &c) const;
|
||||
unsigned matchesFileByContent(Internal::FileMatchContext &c) const;
|
||||
unsigned matchesData(const QByteArray &data) const;
|
||||
|
||||
friend class Internal::BaseMimeTypeParser;
|
||||
friend class MimeDatabasePrivate;
|
||||
QSharedDataPointer<MimeTypeData> m_d;
|
||||
};
|
||||
|
||||
class CORE_EXPORT MimeDatabase
|
||||
{
|
||||
Q_DISABLE_COPY(MimeDatabase)
|
||||
public:
|
||||
typedef IMagicMatcher::IMagicMatcherList IMagicMatcherList;
|
||||
typedef IMagicMatcher::IMagicMatcherSharedPointer IMagicMatcherSharedPointer;
|
||||
|
||||
static bool addMimeTypes(const QString &fileName, QString *errorMessage);
|
||||
static bool addMimeTypes(QIODevice *device, QString *errorMessage);
|
||||
static bool addMimeType(const MimeType &mt);
|
||||
|
||||
// Returns a mime type or Null one if none found
|
||||
static MimeType findByType(const QString &type);
|
||||
|
||||
// Returns a mime type or Null one if none found
|
||||
static MimeType findByFile(const QFileInfo &f);
|
||||
|
||||
// Returns a mime type or Null one if none found
|
||||
static MimeType findByData(const QByteArray &data);
|
||||
|
||||
// Return all known suffixes
|
||||
static QStringList suffixes();
|
||||
static bool setPreferredSuffix(const QString &typeOrAlias, const QString &suffix);
|
||||
static QString preferredSuffixByType(const QString &type);
|
||||
static QString preferredSuffixByFile(const QFileInfo &f);
|
||||
|
||||
static QStringList filterStrings();
|
||||
// Return a string with all the possible file filters, for use with file dialogs
|
||||
static QString allFiltersString(QString *allFilesFilter = 0);
|
||||
|
||||
static QList<MimeGlobPattern> globPatterns();
|
||||
static void setGlobPatterns(const QString &typeOrAlias, const QList<MimeGlobPattern> &globPatterns);
|
||||
|
||||
static IMagicMatcherList magicMatchers();
|
||||
static void setMagicMatchers(const QString &typeOrAlias, const IMagicMatcherList &matchers);
|
||||
|
||||
static QList<MimeType> mimeTypes();
|
||||
|
||||
// The mime types from the functions bellow are considered only in regard to
|
||||
// their glob patterns and rule-based magic matchers.
|
||||
static void syncUserModifiedMimeTypes();
|
||||
static QList<MimeType> readUserModifiedMimeTypes();
|
||||
static void writeUserModifiedMimeTypes(const QList<MimeType> &mimeTypes);
|
||||
static void clearUserModifiedMimeTypes();
|
||||
|
||||
static QList<MimeGlobPattern> toGlobPatterns(const QStringList &patterns,
|
||||
int weight = MimeGlobPattern::MaxWeight);
|
||||
static QStringList fromGlobPatterns(const QList<MimeGlobPattern> &globPatterns);
|
||||
|
||||
private:
|
||||
MimeDatabase();
|
||||
~MimeDatabase();
|
||||
|
||||
static MimeType findByFileUnlocked(const QFileInfo &f);
|
||||
|
||||
friend class Core::Internal::MainWindow;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // MIMEDATABASE_H
|
@@ -29,7 +29,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "mimetypemagicdialog.h"
|
||||
#include "mimedatabase.h"
|
||||
|
||||
#include <utils/headerviewstretcher.h>
|
||||
|
||||
@@ -59,37 +58,37 @@ void MimeTypeMagicDialog::applyRecommended(bool checked)
|
||||
|
||||
void MimeTypeMagicDialog::validateAccept()
|
||||
{
|
||||
if (ui.valueLineEdit->text().isEmpty()
|
||||
|| (ui.byteRadioButton->isChecked()
|
||||
&& !MagicByteRule::validateByteSequence(ui.valueLineEdit->text()))) {
|
||||
QMessageBox::critical(0, tr("Error"), tr("Not a valid byte pattern."));
|
||||
return;
|
||||
}
|
||||
// if (ui.valueLineEdit->text().isEmpty()
|
||||
// || (ui.byteRadioButton->isChecked()
|
||||
// && !MagicByteRule::validateByteSequence(ui.valueLineEdit->text()))) {
|
||||
// QMessageBox::critical(0, tr("Error"), tr("Not a valid byte pattern."));
|
||||
// return;
|
||||
// }
|
||||
accept();
|
||||
}
|
||||
|
||||
void MimeTypeMagicDialog::setMagicData(const MagicData &data)
|
||||
{
|
||||
ui.valueLineEdit->setText(data.m_value);
|
||||
if (data.m_type == MagicStringRule::kMatchType)
|
||||
ui.stringRadioButton->setChecked(true);
|
||||
else
|
||||
ui.byteRadioButton->setChecked(true);
|
||||
ui.startRangeSpinBox->setValue(data.m_start);
|
||||
ui.endRangeSpinBox->setValue(data.m_end);
|
||||
ui.prioritySpinBox->setValue(data.m_priority);
|
||||
// ui.valueLineEdit->setText(data.m_value);
|
||||
// if (data.m_type == MagicStringRule::kMatchType)
|
||||
// ui.stringRadioButton->setChecked(true);
|
||||
// else
|
||||
// ui.byteRadioButton->setChecked(true);
|
||||
// ui.startRangeSpinBox->setValue(data.m_start);
|
||||
// ui.endRangeSpinBox->setValue(data.m_end);
|
||||
// ui.prioritySpinBox->setValue(data.m_priority);
|
||||
}
|
||||
|
||||
MagicData MimeTypeMagicDialog::magicData() const
|
||||
{
|
||||
MagicData data;
|
||||
data.m_value = ui.valueLineEdit->text();
|
||||
if (ui.stringRadioButton->isChecked())
|
||||
data.m_type = MagicStringRule::kMatchType;
|
||||
else
|
||||
data.m_type = MagicByteRule::kMatchType;
|
||||
data.m_start = ui.startRangeSpinBox->value();
|
||||
data.m_end = ui.endRangeSpinBox->value();
|
||||
data.m_priority = ui.prioritySpinBox->value();
|
||||
// data.m_value = ui.valueLineEdit->text();
|
||||
// if (ui.stringRadioButton->isChecked())
|
||||
// data.m_type = MagicStringRule::kMatchType;
|
||||
// else
|
||||
// data.m_type = MagicByteRule::kMatchType;
|
||||
// data.m_start = ui.startRangeSpinBox->value();
|
||||
// data.m_end = ui.endRangeSpinBox->value();
|
||||
// data.m_priority = ui.prioritySpinBox->value();
|
||||
return data;
|
||||
}
|
||||
|
@@ -30,7 +30,6 @@
|
||||
|
||||
#include "coreconstants.h"
|
||||
#include "icore.h"
|
||||
#include "mimedatabase.h"
|
||||
#include "mimetypemagicdialog.h"
|
||||
#include "mimetypesettings.h"
|
||||
#include "ui_mimetypesettingspage.h"
|
||||
@@ -39,6 +38,7 @@
|
||||
#include <coreplugin/editormanager/iexternaleditor.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/headerviewstretcher.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QCoreApplication>
|
||||
@@ -70,10 +70,10 @@ public:
|
||||
virtual QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const;
|
||||
|
||||
void load();
|
||||
void validatePatterns(QStringList *candidates, const MimeType &mimeType) const;
|
||||
void validatePatterns(QStringList *candidates) const;
|
||||
void updateKnownPatterns(const QStringList &oldPatterns, const QStringList &newPatterns);
|
||||
|
||||
QList<MimeType> m_mimeTypes;
|
||||
QList<Utils::MimeType> m_mimeTypes;
|
||||
QSet<QString> m_knownPatterns;
|
||||
QHash<QString, QString> m_handlersByMimeType;
|
||||
};
|
||||
@@ -106,7 +106,7 @@ QVariant MimeTypeSettingsModel::data(const QModelIndex &modelIndex, int role) co
|
||||
|
||||
const int column = modelIndex.column();
|
||||
if (role == Qt::DisplayRole) {
|
||||
const QString &type = m_mimeTypes.at(modelIndex.row()).type();
|
||||
const QString &type = m_mimeTypes.at(modelIndex.row()).name();
|
||||
if (column == 0)
|
||||
return type;
|
||||
else
|
||||
@@ -117,14 +117,14 @@ QVariant MimeTypeSettingsModel::data(const QModelIndex &modelIndex, int role) co
|
||||
|
||||
void MimeTypeSettingsModel::load()
|
||||
{
|
||||
m_mimeTypes = MimeDatabase::mimeTypes();
|
||||
Utils::sort(m_mimeTypes, [](const MimeType &a, const MimeType &b) {
|
||||
return a.type().compare(b.type(), Qt::CaseInsensitive) < 0;
|
||||
Utils::MimeDatabase mdb;
|
||||
m_mimeTypes = mdb.allMimeTypes();
|
||||
Utils::sort(m_mimeTypes, [](const Utils::MimeType &a, const Utils::MimeType &b) {
|
||||
return a.name().compare(b.name(), Qt::CaseInsensitive) < 0;
|
||||
});
|
||||
m_knownPatterns = QSet<QString>::fromList(
|
||||
MimeDatabase::fromGlobPatterns(MimeDatabase::globPatterns()));
|
||||
m_knownPatterns = QSet<QString>::fromList(Utils::MimeDatabase::allGlobPatterns());
|
||||
|
||||
foreach (const MimeType &mimeType, m_mimeTypes) {
|
||||
foreach (const Utils::MimeType &mimeType, m_mimeTypes) {
|
||||
QString value;
|
||||
const QList<IEditorFactory *> factories =
|
||||
EditorManager::editorFactories(mimeType);
|
||||
@@ -138,15 +138,14 @@ void MimeTypeSettingsModel::load()
|
||||
else
|
||||
value = tr("Undefined");
|
||||
}
|
||||
m_handlersByMimeType.insert(mimeType.type(), value);
|
||||
m_handlersByMimeType.insert(mimeType.name(), value);
|
||||
}
|
||||
}
|
||||
|
||||
void MimeTypeSettingsModel::validatePatterns(QStringList *candidates,
|
||||
const MimeType &mimeType) const
|
||||
void MimeTypeSettingsModel::validatePatterns(QStringList *candidates) const
|
||||
{
|
||||
QSet<QString> oldPatterns =
|
||||
QSet<QString>::fromList(MimeDatabase::fromGlobPatterns(mimeType.globPatterns()));
|
||||
QSet<QString>::fromList(Utils::MimeDatabase::allGlobPatterns());
|
||||
|
||||
QStringList duplicates;
|
||||
QStringList::iterator it = candidates->begin();
|
||||
@@ -209,9 +208,10 @@ public:
|
||||
void clearSyncData();
|
||||
void markAsModified(int index);
|
||||
|
||||
void addMagicHeaderRow(const MagicData &data);
|
||||
MagicData getMagicHeaderRowData(const int row) const;
|
||||
void editMagicHeaderRowData(const int row, const MagicData &data);
|
||||
// TODO
|
||||
// void addMagicHeaderRow(const MagicData &data);
|
||||
// MagicData getMagicHeaderRowData(const int row) const;
|
||||
// void editMagicHeaderRowData(const int row, const MagicData &data);
|
||||
|
||||
void updateMimeDatabase();
|
||||
void resetState();
|
||||
@@ -219,9 +219,10 @@ public:
|
||||
public slots:
|
||||
void syncData(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void handlePatternEdited();
|
||||
void addMagicHeader();
|
||||
void removeMagicHeader();
|
||||
void editMagicHeader();
|
||||
// TODO
|
||||
// void addMagicHeader();
|
||||
// void removeMagicHeader();
|
||||
// void editMagicHeader();
|
||||
void resetMimeTypes();
|
||||
void updateMagicHeaderButtons();
|
||||
|
||||
@@ -278,9 +279,10 @@ void MimeTypeSettingsPrivate::configureUi(QWidget *w)
|
||||
SLOT(syncData(QModelIndex,QModelIndex)));
|
||||
connect(m_ui.patternsLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(handlePatternEdited()));
|
||||
connect(m_ui.addMagicButton, SIGNAL(clicked()), this, SLOT(addMagicHeader()));
|
||||
connect(m_ui.removeMagicButton, SIGNAL(clicked()), this, SLOT(removeMagicHeader()));
|
||||
connect(m_ui.editMagicButton, SIGNAL(clicked()), this, SLOT(editMagicHeader()));
|
||||
// TODO
|
||||
// connect(m_ui.addMagicButton, SIGNAL(clicked()), this, SLOT(addMagicHeader()));
|
||||
// connect(m_ui.removeMagicButton, SIGNAL(clicked()), this, SLOT(removeMagicHeader()));
|
||||
// connect(m_ui.editMagicButton, SIGNAL(clicked()), this, SLOT(editMagicHeader()));
|
||||
connect(m_ui.resetButton, SIGNAL(clicked()), this, SLOT(resetMimeTypes()));
|
||||
connect(m_ui.magicHeadersTreeWidget,
|
||||
SIGNAL(itemSelectionChanged()),
|
||||
@@ -332,35 +334,37 @@ void MimeTypeSettingsPrivate::markAsModified(int index)
|
||||
|
||||
void MimeTypeSettingsPrivate::syncMimePattern()
|
||||
{
|
||||
MimeType &mimeType = m_model->m_mimeTypes[m_mimeForPatternSync];
|
||||
QStringList patterns = m_ui.patternsLineEdit->text().split(kSemiColon);
|
||||
patterns.removeDuplicates();
|
||||
m_model->validatePatterns(&patterns, mimeType);
|
||||
m_model->updateKnownPatterns(MimeDatabase::fromGlobPatterns(mimeType.globPatterns()), patterns);
|
||||
mimeType.setGlobPatterns(MimeDatabase::toGlobPatterns(patterns));
|
||||
// TODO
|
||||
// MimeType &mimeType = m_model->m_mimeTypes[m_mimeForPatternSync];
|
||||
// QStringList patterns = m_ui.patternsLineEdit->text().split(kSemiColon);
|
||||
// patterns.removeDuplicates();
|
||||
// m_model->validatePatterns(&patterns);
|
||||
// m_model->updateKnownPatterns(MimeDatabase::fromGlobPatterns(mimeType.globPatterns()), patterns);
|
||||
// mimeType.setGlobPatterns(MimeDatabase::toGlobPatterns(patterns));
|
||||
}
|
||||
|
||||
void MimeTypeSettingsPrivate::syncMimeMagic()
|
||||
{
|
||||
typedef MagicRuleMatcher::MagicRuleList MagicRuleList;
|
||||
typedef MagicRuleMatcher::MagicRuleSharedPointer MagicRuleSharedPointer;
|
||||
// TODO
|
||||
// typedef MagicRuleMatcher::MagicRuleList MagicRuleList;
|
||||
// typedef MagicRuleMatcher::MagicRuleSharedPointer MagicRuleSharedPointer;
|
||||
|
||||
// Gather the magic rules.
|
||||
QHash<int, MagicRuleList> rulesByPriority;
|
||||
for (int row = 0; row < m_ui.magicHeadersTreeWidget->topLevelItemCount(); ++row) {
|
||||
const MagicData &data = getMagicHeaderRowData(row);
|
||||
// @TODO: Validate magic rule?
|
||||
MagicRule *magicRule;
|
||||
if (data.m_type == MagicStringRule::kMatchType)
|
||||
magicRule = new MagicStringRule(data.m_value, data.m_start, data.m_end);
|
||||
else
|
||||
magicRule = new MagicByteRule(data.m_value, data.m_start, data.m_end);
|
||||
rulesByPriority[data.m_priority].append(MagicRuleSharedPointer(magicRule));
|
||||
}
|
||||
// // Gather the magic rules.
|
||||
// QHash<int, MagicRuleList> rulesByPriority;
|
||||
// for (int row = 0; row < m_ui.magicHeadersTreeWidget->topLevelItemCount(); ++row) {
|
||||
// const MagicData &data = getMagicHeaderRowData(row);
|
||||
// // @TODO: Validate magic rule?
|
||||
// MagicRule *magicRule;
|
||||
// if (data.m_type == MagicStringRule::kMatchType)
|
||||
// magicRule = new MagicStringRule(data.m_value, data.m_start, data.m_end);
|
||||
// else
|
||||
// magicRule = new MagicByteRule(data.m_value, data.m_start, data.m_end);
|
||||
// rulesByPriority[data.m_priority].append(MagicRuleSharedPointer(magicRule));
|
||||
// }
|
||||
|
||||
const QList<QSharedPointer<IMagicMatcher> > &matchers =
|
||||
MagicRuleMatcher::createMatchers(rulesByPriority);
|
||||
m_model->m_mimeTypes[m_mimeForMagicSync].setMagicRuleMatchers(matchers);
|
||||
// const QList<QSharedPointer<IMagicMatcher> > &matchers =
|
||||
// MagicRuleMatcher::createMatchers(rulesByPriority);
|
||||
// m_model->m_mimeTypes[m_mimeForMagicSync].setMagicRuleMatchers(matchers);
|
||||
}
|
||||
|
||||
void MimeTypeSettingsPrivate::clearSyncData()
|
||||
@@ -384,27 +388,25 @@ void MimeTypeSettingsPrivate::syncData(const QModelIndex ¤t,
|
||||
}
|
||||
|
||||
if (current.isValid()) {
|
||||
const MimeType ¤tMimeType =
|
||||
const Utils::MimeType ¤tMimeType =
|
||||
m_model->m_mimeTypes.at(m_filterModel->mapToSource(current).row());
|
||||
|
||||
QStringList formatedPatterns;
|
||||
foreach (const MimeGlobPattern &pattern, currentMimeType.globPatterns())
|
||||
formatedPatterns.append(pattern.pattern());
|
||||
m_ui.patternsLineEdit->setText(formatedPatterns.join(kSemiColon));
|
||||
m_ui.patternsLineEdit->setText(currentMimeType.globPatterns().join(kSemiColon));
|
||||
|
||||
// Consider only rule-based matchers.
|
||||
const QList<QSharedPointer<IMagicMatcher> > &matchers = currentMimeType.magicRuleMatchers();
|
||||
foreach (const QSharedPointer<IMagicMatcher> &matcher, matchers) {
|
||||
MagicRuleMatcher *ruleMatcher = static_cast<MagicRuleMatcher *>(matcher.data());
|
||||
const int priority = ruleMatcher->priority();
|
||||
const MagicRuleMatcher::MagicRuleList &rules = ruleMatcher->magicRules();
|
||||
foreach (const MagicRuleMatcher::MagicRuleSharedPointer &rule, rules)
|
||||
addMagicHeaderRow(MagicData(rule->matchValue(),
|
||||
rule->matchType(),
|
||||
rule->startPos(),
|
||||
rule->endPos(),
|
||||
priority));
|
||||
}
|
||||
// TODO
|
||||
// // Consider only rule-based matchers.
|
||||
// const QList<QSharedPointer<IMagicMatcher> > &matchers = currentMimeType.magicRuleMatchers();
|
||||
// foreach (const QSharedPointer<IMagicMatcher> &matcher, matchers) {
|
||||
// MagicRuleMatcher *ruleMatcher = static_cast<MagicRuleMatcher *>(matcher.data());
|
||||
// const int priority = ruleMatcher->priority();
|
||||
// const MagicRuleMatcher::MagicRuleList &rules = ruleMatcher->magicRules();
|
||||
// foreach (const MagicRuleMatcher::MagicRuleSharedPointer &rule, rules)
|
||||
// addMagicHeaderRow(MagicData(rule->matchValue(),
|
||||
// rule->matchType(),
|
||||
// rule->startPos(),
|
||||
// rule->endPos(),
|
||||
// priority));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,94 +419,96 @@ void MimeTypeSettingsPrivate::handlePatternEdited()
|
||||
}
|
||||
}
|
||||
|
||||
void MimeTypeSettingsPrivate::addMagicHeaderRow(const MagicData &data)
|
||||
{
|
||||
const int row = m_ui.magicHeadersTreeWidget->topLevelItemCount();
|
||||
editMagicHeaderRowData(row, data);
|
||||
}
|
||||
// TODO
|
||||
//void MimeTypeSettingsPrivate::addMagicHeaderRow(const MagicData &data)
|
||||
//{
|
||||
// const int row = m_ui.magicHeadersTreeWidget->topLevelItemCount();
|
||||
// editMagicHeaderRowData(row, data);
|
||||
//}
|
||||
|
||||
MagicData MimeTypeSettingsPrivate::getMagicHeaderRowData(const int row) const
|
||||
{
|
||||
MagicData data;
|
||||
data.m_value = m_ui.magicHeadersTreeWidget->topLevelItem(row)->text(0);
|
||||
data.m_type = m_ui.magicHeadersTreeWidget->topLevelItem(row)->text(1);
|
||||
QPair<int, int> startEnd =
|
||||
MagicRule::fromOffset(m_ui.magicHeadersTreeWidget->topLevelItem(row)->text(2));
|
||||
data.m_start = startEnd.first;
|
||||
data.m_end = startEnd.second;
|
||||
data.m_priority = m_ui.magicHeadersTreeWidget->topLevelItem(row)->text(3).toInt();
|
||||
//MagicData MimeTypeSettingsPrivate::getMagicHeaderRowData(const int row) const
|
||||
//{
|
||||
// MagicData data;
|
||||
// data.m_value = m_ui.magicHeadersTreeWidget->topLevelItem(row)->text(0);
|
||||
// data.m_type = m_ui.magicHeadersTreeWidget->topLevelItem(row)->text(1);
|
||||
// QPair<int, int> startEnd =
|
||||
// MagicRule::fromOffset(m_ui.magicHeadersTreeWidget->topLevelItem(row)->text(2));
|
||||
// data.m_start = startEnd.first;
|
||||
// data.m_end = startEnd.second;
|
||||
// data.m_priority = m_ui.magicHeadersTreeWidget->topLevelItem(row)->text(3).toInt();
|
||||
|
||||
return data;
|
||||
}
|
||||
// return data;
|
||||
//}
|
||||
|
||||
void MimeTypeSettingsPrivate::editMagicHeaderRowData(const int row, const MagicData &data)
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem;
|
||||
item->setText(0, data.m_value);
|
||||
item->setText(1, data.m_type);
|
||||
item->setText(2, MagicRule::toOffset(qMakePair(data.m_start, data.m_end)));
|
||||
item->setText(3, QString::number(data.m_priority));
|
||||
m_ui.magicHeadersTreeWidget->takeTopLevelItem(row);
|
||||
m_ui.magicHeadersTreeWidget->insertTopLevelItem(row, item);
|
||||
m_ui.magicHeadersTreeWidget->setCurrentItem(item);
|
||||
}
|
||||
//void MimeTypeSettingsPrivate::editMagicHeaderRowData(const int row, const MagicData &data)
|
||||
//{
|
||||
// QTreeWidgetItem *item = new QTreeWidgetItem;
|
||||
// item->setText(0, data.m_value);
|
||||
// item->setText(1, data.m_type);
|
||||
// item->setText(2, MagicRule::toOffset(qMakePair(data.m_start, data.m_end)));
|
||||
// item->setText(3, QString::number(data.m_priority));
|
||||
// m_ui.magicHeadersTreeWidget->takeTopLevelItem(row);
|
||||
// m_ui.magicHeadersTreeWidget->insertTopLevelItem(row, item);
|
||||
// m_ui.magicHeadersTreeWidget->setCurrentItem(item);
|
||||
//}
|
||||
|
||||
void MimeTypeSettingsPrivate::addMagicHeader()
|
||||
{
|
||||
if (!checkSelectedMimeType())
|
||||
return;
|
||||
//void MimeTypeSettingsPrivate::addMagicHeader()
|
||||
//{
|
||||
// if (!checkSelectedMimeType())
|
||||
// return;
|
||||
|
||||
MimeTypeMagicDialog dlg;
|
||||
if (dlg.exec()) {
|
||||
addMagicHeaderRow(dlg.magicData());
|
||||
markMimeForMagicSync(m_filterModel->mapToSource(
|
||||
m_ui.mimeTypesTreeView->currentIndex()).row());
|
||||
}
|
||||
}
|
||||
// MimeTypeMagicDialog dlg;
|
||||
// if (dlg.exec()) {
|
||||
// addMagicHeaderRow(dlg.magicData());
|
||||
// markMimeForMagicSync(m_filterModel->mapToSource(
|
||||
// m_ui.mimeTypesTreeView->currentIndex()).row());
|
||||
// }
|
||||
//}
|
||||
|
||||
void MimeTypeSettingsPrivate::removeMagicHeader()
|
||||
{
|
||||
if (!checkSelectedMagicHeader())
|
||||
return;
|
||||
//void MimeTypeSettingsPrivate::removeMagicHeader()
|
||||
//{
|
||||
// if (!checkSelectedMagicHeader())
|
||||
// return;
|
||||
|
||||
m_ui.magicHeadersTreeWidget->takeTopLevelItem(m_ui.magicHeadersTreeWidget->indexOfTopLevelItem(m_ui.magicHeadersTreeWidget->currentItem()));
|
||||
markMimeForMagicSync(m_filterModel->mapToSource(
|
||||
m_ui.mimeTypesTreeView->currentIndex()).row());
|
||||
}
|
||||
// m_ui.magicHeadersTreeWidget->takeTopLevelItem(m_ui.magicHeadersTreeWidget->indexOfTopLevelItem(m_ui.magicHeadersTreeWidget->currentItem()));
|
||||
// markMimeForMagicSync(m_filterModel->mapToSource(
|
||||
// m_ui.mimeTypesTreeView->currentIndex()).row());
|
||||
//}
|
||||
|
||||
void MimeTypeSettingsPrivate::editMagicHeader()
|
||||
{
|
||||
if (!checkSelectedMagicHeader())
|
||||
return;
|
||||
//void MimeTypeSettingsPrivate::editMagicHeader()
|
||||
//{
|
||||
// if (!checkSelectedMagicHeader())
|
||||
// return;
|
||||
|
||||
MimeTypeMagicDialog dlg;
|
||||
dlg.setMagicData(getMagicHeaderRowData(m_ui.magicHeadersTreeWidget->indexOfTopLevelItem(m_ui.magicHeadersTreeWidget->currentItem())));
|
||||
if (dlg.exec()) {
|
||||
editMagicHeaderRowData(m_ui.magicHeadersTreeWidget->indexOfTopLevelItem(m_ui.magicHeadersTreeWidget->currentItem()), dlg.magicData());
|
||||
markMimeForMagicSync(m_filterModel->mapToSource(
|
||||
m_ui.mimeTypesTreeView->currentIndex()).row());
|
||||
}
|
||||
}
|
||||
// MimeTypeMagicDialog dlg;
|
||||
// dlg.setMagicData(getMagicHeaderRowData(m_ui.magicHeadersTreeWidget->indexOfTopLevelItem(m_ui.magicHeadersTreeWidget->currentItem())));
|
||||
// if (dlg.exec()) {
|
||||
// editMagicHeaderRowData(m_ui.magicHeadersTreeWidget->indexOfTopLevelItem(m_ui.magicHeadersTreeWidget->currentItem()), dlg.magicData());
|
||||
// markMimeForMagicSync(m_filterModel->mapToSource(
|
||||
// m_ui.mimeTypesTreeView->currentIndex()).row());
|
||||
// }
|
||||
//}
|
||||
|
||||
void MimeTypeSettingsPrivate::updateMimeDatabase()
|
||||
{
|
||||
if (m_modifiedMimeTypes.isEmpty())
|
||||
return;
|
||||
// TODO
|
||||
// if (m_modifiedMimeTypes.isEmpty())
|
||||
// return;
|
||||
|
||||
// For this case it is a better approach to simply use a list and to remove duplicates
|
||||
// afterwards than to keep a more complex data structure like a hash table.
|
||||
Utils::sort(m_modifiedMimeTypes);
|
||||
m_modifiedMimeTypes.erase(std::unique(m_modifiedMimeTypes.begin(), m_modifiedMimeTypes.end()),
|
||||
m_modifiedMimeTypes.end());
|
||||
// // For this case it is a better approach to simply use a list and to remove duplicates
|
||||
// // afterwards than to keep a more complex data structure like a hash table.
|
||||
// Utils::sort(m_modifiedMimeTypes);
|
||||
// m_modifiedMimeTypes.erase(std::unique(m_modifiedMimeTypes.begin(), m_modifiedMimeTypes.end()),
|
||||
// m_modifiedMimeTypes.end());
|
||||
|
||||
QList<MimeType> allModified;
|
||||
foreach (int index, m_modifiedMimeTypes) {
|
||||
const MimeType &mimeType = m_model->m_mimeTypes.at(index);
|
||||
MimeDatabase::setGlobPatterns(mimeType.type(), mimeType.globPatterns());
|
||||
MimeDatabase::setMagicMatchers(mimeType.type(), mimeType.magicMatchers());
|
||||
allModified.append(mimeType);
|
||||
}
|
||||
MimeDatabase::writeUserModifiedMimeTypes(allModified);
|
||||
// QList<MimeType> allModified;
|
||||
// foreach (int index, m_modifiedMimeTypes) {
|
||||
// const MimeType &mimeType = m_model->m_mimeTypes.at(index);
|
||||
// MimeDatabase::setGlobPatterns(mimeType.type(), mimeType.globPatterns());
|
||||
// MimeDatabase::setMagicMatchers(mimeType.type(), mimeType.magicMatchers());
|
||||
// allModified.append(mimeType);
|
||||
// }
|
||||
// MimeDatabase::writeUserModifiedMimeTypes(allModified);
|
||||
}
|
||||
|
||||
void MimeTypeSettingsPrivate::resetState()
|
||||
@@ -561,6 +565,11 @@ QWidget *MimeTypeSettings::widget()
|
||||
if (!d->m_widget) {
|
||||
d->m_widget = new QWidget;
|
||||
d->configureUi(d->m_widget);
|
||||
// TODO temporarily disabled
|
||||
d->m_ui.addMagicButton->setEnabled(false);
|
||||
d->m_ui.editMagicButton->setEnabled(false);
|
||||
d->m_ui.removeMagicButton->setEnabled(false);
|
||||
d->m_ui.patternsLineEdit->setEnabled(false);
|
||||
}
|
||||
return d->m_widget;
|
||||
}
|
||||
@@ -585,12 +594,13 @@ void MimeTypeSettings::apply()
|
||||
|
||||
void MimeTypeSettings::finish()
|
||||
{
|
||||
if (d->m_persist) {
|
||||
if (d->m_reset)
|
||||
MimeDatabase::clearUserModifiedMimeTypes();
|
||||
else
|
||||
d->updateMimeDatabase();
|
||||
}
|
||||
// TODO
|
||||
// if (d->m_persist) {
|
||||
// if (d->m_reset)
|
||||
// MimeDatabase::clearUserModifiedMimeTypes();
|
||||
// else
|
||||
// d->updateMimeDatabase();
|
||||
// }
|
||||
d->resetState();
|
||||
delete d->m_widget;
|
||||
}
|
||||
|
@@ -46,11 +46,11 @@
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <QtPlugin>
|
||||
@@ -377,7 +377,9 @@ void CodepasterPlugin::finishFetch(const QString &titleDescription,
|
||||
// Default to "txt".
|
||||
QByteArray byteContent = content.toUtf8();
|
||||
QString suffix;
|
||||
if (const MimeType mimeType = MimeDatabase::findByData(byteContent))
|
||||
Utils::MimeDatabase mdb;
|
||||
const Utils::MimeType mimeType = mdb.mimeTypeForData(byteContent);
|
||||
if (mimeType.isValid())
|
||||
suffix = mimeType.preferredSuffix();
|
||||
if (suffix.isEmpty())
|
||||
suffix = QLatin1String("txt");
|
||||
|
@@ -1,33 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="text/x-csrc">
|
||||
<sub-class-of type="text/plain"/>
|
||||
<comment>C Source file</comment>
|
||||
<glob pattern="*.c"/>
|
||||
<!-- NVIDIA CUDA files are like C -->
|
||||
<glob pattern="*.cu"/>
|
||||
</mime-type>
|
||||
|
||||
<!-- A C Header file is virtually undistinguishable from the C++ header -->
|
||||
<mime-type type="text/x-chdr">
|
||||
<mime-type type="text/vnd.nvidia.cuda.csrc">
|
||||
<sub-class-of type="text/x-csrc"/>
|
||||
<comment>C Header file</comment>
|
||||
<glob pattern="*.h"/>
|
||||
<comment>NVIDIA CUDA C source code</comment>
|
||||
<glob pattern="*.cu"/>
|
||||
</mime-type>
|
||||
|
||||
<!-- Those are used to find matching headers by the CppTools plugin,
|
||||
so, they should match -->
|
||||
<mime-type type="text/x-c++hdr">
|
||||
<sub-class-of type="text/x-chdr"/>
|
||||
<comment>C++ Header file</comment>
|
||||
<comment>C++ header</comment>
|
||||
<glob pattern="*.h"/>
|
||||
<glob pattern="*.hh"/>
|
||||
<glob pattern="*.hxx"/>
|
||||
<glob pattern="*.h++"/>
|
||||
<glob pattern="*.H"/>
|
||||
<glob pattern="*.hpp"/>
|
||||
<glob pattern="*.hp"/>
|
||||
<!-- Additions to freedesktop: -->
|
||||
<glob pattern="*.h"/>
|
||||
<glob pattern="*.H"/>
|
||||
<!-- Find include guards of header files without extension, for
|
||||
example, STL ones like <string>. Those can have a big initial
|
||||
comment exceeding 1000 chars, though. -->
|
||||
@@ -39,17 +30,17 @@
|
||||
</mime-type>
|
||||
|
||||
<mime-type type="text/x-c++src">
|
||||
<comment>C++ Source file</comment>
|
||||
<comment>C++ source code</comment>
|
||||
<sub-class-of type="text/x-csrc"/>
|
||||
<comment>C++ source code</comment>
|
||||
<glob pattern="*.cpp"/>
|
||||
<glob pattern="*.cp"/>
|
||||
<glob pattern="*.cc"/>
|
||||
<glob pattern="*.cxx"/>
|
||||
<glob pattern="*.cc"/>
|
||||
<glob pattern="*.C" case-sensitive="true"/>
|
||||
<glob pattern="*.c++"/>
|
||||
<glob pattern="*.C"/>
|
||||
<!-- Additions to freedesktop: -->
|
||||
<glob pattern="*.cp"/>
|
||||
<glob pattern="*.inl"/>
|
||||
<glob pattern="*.moc"/>
|
||||
<glob pattern="*.qdoc"/>
|
||||
<glob pattern="*.tcc"/>
|
||||
<glob pattern="*.tpp"/>
|
||||
@@ -60,10 +51,13 @@
|
||||
</magic>
|
||||
</mime-type>
|
||||
|
||||
<mime-type type="text/x-objcsrc">
|
||||
<comment>Objective-C source code</comment>
|
||||
<sub-class-of type="text/x-csrc"/>
|
||||
<glob pattern="*.m"/>
|
||||
<mime-type type="text/x-moc">
|
||||
<comment>Qt MOC file</comment>
|
||||
<acronym>Qt MOC</acronym>
|
||||
<expanded-acronym>Qt Meta Object Compiler</expanded-acronym>
|
||||
<!-- Fix to freedesktop: moc is C++ source -->
|
||||
<sub-class-of type="text/x-c++src"/>
|
||||
<glob pattern="*.moc"/>
|
||||
</mime-type>
|
||||
|
||||
<mime-type type="text/x-objc++src">
|
||||
|
@@ -44,6 +44,7 @@
|
||||
|
||||
#include <projectexplorer/session.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/runextensions.h>
|
||||
|
||||
@@ -202,7 +203,8 @@ void CppEditorDocument::onFilePathChanged(const Utils::FileName &oldPath,
|
||||
Q_UNUSED(oldPath);
|
||||
|
||||
if (!newPath.isEmpty()) {
|
||||
setMimeType(Core::MimeDatabase::findByFile(newPath.toFileInfo()).type());
|
||||
Utils::MimeDatabase mdb;
|
||||
setMimeType(mdb.mimeTypeForFile(newPath.toFileInfo()).name());
|
||||
|
||||
disconnect(this, SIGNAL(contentsChanged()), this, SLOT(scheduleProcessDocument()));
|
||||
connect(this, SIGNAL(contentsChanged()), this, SLOT(scheduleProcessDocument()));
|
||||
|
@@ -60,7 +60,7 @@
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -153,8 +153,8 @@ CppQuickFixAssistProvider *CppEditorPlugin::quickFixProvider() const
|
||||
|
||||
bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
|
||||
{
|
||||
if (!MimeDatabase::addMimeTypes(QLatin1String(":/cppeditor/CppEditor.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
Q_UNUSED(errorMessage)
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/cppeditor/CppEditor.mimetypes.xml"));
|
||||
|
||||
addAutoReleasedObject(new CppEditorFactory);
|
||||
addAutoReleasedObject(new CppOutlineWidgetFactory);
|
||||
|
@@ -49,6 +49,7 @@
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/completionsettings.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <cplusplus/BackwardsScanner.h>
|
||||
@@ -1120,9 +1121,8 @@ bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cu
|
||||
if (!headerPaths.contains(currentFilePath))
|
||||
headerPaths.append(currentFilePath);
|
||||
|
||||
const Core::MimeType mimeType =
|
||||
Core::MimeDatabase::findByType(QLatin1String("text/x-c++hdr"));
|
||||
const QStringList suffixes = mimeType.suffixes();
|
||||
Utils::MimeDatabase mdb;
|
||||
const QStringList suffixes = mdb.mimeTypeForName(QLatin1String("text/x-c++hdr")).suffixes();
|
||||
|
||||
foreach (const ProjectPart::HeaderPath &headerPath, headerPaths) {
|
||||
QString realPath = headerPath.path;
|
||||
@@ -1171,9 +1171,10 @@ bool InternalCppCompletionAssistProcessor::objcKeywordsWanted() const
|
||||
|
||||
const QString fileName = m_interface->fileName();
|
||||
|
||||
const QString mt = Core::MimeDatabase::findByFile(fileName).type();
|
||||
return mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
|
||||
|| mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE);
|
||||
Utils::MimeDatabase mdb;
|
||||
const Utils::MimeType mt = mdb.mimeTypeForFile(fileName);
|
||||
return mt.matchesName(QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE))
|
||||
|| mt.matchesName(QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
|
||||
}
|
||||
|
||||
int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString &fileName,
|
||||
|
@@ -36,11 +36,11 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QDebug>
|
||||
@@ -118,8 +118,17 @@ void CppFileSettings::fromSettings(QSettings *s)
|
||||
|
||||
bool CppFileSettings::applySuffixesToMimeDB()
|
||||
{
|
||||
return Core::MimeDatabase::setPreferredSuffix(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE), sourceSuffix)
|
||||
&& Core::MimeDatabase::setPreferredSuffix(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE), headerSuffix);
|
||||
Utils::MimeDatabase mdb;
|
||||
Utils::MimeType mt;
|
||||
mt = mdb.mimeTypeForName(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE));
|
||||
if (!mt.isValid())
|
||||
return false;
|
||||
mt.setPreferredSuffix(sourceSuffix);
|
||||
mt = mdb.mimeTypeForName(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE));
|
||||
if (!mt.isValid())
|
||||
return false;
|
||||
mt.setPreferredSuffix(headerSuffix);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CppFileSettings::equals(const CppFileSettings &rhs) const
|
||||
@@ -255,13 +264,18 @@ CppFileSettingsWidget::CppFileSettingsWidget(QWidget *parent) :
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
// populate suffix combos
|
||||
if (const Core::MimeType sourceMt = Core::MimeDatabase::findByType(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE)))
|
||||
Utils::MimeDatabase mdb;
|
||||
const Utils::MimeType sourceMt = mdb.mimeTypeForName(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE));
|
||||
if (sourceMt.isValid()) {
|
||||
foreach (const QString &suffix, sourceMt.suffixes())
|
||||
m_ui->sourceSuffixComboBox->addItem(suffix);
|
||||
}
|
||||
|
||||
if (const Core::MimeType headerMt = Core::MimeDatabase::findByType(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE)))
|
||||
const Utils::MimeType headerMt = mdb.mimeTypeForName(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE));
|
||||
if (headerMt.isValid()) {
|
||||
foreach (const QString &suffix, headerMt.suffixes())
|
||||
m_ui->headerSuffixComboBox->addItem(suffix);
|
||||
}
|
||||
m_ui->licenseTemplatePathChooser->setExpectedKind(Utils::PathChooser::File);
|
||||
m_ui->licenseTemplatePathChooser->setHistoryCompleter(QLatin1String("Cpp.LicenseTemplate.History"));
|
||||
m_ui->licenseTemplatePathChooser->addButton(tr("Edit..."), this, SLOT(slotEdit()));
|
||||
|
@@ -33,7 +33,8 @@
|
||||
#include "cpptoolsconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#
|
||||
#include <QDebug>
|
||||
|
||||
namespace CppTools {
|
||||
@@ -51,11 +52,11 @@ ProjectFile::ProjectFile(const QString &file, Kind kind)
|
||||
|
||||
ProjectFile::Kind ProjectFile::classify(const QString &file)
|
||||
{
|
||||
const QFileInfo fi(file);
|
||||
const Core::MimeType mimeType = Core::MimeDatabase::findByFile(fi);
|
||||
if (!mimeType)
|
||||
Utils::MimeDatabase mdb;
|
||||
const Utils::MimeType mimeType = mdb.mimeTypeForFile(file);
|
||||
if (!mimeType.isValid())
|
||||
return Unclassified;
|
||||
const QString mt = mimeType.type();
|
||||
const QString mt = mimeType.name();
|
||||
if (mt == QLatin1String(CppTools::Constants::C_SOURCE_MIMETYPE))
|
||||
return CSource;
|
||||
if (mt == QLatin1String(CppTools::Constants::C_HEADER_MIMETYPE))
|
||||
@@ -141,10 +142,9 @@ ProjectFileAdder::~ProjectFileAdder()
|
||||
|
||||
bool ProjectFileAdder::maybeAdd(const QString &path)
|
||||
{
|
||||
m_fileInfo.setFile(path);
|
||||
foreach (const Pair &pair, m_mapping)
|
||||
if (pair.first.matchesFile(path)) {
|
||||
m_files << ProjectFile(path, pair.second);
|
||||
const Utils::MimeType mt = Utils::MimeDatabase::bestMatch(path, m_mimeTypes);
|
||||
if (mt.isValid()) {
|
||||
m_files << ProjectFile(path, m_mimeNameMapping.value(mt.name()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -152,9 +152,12 @@ bool ProjectFileAdder::maybeAdd(const QString &path)
|
||||
|
||||
void ProjectFileAdder::addMapping(const char *mimeName, ProjectFile::Kind kind)
|
||||
{
|
||||
Core::MimeType mimeType = Core::MimeDatabase::findByType(QLatin1String(mimeName));
|
||||
if (!mimeType.isNull())
|
||||
m_mapping.append(Pair(mimeType, kind));
|
||||
Utils::MimeDatabase mdb;
|
||||
Utils::MimeType mimeType = mdb.mimeTypeForName(QLatin1String(mimeName));
|
||||
if (mimeType.isValid()) {
|
||||
m_mimeNameMapping.insert(mimeType.name(), kind);
|
||||
m_mimeTypes.append(mimeType);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -33,8 +33,10 @@
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <utils/mimetypes/mimetype.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
namespace CppTools {
|
||||
@@ -81,13 +83,12 @@ public:
|
||||
bool maybeAdd(const QString &path);
|
||||
|
||||
private:
|
||||
typedef QPair<Core::MimeType, ProjectFile::Kind> Pair;
|
||||
|
||||
void addMapping(const char *mimeName, ProjectFile::Kind kind);
|
||||
|
||||
QList<ProjectFile> &m_files;
|
||||
QList<Pair> m_mapping;
|
||||
QFileInfo m_fileInfo;
|
||||
QHash<QString, ProjectFile::Kind> m_mimeNameMapping;
|
||||
QList<Utils::MimeType> m_mimeTypes;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -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);
|
||||
|
14
src/plugins/debugger/Debugger.mimetypes.xml
Normal file
14
src/plugins/debugger/Debugger.mimetypes.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="text/x-asm">
|
||||
<sub-class-of type="text/plain"/>
|
||||
<comment>Assembler</comment>
|
||||
<glob pattern="*.asm"/>
|
||||
</mime-type>
|
||||
<!-- Catch-all for assemblers -->
|
||||
<mime-type type="text/x-qtcreator-generic-asm">
|
||||
<sub-class-of type="text/x-asm"/>
|
||||
<comment>Qt Creator Generic Assembler</comment>
|
||||
<glob pattern="*.asm"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
@@ -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();
|
||||
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="application/x-designer">
|
||||
<sub-class-of type="application/xml"/>
|
||||
<comment>Qt Designer file</comment>
|
||||
<glob pattern="*.ui"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
@@ -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());
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<RCC>
|
||||
<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);
|
||||
|
@@ -1,70 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="image/bmp">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>BMP image</comment>
|
||||
<glob pattern="*.bmp"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/gif">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>GIF image</comment>
|
||||
<glob pattern="*.gif"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/x-icon">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>ICO image</comment>
|
||||
<glob pattern="*.ico"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/jpeg">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>JPEG image</comment>
|
||||
<glob pattern="*.jpg"/>
|
||||
<glob pattern="*.jpeg"/>
|
||||
</mime-type>
|
||||
<mime-type type="video/x-mng">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>MNG video</comment>
|
||||
<glob pattern="*.mng"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/x-portable-bitmap">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>PBM image</comment>
|
||||
<glob pattern="*.pbm"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/x-portable-graymap">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>PGM image</comment>
|
||||
<glob pattern="*.pgm"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/png">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>PNG image</comment>
|
||||
<glob pattern="*.png"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/x-portable-pixmap">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>PPM image</comment>
|
||||
<glob pattern="*.ppm"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/svg+xml">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>SVG image</comment>
|
||||
<glob pattern="*.svg"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/tiff">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>TIFF image</comment>
|
||||
<glob pattern="*.tif"/>
|
||||
<glob pattern="*.tiff"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/xbm">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>XBM image</comment>
|
||||
<glob pattern="*.xbm"/>
|
||||
</mime-type>
|
||||
<mime-type type="image/xpm">
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<comment>XPM image</comment>
|
||||
<glob pattern="*.xpm"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
@@ -1,6 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/imageviewer">
|
||||
<file>ImageViewer.mimetypes.xml</file>
|
||||
<file>images/outline.png</file>
|
||||
<file>images/zoomin.png</file>
|
||||
<file>images/zoomout.png</file>
|
||||
|
@@ -36,7 +36,6 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/id.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
@@ -48,9 +47,7 @@ namespace Internal {
|
||||
bool ImageViewerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
|
||||
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":/imageviewer/ImageViewer.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
m_factory = new ImageViewerFactory(this);
|
||||
addAutoReleasedObject(m_factory);
|
||||
|
@@ -48,12 +48,12 @@
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/locator/commandlocator.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <vcsbase/basevcseditorfactory.h>
|
||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
@@ -221,12 +221,13 @@ static const VcsBaseSubmitEditorParameters submitParameters = {
|
||||
|
||||
bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
Context context(PERFORCE_CONTEXT);
|
||||
|
||||
initializeVcs(new PerforceVersionControl(this), context);
|
||||
|
||||
if (!MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.perforce/Perforce.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.perforce/Perforce.mimetypes.xml"));
|
||||
|
||||
m_instance = this;
|
||||
|
||||
m_settings.fromSettings(ICore::settings());
|
||||
|
@@ -32,10 +32,10 @@
|
||||
#include "customwizardpreprocessor.h"
|
||||
#include "customwizardscriptgenerator.h"
|
||||
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <cpptools/cpptoolsconstants.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -917,10 +917,13 @@ void CustomWizardContext::reset()
|
||||
const QDate currentDate = QDate::currentDate();
|
||||
const QTime currentTime = QTime::currentTime();
|
||||
baseReplacements.clear();
|
||||
Utils::MimeDatabase mdb;
|
||||
baseReplacements.insert(QLatin1String("CppSourceSuffix"),
|
||||
MimeDatabase::preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE)));
|
||||
mdb.mimeTypeForName(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE))
|
||||
.preferredSuffix());
|
||||
baseReplacements.insert(QLatin1String("CppHeaderSuffix"),
|
||||
MimeDatabase::preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE)));
|
||||
mdb.mimeTypeForName(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE))
|
||||
.preferredSuffix());
|
||||
baseReplacements.insert(QLatin1String("CurrentDate"),
|
||||
currentDate.toString(Qt::ISODate));
|
||||
baseReplacements.insert(QLatin1String("CurrentTime"),
|
||||
|
@@ -37,12 +37,12 @@
|
||||
#include "../projectexplorer.h"
|
||||
|
||||
#include <coreplugin/featureprovider.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -102,11 +102,12 @@ void JsonKitsPage::setupProjectFiles(const JsonWizard::GeneratorFiles &files)
|
||||
if (fi.exists())
|
||||
path = fi.canonicalFilePath();
|
||||
|
||||
Core::MimeType mt = Core::MimeDatabase::findByFile(fi);
|
||||
if (mt.isNull())
|
||||
Utils::MimeDatabase mdb;
|
||||
Utils::MimeType mt = mdb.mimeTypeForFile(fi);
|
||||
if (!mt.isValid())
|
||||
continue;
|
||||
|
||||
auto manager = Utils::findOrDefault(managerList, Utils::equal(&IProjectManager::mimeType, mt.type()));
|
||||
auto manager = Utils::findOrDefault(managerList, Utils::equal(&IProjectManager::mimeType, mt.name()));
|
||||
project = manager ? manager->openProject(path, &errorMessage) : 0;
|
||||
if (project) {
|
||||
if (setupProject(project))
|
||||
|
@@ -38,7 +38,6 @@
|
||||
#include "../projectexplorerconstants.h"
|
||||
|
||||
#include <coreplugin/dialogs/promptoverwritedialog.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <texteditor/icodestylepreferences.h>
|
||||
#include <texteditor/icodestylepreferencesfactory.h>
|
||||
#include <texteditor/indenter.h>
|
||||
@@ -48,6 +47,7 @@
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -90,8 +90,8 @@ bool JsonWizardGenerator::formatFile(const JsonWizard *wizard, GeneratedFile *fi
|
||||
if (file->isBinary() || file->contents().isEmpty())
|
||||
return true; // nothing to do
|
||||
|
||||
MimeType mt = MimeDatabase::findByFile(QFileInfo(file->path()));
|
||||
Id languageId = TextEditorSettings::languageId(mt.type());
|
||||
Utils::MimeDatabase mdb;
|
||||
Id languageId = TextEditorSettings::languageId(mdb.mimeTypeForFile(file->path()).name());
|
||||
|
||||
if (!languageId.isValid())
|
||||
return true; // don't modify files like *.ui, *.pro
|
||||
|
@@ -111,7 +111,6 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/imode.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
@@ -128,6 +127,7 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
@@ -1337,7 +1337,7 @@ void ProjectExplorerPlugin::extensionsInitialized()
|
||||
QList<IProjectManager*> projectManagers =
|
||||
ExtensionSystem::PluginManager::getObjects<IProjectManager>();
|
||||
|
||||
QList<MimeGlobPattern> allGlobPatterns;
|
||||
QStringList allGlobPatterns;
|
||||
|
||||
const QString filterSeparator = QLatin1String(";;");
|
||||
QStringList filterStrings;
|
||||
@@ -1352,10 +1352,11 @@ void ProjectExplorerPlugin::extensionsInitialized()
|
||||
return 0;
|
||||
});
|
||||
|
||||
Utils::MimeDatabase mdb;
|
||||
foreach (IProjectManager *manager, projectManagers) {
|
||||
const QString mimeType = manager->mimeType();
|
||||
factory->addMimeType(mimeType);
|
||||
MimeType mime = MimeDatabase::findByType(mimeType);
|
||||
Utils::MimeType mime = mdb.mimeTypeForName(mimeType);
|
||||
allGlobPatterns.append(mime.globPatterns());
|
||||
filterStrings.append(mime.filterString());
|
||||
|
||||
@@ -1364,8 +1365,10 @@ void ProjectExplorerPlugin::extensionsInitialized()
|
||||
|
||||
addAutoReleasedObject(factory);
|
||||
|
||||
filterStrings.prepend(MimeType::formatFilterString(
|
||||
tr("All Projects"), allGlobPatterns));
|
||||
QString allProjectsFilter = tr("All Projects");
|
||||
allProjectsFilter += QLatin1String(" (") + allGlobPatterns.join(QLatin1Char(' '))
|
||||
+ QLatin1Char(')');
|
||||
filterStrings.prepend(allProjectsFilter);
|
||||
dd->m_projectFilterString = filterStrings.join(filterSeparator);
|
||||
|
||||
BuildManager::extensionsInitialized();
|
||||
@@ -1573,10 +1576,12 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
|
||||
continue;
|
||||
}
|
||||
|
||||
if (const MimeType mt = MimeDatabase::findByFile(QFileInfo(fileName))) {
|
||||
Utils::MimeDatabase mdb;
|
||||
Utils::MimeType mt = mdb.mimeTypeForFile(fileName);
|
||||
if (mt.isValid()) {
|
||||
bool foundProjectManager = false;
|
||||
foreach (IProjectManager *manager, projectManagers) {
|
||||
if (manager->mimeType() == mt.type()) {
|
||||
if (mt.matchesName(manager->mimeType())) {
|
||||
foundProjectManager = true;
|
||||
QString tmp;
|
||||
if (Project *pro = manager->openProject(filePath, &tmp)) {
|
||||
@@ -1598,7 +1603,7 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
|
||||
if (!foundProjectManager) {
|
||||
appendError(errorString, tr("Failed opening project \"%1\": No plugin can open project type \"%2\".")
|
||||
.arg(QDir::toNativeSeparators(fileName))
|
||||
.arg((mt.type())));
|
||||
.arg(mt.name()));
|
||||
}
|
||||
} else {
|
||||
appendError(errorString, tr("Failed opening project \"%1\": Unknown project type.")
|
||||
@@ -1666,11 +1671,13 @@ void ProjectExplorerPlugin::determineSessionToRestoreAtStartup()
|
||||
QStringList ProjectExplorerPlugin::projectFileGlobs()
|
||||
{
|
||||
QStringList result;
|
||||
Utils::MimeDatabase mdb;
|
||||
foreach (const IProjectManager *ipm, ExtensionSystem::PluginManager::getObjects<IProjectManager>()) {
|
||||
if (const MimeType mimeType = MimeDatabase::findByType(ipm->mimeType())) {
|
||||
const QList<MimeGlobPattern> patterns = mimeType.globPatterns();
|
||||
Utils::MimeType mimeType = mdb.mimeTypeForName(ipm->mimeType());
|
||||
if (mimeType.isValid()) {
|
||||
const QStringList patterns = mimeType.globPatterns();
|
||||
if (!patterns.isEmpty())
|
||||
result.push_back(patterns.front().pattern());
|
||||
result.append(patterns.front());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -3122,10 +3129,12 @@ ProjectExplorerSettings ProjectExplorerPlugin::projectExplorerSettings()
|
||||
QStringList ProjectExplorerPlugin::projectFilePatterns()
|
||||
{
|
||||
QStringList patterns;
|
||||
foreach (const IProjectManager *pm, allProjectManagers())
|
||||
if (const MimeType mt = MimeDatabase::findByType(pm->mimeType()))
|
||||
foreach (const MimeGlobPattern &gp, mt.globPatterns())
|
||||
patterns.append(gp.pattern());
|
||||
Utils::MimeDatabase mdb;
|
||||
foreach (const IProjectManager *pm, allProjectManagers()) {
|
||||
Utils::MimeType mt = mdb.mimeTypeForName(pm->mimeType());
|
||||
if (mt.isValid())
|
||||
patterns.append(mt.globPatterns());
|
||||
}
|
||||
return patterns;
|
||||
}
|
||||
|
||||
|
@@ -171,7 +171,7 @@ const char C_SOURCE_MIMETYPE[] = "text/x-csrc";
|
||||
const char C_HEADER_MIMETYPE[] = "text/x-chdr";
|
||||
const char CPP_SOURCE_MIMETYPE[] = "text/x-c++src";
|
||||
const char CPP_HEADER_MIMETYPE[] = "text/x-c++hdr";
|
||||
const char LINGUIST_MIMETYPE[] = "application/x-linguist";
|
||||
const char LINGUIST_MIMETYPE[] = "text/vnd.trolltech.linguist";
|
||||
const char FORM_MIMETYPE[] = "application/x-designer";
|
||||
const char QML_MIMETYPE[] = "application/x-qml"; // separate def also in qmljstoolsconstants.h
|
||||
const char RESOURCE_MIMETYPE[] = "application/vnd.qt.xml.resource";
|
||||
|
@@ -39,7 +39,6 @@
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/icodestylepreferences.h>
|
||||
#include <texteditor/icodestylepreferencesfactory.h>
|
||||
@@ -48,7 +47,8 @@
|
||||
#include <texteditor/storagesettings.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/editorconfiguration.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#
|
||||
#include <QPointer>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
@@ -230,8 +230,8 @@ void ProjectFileWizardExtension::applyCodeStyle(GeneratedFile *file) const
|
||||
if (file->isBinary() || file->contents().isEmpty())
|
||||
return; // nothing to do
|
||||
|
||||
MimeType mt = MimeDatabase::findByFile(QFileInfo(file->path()));
|
||||
Id languageId = TextEditorSettings::languageId(mt.type());
|
||||
Utils::MimeDatabase mdb;
|
||||
Id languageId = TextEditorSettings::languageId(mdb.mimeTypeForFile(file->path()).name());
|
||||
|
||||
if (!languageId.isValid())
|
||||
return; // don't modify files like *.ui *.pro
|
||||
|
@@ -34,7 +34,6 @@
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "projecttree.h"
|
||||
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/fileiconprovider.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/iversioncontrol.h>
|
||||
|
@@ -45,8 +45,6 @@ QT_BEGIN_NAMESPACE
|
||||
class QFileInfo;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core { class MimeDatabase; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class RunConfiguration;
|
||||
|
||||
|
@@ -1,10 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="text/x-python">
|
||||
<sub-class-of type="text/plain"/>
|
||||
<comment>Python Source File</comment>
|
||||
<glob pattern="*.py"/>
|
||||
<mime-type type="text/x-python-gui">
|
||||
<sub-class-of type="text/x-python"/>
|
||||
<comment>Python source file without console</comment>
|
||||
<glob pattern="*.pyw"/>
|
||||
<glob pattern="*.wsgi"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
||||
|
@@ -44,7 +44,6 @@ const char C_EDITOR_DISPLAY_NAME[] =
|
||||
* MIME type
|
||||
******************************************************************************/
|
||||
const char C_PY_MIMETYPE[] = "text/x-python";
|
||||
const char RC_PY_MIME_XML[] = ":/pythoneditor/PythonEditor.mimetypes.xml";
|
||||
const char C_PY_MIME_ICON[] = "text-x-python";
|
||||
|
||||
} // namespace Constants
|
||||
|
@@ -35,12 +35,12 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/fileiconprovider.h>
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QCoreApplication>
|
||||
@@ -209,9 +209,9 @@ PythonEditorPlugin::~PythonEditorPlugin()
|
||||
bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(RC_PY_MIME_XML), errorMessage))
|
||||
return false;
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/pythoneditor/PythonEditor.mimetypes.xml"));
|
||||
|
||||
addAutoReleasedObject(new PythonEditorFactory);
|
||||
|
||||
|
@@ -40,7 +40,6 @@
|
||||
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
@@ -49,6 +48,7 @@
|
||||
#include <projectexplorer/projectmacroexpander.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -397,8 +397,10 @@ QList<BuildInfo *> QbsBuildConfigurationFactory::availableBuilds(const Target *p
|
||||
|
||||
int QbsBuildConfigurationFactory::priority(const Kit *k, const QString &projectPath) const
|
||||
{
|
||||
return (k && Core::MimeDatabase::findByFile(QFileInfo(projectPath))
|
||||
.matchesType(QLatin1String(Constants::MIME_TYPE))) ? 0 : -1;
|
||||
Utils::MimeDatabase mdb;
|
||||
if (k && mdb.mimeTypeForFile(projectPath).matchesName(QLatin1String(Constants::MIME_TYPE)))
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static Utils::FileName defaultBuildDirectory(const QString &projectFilePath, const Kit *k,
|
||||
|
@@ -46,7 +46,6 @@
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <projectexplorer/buildenvironmentwidget.h>
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
|
@@ -41,7 +41,6 @@
|
||||
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/kit.h>
|
||||
@@ -52,6 +51,7 @@
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -687,8 +687,10 @@ QList<BuildInfo *> QmakeBuildConfigurationFactory::availableBuilds(const Target
|
||||
|
||||
int QmakeBuildConfigurationFactory::priority(const Kit *k, const QString &projectPath) const
|
||||
{
|
||||
return (k && Core::MimeDatabase::findByFile(QFileInfo(projectPath))
|
||||
.matchesType(QLatin1String(Constants::PROFILE_MIMETYPE))) ? 0 : -1;
|
||||
Utils::MimeDatabase mdb;
|
||||
if (k && mdb.mimeTypeForFile(projectPath).matchesName(QLatin1String(Constants::PROFILE_MIMETYPE)))
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
QList<BuildInfo *> QmakeBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const
|
||||
|
@@ -63,6 +63,7 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/theme/theme.h>
|
||||
#include <proparser/prowriter.h>
|
||||
@@ -1033,9 +1034,10 @@ bool QmakePriFileNode::addFiles(const QStringList &filePaths, QStringList *notAd
|
||||
typedef QMap<QString, QStringList> TypeFileMap;
|
||||
// Split into lists by file type and bulk-add them.
|
||||
TypeFileMap typeFileMap;
|
||||
Utils::MimeDatabase mdb;
|
||||
foreach (const QString &file, filePaths) {
|
||||
const Core::MimeType mt = Core::MimeDatabase::findByFile(file);
|
||||
typeFileMap[mt.type()] << file;
|
||||
const Utils::MimeType mt = mdb.mimeTypeForFile(file);
|
||||
typeFileMap[mt.name()] << file;
|
||||
}
|
||||
|
||||
QStringList failedFiles;
|
||||
@@ -1080,9 +1082,10 @@ bool QmakePriFileNode::removeFiles(const QStringList &filePaths,
|
||||
typedef QMap<QString, QStringList> TypeFileMap;
|
||||
// Split into lists by file type and bulk-add them.
|
||||
TypeFileMap typeFileMap;
|
||||
Utils::MimeDatabase mdb;
|
||||
foreach (const QString &file, filePaths) {
|
||||
const Core::MimeType mt = Core::MimeDatabase::findByFile(file);
|
||||
typeFileMap[mt.type()] << file;
|
||||
const Utils::MimeType mt = mdb.mimeTypeForFile(file);
|
||||
typeFileMap[mt.name()] << file;
|
||||
}
|
||||
foreach (const QString &type, typeFileMap.keys()) {
|
||||
const QStringList typeFiles = typeFileMap.value(type);
|
||||
@@ -1105,13 +1108,14 @@ bool QmakePriFileNode::renameFile(const QString &filePath, const QString &newFil
|
||||
return false;
|
||||
|
||||
bool changeProFileOptional = deploysFolder(QFileInfo(filePath).absolutePath());
|
||||
const Core::MimeType mt = Core::MimeDatabase::findByFile(newFilePath);
|
||||
Utils::MimeDatabase mdb;
|
||||
const Utils::MimeType mt = mdb.mimeTypeForFile(newFilePath);
|
||||
QStringList dummy;
|
||||
|
||||
changeFiles(mt.type(), QStringList() << filePath, &dummy, RemoveFromProFile);
|
||||
changeFiles(mt.name(), QStringList() << filePath, &dummy, RemoveFromProFile);
|
||||
if (!dummy.isEmpty() && !changeProFileOptional)
|
||||
return false;
|
||||
changeFiles(mt.type(), QStringList() << newFilePath, &dummy, AddToProFile);
|
||||
changeFiles(mt.name(), QStringList() << newFilePath, &dummy, AddToProFile);
|
||||
if (!dummy.isEmpty() && !changeProFileOptional)
|
||||
return false;
|
||||
return true;
|
||||
|
@@ -55,7 +55,6 @@
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
@@ -64,6 +63,7 @@
|
||||
#include <texteditor/texteditoractionhandler.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/parameteraction.h>
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
@@ -94,11 +94,11 @@ QmakeProjectManagerPlugin::~QmakeProjectManagerPlugin()
|
||||
bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorMessage)
|
||||
const Core::Context projectContext(QmakeProjectManager::Constants::PROJECT_ID);
|
||||
Core::Context projecTreeContext(ProjectExplorer::Constants::C_PROJECT_TREE);
|
||||
|
||||
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":qmakeprojectmanager/QmakeProjectManager.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":qmakeprojectmanager/QmakeProjectManager.mimetypes.xml"));
|
||||
|
||||
//create and register objects
|
||||
m_qmakeProjectManager = new QmakeManager;
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<alias type="text/x-qml"/>
|
||||
<sub-class-of type="text/plain"/>
|
||||
<comment>QML file</comment>
|
||||
<glob weight="50" pattern="*.qml"/>
|
||||
<glob pattern="*.qml"/>
|
||||
</mime-type>
|
||||
<mime-type type="application/x-qt.qbs+qml">
|
||||
<alias type="text/x-qt.qbs+qml"/>
|
||||
@@ -16,7 +16,7 @@
|
||||
<alias type="text/x-qt.ui+qml"/>
|
||||
<sub-class-of type="application/x-qml"/>
|
||||
<comment>QtQuick Designer ui file</comment>
|
||||
<glob weight="100" pattern="*.ui.qml"/>
|
||||
<glob pattern="*.ui.qml"/>
|
||||
</mime-type>
|
||||
<mime-type type="application/x-qmlproject">
|
||||
<alias type="text/x-qmlproject"/>
|
||||
@@ -30,16 +30,6 @@
|
||||
<comment>QML file</comment>
|
||||
<glob pattern="*.qmltypes"/>
|
||||
</mime-type>
|
||||
<mime-type type="application/javascript">
|
||||
<alias type="application/x-javascript"/>
|
||||
<alias type="text/javascript"/>
|
||||
<alias type="text/x-javascript"/>
|
||||
<sub-class-of type="text/plain"/>
|
||||
<comment>Qt Script file</comment>
|
||||
<glob pattern="*.js"/>
|
||||
<glob pattern="*.qs"/>
|
||||
<glob pattern="*.qtt"/>
|
||||
</mime-type>
|
||||
<mime-type type="application/json">
|
||||
<sub-class-of type="text/plain"/>
|
||||
<comment>JSON file</comment>
|
||||
|
@@ -52,6 +52,7 @@
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@@ -76,22 +77,18 @@ ModelManagerInterface::ProjectInfo QmlJSTools::Internal::ModelManager::defaultPr
|
||||
ModelManagerInterface::ProjectInfo projectInfo(project);
|
||||
ProjectExplorer::Target *activeTarget = 0;
|
||||
if (project) {
|
||||
QList<MimeGlobPattern> globs;
|
||||
foreach (const MimeType &mimeType, MimeDatabase::mimeTypes())
|
||||
if (mimeType.type() == QLatin1String(Constants::QML_MIMETYPE)
|
||||
|| mimeType.subClassesOf().contains(QLatin1String(Constants::QML_MIMETYPE)))
|
||||
globs << mimeType.globPatterns();
|
||||
if (globs.isEmpty()) {
|
||||
globs.append(MimeGlobPattern(QLatin1String("*.qbs")));
|
||||
globs.append(MimeGlobPattern(QLatin1String("*.qml")));
|
||||
globs.append(MimeGlobPattern(QLatin1String("*.qmltypes")));
|
||||
globs.append(MimeGlobPattern(QLatin1String("*.qmlproject")));
|
||||
Utils::MimeDatabase mdb;
|
||||
QList<Utils::MimeType> qmlTypes;
|
||||
foreach (const Utils::MimeType &mimeType, mdb.allMimeTypes()) {
|
||||
if (mimeType.matchesName(QLatin1String(Constants::QML_MIMETYPE))
|
||||
|| mimeType.allAncestors().contains(QLatin1String(Constants::QML_MIMETYPE)))
|
||||
qmlTypes.append(mimeType);
|
||||
}
|
||||
foreach (const QString &filePath,
|
||||
project->files(ProjectExplorer::Project::ExcludeGeneratedFiles))
|
||||
foreach (const MimeGlobPattern &glob, globs)
|
||||
if (glob.matches(filePath))
|
||||
project->files(ProjectExplorer::Project::ExcludeGeneratedFiles)) {
|
||||
if (mdb.bestMatch(filePath, qmlTypes).isValid())
|
||||
projectInfo.sourceFiles << filePath;
|
||||
}
|
||||
activeTarget = project->activeTarget();
|
||||
}
|
||||
ProjectExplorer::Kit *activeKit = activeTarget ? activeTarget->kit() :
|
||||
@@ -179,22 +176,23 @@ QHash<QString,QmlJS::Dialect> ModelManager::languageForSuffix() const
|
||||
QHash<QString,QmlJS::Dialect> res = ModelManagerInterface::languageForSuffix();
|
||||
|
||||
if (ICore::instance()) {
|
||||
MimeType jsSourceTy = MimeDatabase::findByType(QLatin1String(Constants::JS_MIMETYPE));
|
||||
Utils::MimeDatabase mdb;
|
||||
Utils::MimeType jsSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::JS_MIMETYPE));
|
||||
foreach (const QString &suffix, jsSourceTy.suffixes())
|
||||
res[suffix] = Dialect::JavaScript;
|
||||
MimeType qmlSourceTy = MimeDatabase::findByType(QLatin1String(Constants::QML_MIMETYPE));
|
||||
Utils::MimeType qmlSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QML_MIMETYPE));
|
||||
foreach (const QString &suffix, qmlSourceTy.suffixes())
|
||||
res[suffix] = Dialect::Qml;
|
||||
MimeType qbsSourceTy = MimeDatabase::findByType(QLatin1String(Constants::QBS_MIMETYPE));
|
||||
Utils::MimeType qbsSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QBS_MIMETYPE));
|
||||
foreach (const QString &suffix, qbsSourceTy.suffixes())
|
||||
res[suffix] = Dialect::QmlQbs;
|
||||
MimeType qmlProjectSourceTy = MimeDatabase::findByType(QLatin1String(Constants::QMLPROJECT_MIMETYPE));
|
||||
Utils::MimeType qmlProjectSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QMLPROJECT_MIMETYPE));
|
||||
foreach (const QString &suffix, qmlProjectSourceTy.suffixes())
|
||||
res[suffix] = Dialect::QmlProject;
|
||||
MimeType qmlUiSourceTy = MimeDatabase::findByType(QLatin1String(Constants::QMLUI_MIMETYPE));
|
||||
Utils::MimeType qmlUiSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QMLUI_MIMETYPE));
|
||||
foreach (const QString &suffix, qmlUiSourceTy.suffixes())
|
||||
res[suffix] = Dialect::QmlQtQuick2Ui;
|
||||
MimeType jsonSourceTy = MimeDatabase::findByType(QLatin1String(Constants::JSON_MIMETYPE));
|
||||
Utils::MimeType jsonSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::JSON_MIMETYPE));
|
||||
foreach (const QString &suffix, jsonSourceTy.suffixes())
|
||||
res[suffix] = Dialect::Json;
|
||||
}
|
||||
@@ -269,23 +267,6 @@ void ModelManager::updateDefaultProjectInfo()
|
||||
}
|
||||
|
||||
|
||||
// Check whether fileMimeType is the same or extends knownMimeType
|
||||
bool ModelManager::matchesMimeType(const MimeType &fileMimeType, const MimeType &knownMimeType)
|
||||
{
|
||||
const QStringList knownTypeNames = QStringList(knownMimeType.type()) + knownMimeType.aliases();
|
||||
|
||||
foreach (const QString &knownTypeName, knownTypeNames)
|
||||
if (fileMimeType.matchesType(knownTypeName))
|
||||
return true;
|
||||
|
||||
// recursion to parent types of fileMimeType
|
||||
foreach (const QString &parentMimeType, fileMimeType.subClassesOf())
|
||||
if (matchesMimeType(MimeDatabase::findByType(parentMimeType), knownMimeType))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ModelManager::addTaskInternal(QFuture<void> result, const QString &msg, const char *taskId) const
|
||||
{
|
||||
ProgressManager::addTask(result, msg, taskId);
|
||||
|
@@ -46,7 +46,7 @@
|
||||
QT_FORWARD_DECLARE_CLASS(QTimer)
|
||||
QT_FORWARD_DECLARE_CLASS(QLocale)
|
||||
|
||||
namespace Core { class MimeType; }
|
||||
namespace Utils { class MimeType; }
|
||||
|
||||
namespace QmlJSTools {
|
||||
namespace Internal {
|
||||
@@ -70,7 +70,6 @@ private slots:
|
||||
void updateDefaultProjectInfo();
|
||||
private:
|
||||
void loadDefaultQmlTypeDescriptions();
|
||||
static bool matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -42,8 +42,8 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QMenu>
|
||||
@@ -72,9 +72,9 @@ QmlJSToolsPlugin::~QmlJSToolsPlugin()
|
||||
bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(error)
|
||||
|
||||
if (!MimeDatabase::addMimeTypes(QLatin1String(":/qmljstools/QmlJSTools.mimetypes.xml"), error))
|
||||
return false;
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/qmljstools/QmlJSTools.mimetypes.xml"));
|
||||
|
||||
m_settings = new QmlJSToolsSettings(this); // force registration of qmljstools settings
|
||||
|
||||
|
@@ -37,10 +37,11 @@
|
||||
|
||||
#include <coreplugin/fileiconprovider.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
#include <QApplication>
|
||||
@@ -58,18 +59,14 @@ QmlProjectPlugin::~QmlProjectPlugin()
|
||||
|
||||
bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
|
||||
{
|
||||
using namespace Core;
|
||||
|
||||
const QLatin1String mimetypesXml(":/qmlproject/QmlProjectManager.mimetypes.xml");
|
||||
|
||||
if (!MimeDatabase::addMimeTypes(mimetypesXml, errorMessage))
|
||||
return false;
|
||||
Q_UNUSED(errorMessage)
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/qmlproject/QmlProjectManager.mimetypes.xml"));
|
||||
|
||||
addAutoReleasedObject(new Internal::Manager);
|
||||
addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory);
|
||||
addAutoReleasedObject(new Internal::QmlApplicationWizard);
|
||||
|
||||
FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png", "qmlproject");
|
||||
Core::FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png", "qmlproject");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,6 @@
|
||||
#include "qmlprojectmanagerconstants.h"
|
||||
#include "qmlprojectrunconfigurationwidget.h"
|
||||
#include "qmlprojectenvironmentaspect.h"
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -43,6 +42,7 @@
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/winutils.h>
|
||||
|
||||
@@ -264,22 +264,23 @@ void QmlProjectRunConfiguration::changeCurrentFile(IEditor *editor)
|
||||
void QmlProjectRunConfiguration::updateEnabled()
|
||||
{
|
||||
bool qmlFileFound = false;
|
||||
Utils::MimeDatabase mdb;
|
||||
if (mainScriptSource() == FileInEditor) {
|
||||
IDocument *document = EditorManager::currentDocument();
|
||||
if (document) {
|
||||
m_currentFileFilename = document->filePath().toString();
|
||||
if (MimeDatabase::findByFile(mainScript()).type() == QLatin1String("application/x-qml"))
|
||||
if (mdb.mimeTypeForFile(mainScript()).matchesName(QLatin1String("application/x-qml")))
|
||||
qmlFileFound = true;
|
||||
}
|
||||
if (!document
|
||||
|| MimeDatabase::findByFile(mainScript()).type() == QLatin1String("application/x-qmlproject")) {
|
||||
|| mdb.mimeTypeForFile(mainScript()).matchesName(QLatin1String("application/x-qmlproject"))) {
|
||||
// find a qml file with lowercase filename. This is slow, but only done
|
||||
// in initialization/other border cases.
|
||||
foreach (const QString &filename, target()->project()->files(Project::AllFiles)) {
|
||||
const QFileInfo fi(filename);
|
||||
|
||||
if (!filename.isEmpty() && fi.baseName()[0].isLower()
|
||||
&& MimeDatabase::findByFile(fi).type() == QLatin1String("application/x-qml"))
|
||||
&& mdb.mimeTypeForFile(fi).matchesName(QLatin1String("application/x-qml")))
|
||||
{
|
||||
m_currentFileFilename = filename;
|
||||
qmlFileFound = true;
|
||||
|
11
src/plugins/qnx/Qnx.mimetypes.xml
Normal file
11
src/plugins/qnx/Qnx.mimetypes.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="application/vnd.rim.qnx.bar_descriptor">
|
||||
<comment>BAR descriptor file (BlackBerry)</comment>
|
||||
<sub-class-of type="application/xml"/>
|
||||
<glob pattern="*.xml"/>
|
||||
<magic>
|
||||
<match value="<qnx>" type="string" offset="0:1000"/>
|
||||
</magic>
|
||||
</mime-type>
|
||||
</mime-info>
|
@@ -1,56 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 BlackBerry Limited. All rights reserved.
|
||||
**
|
||||
** Contact: BlackBerry (qt@blackberry.com)
|
||||
** Contact: KDAB (info@kdab.com)
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "bardescriptormagicmatcher.h"
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
using namespace Qnx;
|
||||
using namespace Qnx::Internal;
|
||||
|
||||
BarDescriptorMagicMatcher::BarDescriptorMagicMatcher()
|
||||
{
|
||||
}
|
||||
|
||||
bool BarDescriptorMagicMatcher::matches(const QByteArray &data) const
|
||||
{
|
||||
QXmlStreamReader reader(data);
|
||||
if (reader.readNextStartElement())
|
||||
return reader.name() == QLatin1String("qnx");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int BarDescriptorMagicMatcher::priority() const
|
||||
{
|
||||
return Core::MimeGlobPattern::MaxWeight;
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 BlackBerry Limited. All rights reserved.
|
||||
**
|
||||
** Contact: BlackBerry (qt@blackberry.com)
|
||||
** Contact: KDAB (info@kdab.com)
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNX_INTERNAL_BARDESCRIPTORMAGICMATCHER_H
|
||||
#define QNX_INTERNAL_BARDESCRIPTORMAGICMATCHER_H
|
||||
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class BarDescriptorMagicMatcher : public Core::IMagicMatcher
|
||||
{
|
||||
public:
|
||||
BarDescriptorMagicMatcher();
|
||||
|
||||
bool matches(const QByteArray &data) const;
|
||||
int priority() const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_INTERNAL_BARDESCRIPTORMAGICMATCHER_H
|
@@ -50,7 +50,6 @@ SOURCES += qnxplugin.cpp \
|
||||
blackberryabstractdeploystep.cpp \
|
||||
blackberryndksettingswidget.cpp \
|
||||
blackberryndksettingspage.cpp \
|
||||
bardescriptormagicmatcher.cpp \
|
||||
bardescriptoreditorfactory.cpp \
|
||||
bardescriptoreditor.cpp \
|
||||
bardescriptoreditorwidget.cpp \
|
||||
@@ -161,7 +160,6 @@ HEADERS += qnxplugin.h\
|
||||
blackberryabstractdeploystep.h \
|
||||
blackberryndksettingswidget.h \
|
||||
blackberryndksettingspage.h \
|
||||
bardescriptormagicmatcher.h \
|
||||
bardescriptoreditorfactory.h \
|
||||
bardescriptoreditor.h \
|
||||
bardescriptoreditorwidget.h \
|
||||
|
@@ -4,6 +4,6 @@
|
||||
<file>images/target.png</file>
|
||||
<file>images/ok.png</file>
|
||||
<file>images/qnx-target.png</file>
|
||||
<file>Qnx.mimetypes.xml</file>
|
||||
</qresource>
|
||||
<qresource prefix="/"/>
|
||||
</RCC>
|
||||
|
@@ -51,7 +51,6 @@
|
||||
#include "blackberryndksettingspage.h"
|
||||
#include "qnxsettingspage.h"
|
||||
#include "bardescriptoreditorfactory.h"
|
||||
#include "bardescriptormagicmatcher.h"
|
||||
#include "blackberrykeyspage.h"
|
||||
#include "blackberrycheckdevicestatusstepfactory.h"
|
||||
#include "blackberrydeviceconnectionmanager.h"
|
||||
@@ -68,12 +67,12 @@
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QtPlugin>
|
||||
@@ -128,19 +127,8 @@ bool QnxPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
// Handle Qcc Compiler
|
||||
addAutoReleasedObject(new QnxToolChainFactory);
|
||||
|
||||
// bar-descriptor.xml editor
|
||||
Core::MimeGlobPattern barDescriptorGlobPattern(QLatin1String("*.xml"), Core::MimeGlobPattern::MinWeight + 1);
|
||||
Core::MimeType barDescriptorMimeType;
|
||||
barDescriptorMimeType.setType(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE));
|
||||
barDescriptorMimeType.setComment(tr("BAR descriptor file (BlackBerry)"));
|
||||
barDescriptorMimeType.setGlobPatterns(QList<Core::MimeGlobPattern>() << barDescriptorGlobPattern);
|
||||
barDescriptorMimeType.addMagicMatcher(QSharedPointer<Core::IMagicMatcher>(new BarDescriptorMagicMatcher));
|
||||
barDescriptorMimeType.setSubClassesOf(QStringList() << QLatin1String("application/xml"));
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":qnx/Qnx.mimetypes.xml"));
|
||||
|
||||
if (!Core::MimeDatabase::addMimeType(barDescriptorMimeType)) {
|
||||
*errorString = tr("Could not add MIME type for bar-descriptor.xml editor.");
|
||||
return false;
|
||||
}
|
||||
addAutoReleasedObject(new BarDescriptorEditorFactory);
|
||||
|
||||
connect(KitManager::instance(), SIGNAL(kitsLoaded()),
|
||||
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="application/x-linguist">
|
||||
<sub-class-of type="application/xml"/>
|
||||
<comment>message catalog</comment>
|
||||
<glob pattern="*.ts"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
@@ -8,6 +8,5 @@
|
||||
<file>images/dark_qml.png</file>
|
||||
<file>images/dark_qt_project.png</file>
|
||||
<file>images/dark_qt_qrc.png</file>
|
||||
<file>QtSupport.mimetypes.xml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@@ -45,7 +45,6 @@
|
||||
#include "profilereader.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/jsexpander.h>
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
@@ -70,9 +69,6 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes
|
||||
ProFileEvaluator::initialize();
|
||||
new ProFileCacheManager(this);
|
||||
|
||||
if (!MimeDatabase::addMimeTypes(QLatin1String(":qtsupport/QtSupport.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
|
||||
JsExpander::registerQObjectForJs(QLatin1String("QtSupport"), new CodeGenerator);
|
||||
|
||||
addAutoReleasedObject(new QtVersionManager);
|
||||
|
@@ -36,7 +36,6 @@
|
||||
#include "resourcenode.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/id.h>
|
||||
@@ -50,6 +49,7 @@
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -124,14 +124,12 @@ ResourceEditorPlugin::ResourceEditorPlugin() :
|
||||
bool ResourceEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":/resourceeditor/ResourceEditor.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
Q_UNUSED(errorMessage)
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/resourceeditor/ResourceEditor.mimetypes.xml"));
|
||||
|
||||
ResourceEditorFactory *editor = new ResourceEditorFactory(this);
|
||||
addAutoReleasedObject(editor);
|
||||
|
||||
errorMessage->clear();
|
||||
|
||||
// Register undo and redo
|
||||
const Core::Context context(Constants::C_RESOURCEEDITOR);
|
||||
m_undoAction = new QAction(tr("&Undo"), this);
|
||||
|
@@ -36,10 +36,11 @@
|
||||
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/fileiconprovider.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
@@ -51,8 +52,8 @@ static bool priority(const QStringList &files)
|
||||
{
|
||||
if (files.isEmpty())
|
||||
return false;
|
||||
Core::MimeType mt = Core::MimeDatabase::findByFile(files.at(0));
|
||||
QString type = mt.type();
|
||||
Utils::MimeDatabase mdb;
|
||||
QString type = mdb.mimeTypeForFile(files.at(0)).name();
|
||||
if (type.startsWith(QLatin1String("image/"))
|
||||
|| type == QLatin1String(QmlJSTools::Constants::QML_MIMETYPE)
|
||||
|| type == QLatin1String(QmlJSTools::Constants::JS_MIMETYPE))
|
||||
|
@@ -57,10 +57,10 @@
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/locator/commandlocator.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
@@ -233,6 +233,7 @@ const VcsBaseSubmitEditorParameters submitParameters = {
|
||||
|
||||
bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
using namespace Constants;
|
||||
using namespace Core::Constants;
|
||||
|
||||
@@ -242,8 +243,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
||||
|
||||
m_subversionPluginInstance = this;
|
||||
|
||||
if (!MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.subversion/Subversion.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.subversion/Subversion.mimetypes.xml"));
|
||||
|
||||
m_settings.readSettings(ICore::settings());
|
||||
m_client = new SubversionClient(&m_settings);
|
||||
|
@@ -37,12 +37,12 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocumentfactory.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/task.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
@@ -199,12 +199,12 @@ TaskListPlugin::TaskListPlugin()
|
||||
bool TaskListPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
//: Category under which tasklist tasks are listed in Issues view
|
||||
TaskHub::addCategory(Constants::TASKLISTTASK_ID, tr("My Tasks"));
|
||||
|
||||
if (!MimeDatabase::addMimeTypes(QLatin1String(":tasklist/TaskList.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
Utils::MimeDatabase::addMimeTypes(QLatin1String(":tasklist/TaskList.mimetypes.xml"));
|
||||
|
||||
m_fileFactory = new IDocumentFactory;
|
||||
m_fileFactory->addMimeType(QLatin1String("text/x-tasklist"));
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user