Commit 6f768813 authored by Elvis Angelaccio's avatar Elvis Angelaccio

Merge branch 'Applications/16.04'

This adapts the patch in D1725 to our new PluginManager class.

CCBUG: 363717
parents c369264d 8b9cd300
......@@ -154,6 +154,12 @@ void ArchiveTest::testProperties_data()
<< QStringLiteral("simplearchive")
<< true << false << false << Archive::Unencrypted
<< QStringLiteral("simplearchive");
QTest::newRow("mimetype child of application/zip")
<< QFINDTESTDATA("data/test.odt")
<< QStringLiteral("test")
<< false << true << false << Archive::Unencrypted
<< QStringLiteral("test");
}
void ArchiveTest::testProperties()
......
......@@ -137,11 +137,19 @@ QStringList PluginManager::supportedWriteMimeTypes() const
return sortByComment(supported);
}
QVector<Plugin*> PluginManager::filterBy(const QVector<Plugin*> &plugins, const QMimeType &mimeType)
QVector<Plugin*> PluginManager::filterBy(const QVector<Plugin*> &plugins, const QMimeType &mimeType) const
{
const bool supportedMime = supportedMimeTypes().contains(mimeType.name());
QVector<Plugin*> filteredPlugins;
foreach (Plugin *plugin, plugins) {
if (plugin->metaData().mimeTypes().contains(mimeType.name())) {
if (!supportedMime) {
// Check whether the mimetype inherits from a supported mimetype.
foreach (const QString &mime, plugin->metaData().mimeTypes()) {
if (mimeType.inherits(mime)) {
filteredPlugins << plugin;
}
}
} else if (plugin->metaData().mimeTypes().contains(mimeType.name())) {
filteredPlugins << plugin;
}
}
......
......@@ -101,9 +101,9 @@ public:
QStringList supportedWriteMimeTypes() const;
/**
* @return The given list of @p plugins filtered by @p mimeType.
* @return The subset of @p plugins that support either @p mimetype or a parent of @p mimetype.
*/
static QVector<Plugin*> filterBy(const QVector<Plugin*> &plugins, const QMimeType &mimeType);
QVector<Plugin*> filterBy(const QVector<Plugin*> &plugins, const QMimeType &mimeType) const;
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment