diff --git a/dataenginemanager.cpp b/dataenginemanager.cpp index 31eed380c..c0f50df4d 100644 --- a/dataenginemanager.cpp +++ b/dataenginemanager.cpp @@ -202,6 +202,20 @@ KPluginInfo::List DataEngineManager::listEngineInfo(const QString &parentApp) return KPluginInfo::fromServices(offers); } +KPluginInfo::List DataEngineManager::listEngineInfoByCategory(const QString &category, const QString &parentApp) +{ + QString constraint = QString("[X-KDE-PluginInfo-Category] == '%1'").arg(category); + + if (parentApp.isEmpty()) { + constraint.append(" and not exist [X-KDE-ParentApp]"); + } else { + constraint.append(" and [X-KDE-ParentApp] == '").append(parentApp).append("'"); + } + + KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", constraint); + return KPluginInfo::fromServices(offers); +} + } // namespace Plasma #include "dataenginemanager.moc" diff --git a/dataenginemanager.h b/dataenginemanager.h index 06970dcdf..16b9fd9dd 100644 --- a/dataenginemanager.h +++ b/dataenginemanager.h @@ -73,7 +73,7 @@ class PLASMA_EXPORT DataEngineManager: public QObject * zero, then the engine is deleted to save resources. */ void unloadEngine(const QString &name); - + /** * @return a listing of all known DataEngines by name * @@ -97,6 +97,23 @@ class PLASMA_EXPORT DataEngineManager: public QObject **/ static KPluginInfo::List listEngineInfo(const QString &parentApp = QString()); + /** + * Returns a list of all known DataEngines filtering by category. + * + * @param category the category to filter applets on. Uses the + * X-KDE-PluginInfo-Category entry (if any) in the + * plugin info. The value of QString() will + * result in a list of engines with an empty category. + * + * @param parentApp the application to filter applets on. Uses the + * X-KDE-ParentApp entry (if any) in the plugin info. + * The default value of QString() will result in a + * list containing only applets not specifically + * registered to an application. + * @return list of DataEngines + * @since 4.3 + **/ + static KPluginInfo::List listEngineInfoByCategory(const QString &category, const QString &parentApp = QString()); private: /** * Default constructor. The singleton method self() is the