move all loading function to PluginLoader
This commit is contained in:
parent
efc1264592
commit
5af5da2687
@ -602,48 +602,6 @@ void DataEnginePrivate::scheduleSourcesUpdated()
|
||||
checkSourcesTimerId = q->startTimer(0);
|
||||
}
|
||||
|
||||
QStringList DataEngine::listAllEngines(const QString &parentApp)
|
||||
{
|
||||
QString constraint;
|
||||
|
||||
if (parentApp.isEmpty()) {
|
||||
constraint.append("(not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '')");
|
||||
} else {
|
||||
constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'");
|
||||
}
|
||||
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", constraint);
|
||||
|
||||
QStringList engines;
|
||||
foreach (const KService::Ptr &service, offers) {
|
||||
QString name = service->property("X-KDE-PluginInfo-Name").toString();
|
||||
if (!name.isEmpty()) {
|
||||
engines.append(name);
|
||||
}
|
||||
}
|
||||
|
||||
return engines;
|
||||
}
|
||||
|
||||
KPluginInfo::List DataEngine::listEngineInfo(const QString &parentApp)
|
||||
{
|
||||
return PluginLoader::self()->listDataEngineInfo(parentApp);
|
||||
}
|
||||
|
||||
KPluginInfo::List DataEngine::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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -212,47 +212,6 @@ NoAlignment) const;
|
||||
**/
|
||||
Package package() const;
|
||||
|
||||
/**
|
||||
* @return a listing of all known DataEngines by name
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
static QStringList listAllEngines(const QString &parentApp = QString());
|
||||
|
||||
/**
|
||||
* Returns a list of all known DataEngines.
|
||||
*
|
||||
* @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
|
||||
**/
|
||||
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());
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* Emitted when a new data source is created
|
||||
|
@ -266,6 +266,48 @@ DataEngine *PluginLoader::loadDataEngine(const QString &name)
|
||||
return engine;
|
||||
}
|
||||
|
||||
QStringList PluginLoader::listAllEngines(const QString &parentApp)
|
||||
{
|
||||
QString constraint;
|
||||
|
||||
if (parentApp.isEmpty()) {
|
||||
constraint.append("(not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '')");
|
||||
} else {
|
||||
constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'");
|
||||
}
|
||||
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", constraint);
|
||||
|
||||
QStringList engines;
|
||||
foreach (const KService::Ptr &service, offers) {
|
||||
QString name = service->property("X-KDE-PluginInfo-Name").toString();
|
||||
if (!name.isEmpty()) {
|
||||
engines.append(name);
|
||||
}
|
||||
}
|
||||
|
||||
return engines;
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::listEngineInfo(const QString &parentApp)
|
||||
{
|
||||
return PluginLoader::self()->listDataEngineInfo(parentApp);
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::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);
|
||||
}
|
||||
|
||||
AbstractRunner *PluginLoader::loadRunner(const QString &name)
|
||||
{
|
||||
// FIXME: RunnerManager is all wrapped around runner loading; that should be sorted out
|
||||
|
@ -74,6 +74,47 @@ public:
|
||||
**/
|
||||
DataEngine *loadDataEngine(const QString &name);
|
||||
|
||||
/**
|
||||
* @return a listing of all known DataEngines by name
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
static QStringList listAllEngines(const QString &parentApp = QString());
|
||||
|
||||
/**
|
||||
* Returns a list of all known DataEngines.
|
||||
*
|
||||
* @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
|
||||
**/
|
||||
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());
|
||||
|
||||
/**
|
||||
* Load a Runner plugin
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user