mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kio: specialize only the globs matching
the soft MIME matching via KMimeType::is() is way too.. soft. it can match application/x-dvi as plain/text (and use ps thumbnailer) which is not ideal (should use only textthumbnail thumbnailer for plain/text and ps thumbnailer for application/x-dvi) Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
5d0377b9e6
commit
1ecd860cd3
1 changed files with 19 additions and 32 deletions
|
@ -257,21 +257,6 @@ PreviewJob::ScaleType PreviewJob::scaleType() const
|
|||
void PreviewJobPrivate::startPreview()
|
||||
{
|
||||
Q_Q(PreviewJob);
|
||||
// Load the list of plugins to determine which mimetypes are supported
|
||||
const KService::List plugins = KServiceTypeTrader::self()->query("ThumbCreator");
|
||||
|
||||
// Map their MIME types
|
||||
QHash<QString, KService::Ptr> mimesMap;
|
||||
foreach (const KService::Ptr plugin, plugins) {
|
||||
if (enabledPlugins.contains(plugin->desktopEntryName())) {
|
||||
foreach (const QString &pluginmime, kThumbGlobMimeTypes(plugin->serviceTypes())) {
|
||||
mimesMap.insert(pluginmime, plugin);
|
||||
}
|
||||
} else {
|
||||
kDebug(7007) << "Plugin is disabled" << plugin->desktopEntryName();
|
||||
}
|
||||
}
|
||||
|
||||
// Look for images and store the items in our todo list :)
|
||||
bool bNeedCache = false;
|
||||
foreach (const KFileItem &kit, initialItems) {
|
||||
|
@ -291,28 +276,30 @@ void PreviewJobPrivate::startPreview()
|
|||
}
|
||||
|
||||
if (!itemplugin) {
|
||||
// Long stretch, globs first
|
||||
QHash<QString, KService::Ptr>::ConstIterator it = mimesMap.constBegin();
|
||||
while (it != mimesMap.constEnd()) {
|
||||
const QString pluginmime = it.key();
|
||||
if (pluginmime.endsWith('*')) {
|
||||
const QString globmime = pluginmime.mid(0, pluginmime.size() - 1);
|
||||
if (itemmime.startsWith(globmime)) {
|
||||
itemplugin = it.value();
|
||||
kDebug(7007) << "Glob match for" << itemmime << itemplugin->library();
|
||||
break;
|
||||
// Long stretch, globs match maybe?
|
||||
const KService::List plugins = KServiceTypeTrader::self()->query("ThumbCreator");
|
||||
bool breakouterloop = false;
|
||||
foreach (const KService::Ptr plugin, plugins) {
|
||||
if (!enabledPlugins.contains(plugin->desktopEntryName())) {
|
||||
kDebug(7007) << "Plugin is disabled" << plugin->desktopEntryName();
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (const QString &pluginmime, kThumbGlobMimeTypes(plugin->serviceTypes())) {
|
||||
if (pluginmime.endsWith(QLatin1Char('*'))) {
|
||||
const QString globmime = pluginmime.mid(0, pluginmime.size() - 1);
|
||||
if (itemmime.startsWith(globmime)) {
|
||||
itemplugin = plugin;
|
||||
kDebug(7007) << "Glob match for" << itemmime << itemplugin->library();
|
||||
breakouterloop = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Soft MIME match
|
||||
const KMimeType::Ptr mimeInfo = KMimeType::mimeType(pluginmime);
|
||||
if (mimeInfo && mimeInfo->is(itemmime)) {
|
||||
itemplugin = it.value();
|
||||
kDebug(7007) << "MIME match for" << itemmime << itemplugin->library();
|
||||
if (breakouterloop) {
|
||||
break;
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue