[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kio/kio
From: Dawit Alemayehu <adawit () kde ! org>
Date: 2010-11-12 18:33:56
Message-ID: 20101112183356.9B2FEAC89E () svn ! kde ! org
[Download RAW message or body]
SVN commit 1196172 by adawit:
Make sure the order of the filter plugins determined by the InitialPreference property is honored
M +21 -14 kurifilter.cpp
--- trunk/KDE/kdelibs/kio/kio/kurifilter.cpp #1196171:1196172
@@ -574,6 +574,9 @@
plugins.clear();
}
QHash<QString, KUriFilterPlugin *> plugins;
+ // NOTE: DO NOT REMOVE this variable! Read the
+ // comments in KUriFilter::loadPlugins to understand why...
+ QStringList pluginNames;
};
KUriFilter *KUriFilter::self()
@@ -600,14 +603,14 @@
// If no specific filters were requested, iterate through all the plugins.
// Otherwise, only use available filters.
if( filters.isEmpty() ) {
- QHashIterator<QString, KUriFilterPlugin *> it (d->plugins);
+ QStringListIterator it (d->pluginNames);
while (it.hasNext()) {
- it.next();
- if ( it.value()->filterUri( data ) )
+ KUriFilterPlugin* plugin = d->plugins.value(it.next());
+ if (plugin && plugin->filterUri( data ))
filtered = true;
}
} else {
- QListIterator<QString> it (filters);
+ QStringListIterator it (filters);
while (it.hasNext()) {
KUriFilterPlugin* plugin = d->plugins.value(it.next());
if (plugin && plugin->filterUri( data ))
@@ -659,36 +662,40 @@
{
QStringList filters;
+ if (types & WebShortcutFilter)
+ filters << "kurisearchfilter";
+
if (types & NormalTextFilter)
filters << "kuriikwsfilter";
- if (types & WebShortcutFilter)
- filters << "kurisearchfilter";
-
return filterUri(data, filters);
}
QStringList KUriFilter::pluginNames() const
{
- return d->plugins.keys();
+ return d->pluginNames;
}
void KUriFilter::loadPlugins()
{
const KService::List offers = KServiceTypeTrader::self()->query( "KUriFilter/Plugin" );
+ // NOTE: Plugin priority is determined by the InitialPreference entry in
+ // the .desktop files, so the trader result is already sorted and should
+ // not be manually sorted.
Q_FOREACH (const KService::Ptr &ptr, offers) {
KUriFilterPlugin *plugin = ptr->createInstance<KUriFilterPlugin>();
if (plugin) {
- Q_ASSERT( !plugin->objectName().isEmpty() );
- d->plugins.insert(plugin->objectName(), plugin );
+ const QString& pluginName = plugin->objectName();
+ Q_ASSERT( !pluginName.isEmpty() )
+ d->plugins.insert(pluginName, plugin );
+ // Needed to ensure the order of filtering is honored since
+ // items are ordered arbitarily in a QHash and QMap always
+ // sorts by keys. Both undesired behavior.
+ d->pluginNames << pluginName;
}
}
-
- // NOTE: Plugin priority is determined by the InitialPreference entry in
- // the .desktop files, so the trader result is already sorted and should
- // not be manually sorted.
}
#include "kurifilter.moc"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic