Use KPluginMetaData to list DataEngines
Avoid using KPluginInfo and KPluginTrader in favor of KPluginMetaData and KPluginLoader. Add new method that uses KPluginMetaData Deprecate old KPluginInfo-based methods. See also https://phabricator.kde.org/T13889
This commit is contained in:
parent
255eb93070
commit
1a1133006b
@ -11,6 +11,7 @@
|
||||
#include <QSignalSpy>
|
||||
|
||||
#include <KPluginInfo>
|
||||
#include <KPluginMetaData>
|
||||
|
||||
#include <plasma/pluginloader.h>
|
||||
#include <plasma/dataengineconsumer.h>
|
||||
@ -24,7 +25,7 @@ PluginTest::PluginTest()
|
||||
|
||||
void PluginTest::listEngines()
|
||||
{
|
||||
KPluginInfo::List plugins = Plasma::PluginLoader::listEngineInfo();
|
||||
QVector<KPluginMetaData> plugins = Plasma::PluginLoader::self()->listDataEngineMetaData();
|
||||
// foreach (const KPluginInfo& info, plugins) {
|
||||
//qDebug() << " Found DataEngine: " << info.pluginName() << info.name();
|
||||
// }
|
||||
|
@ -83,7 +83,7 @@ ecm_generate_export_header(KF5Plasma
|
||||
GROUP_BASE_NAME KF
|
||||
VERSION ${KF5_VERSION}
|
||||
DEPRECATED_BASE_VERSION 0
|
||||
DEPRECATION_VERSIONS 5.6 5.19 5.28 5.30 5.36 5.46 5.67
|
||||
DEPRECATION_VERSIONS 5.6 5.19 5.28 5.30 5.36 5.46 5.67 5.77
|
||||
)
|
||||
# TODO: add support for EXCLUDE_DEPRECATED_BEFORE_AND_AT to all Plasma libs
|
||||
# needs fixing of undeprecated API being still implemented using own deprecated API
|
||||
|
@ -270,10 +270,12 @@ QStringList PluginLoader::listAllEngines(const QString &parentApp)
|
||||
return engines;
|
||||
}
|
||||
|
||||
#if PLASMA_BUILD_DEPRECATED_SINCE(5, 77)
|
||||
KPluginInfo::List PluginLoader::listEngineInfo(const QString &parentApp)
|
||||
{
|
||||
return PluginLoader::self()->listDataEngineInfo(parentApp);
|
||||
}
|
||||
#endif
|
||||
|
||||
KPluginInfo::List PluginLoader::listEngineInfoByCategory(const QString &category, const QString &parentApp)
|
||||
{
|
||||
@ -715,21 +717,28 @@ QStringList PluginLoader::listContainmentTypes()
|
||||
return types.values();
|
||||
}
|
||||
|
||||
#if PLASMA_BUILD_DEPRECATED_SINCE(5, 77)
|
||||
KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp)
|
||||
{
|
||||
KPluginInfo::List list;
|
||||
return KPluginInfo::fromMetaData(listDataEngineMetaData(parentApp));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!d->isDefaultLoader && (parentApp.isEmpty() || parentApp == QCoreApplication::instance()->applicationName())) {
|
||||
list = internalDataEngineInfo();
|
||||
QVector<KPluginMetaData> PluginLoader::listDataEngineMetaData(const QString &parentApp)
|
||||
{
|
||||
auto filter = [&parentApp](const KPluginMetaData &md) -> bool
|
||||
{
|
||||
return md.value(QStringLiteral("X-KDE-ParentApp")) == parentApp;
|
||||
};
|
||||
|
||||
QVector<KPluginMetaData> plugins;
|
||||
if (parentApp.isEmpty()) {
|
||||
plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_dataEnginePluginDir);
|
||||
} else {
|
||||
plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_dataEnginePluginDir, filter);
|
||||
}
|
||||
|
||||
QString constraint;
|
||||
if (!parentApp.isEmpty()) {
|
||||
constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + QLatin1Char('\'');
|
||||
}
|
||||
|
||||
list.append(KPluginTrader::self()->query(PluginLoaderPrivate::s_dataEnginePluginDir, QStringLiteral("Plasma/DataEngine"), constraint));
|
||||
return list;
|
||||
return plugins;
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::listContainmentActionsInfo(const QString &parentApp)
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
*/
|
||||
static QStringList listAllEngines(const QString &parentApp = QString());
|
||||
|
||||
#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 77)
|
||||
/**
|
||||
* Returns a list of all known dataengines.
|
||||
*
|
||||
@ -81,8 +82,11 @@ public:
|
||||
* The default value of QString() will result in a
|
||||
* list of all dataengines.
|
||||
* @return list of dataengines
|
||||
* @deprecated since 5.77, use listDataEngineMetaData instead.
|
||||
**/
|
||||
PLASMA_DEPRECATED_VERSION(5, 77, "Use listDataEngineMetaData instead")
|
||||
static KPluginInfo::List listEngineInfo(const QString &parentApp = QString());
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns a list of all known dataengines filtering by category.
|
||||
@ -311,6 +315,7 @@ public:
|
||||
**/
|
||||
static KPluginInfo::List listContainmentsForMimeType(const QString &mimeType);
|
||||
|
||||
#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 77)
|
||||
/**
|
||||
* Returns a list of all known dataengines.
|
||||
*
|
||||
@ -319,8 +324,23 @@ public:
|
||||
* The default value of QString() will result in a
|
||||
* list of all dataengines
|
||||
* @return list of dataengines
|
||||
* @deprecated since 5.77, use listDataEngineMetaData()
|
||||
**/
|
||||
PLASMA_DEPRECATED_VERSION(5, 77, "Use listDataEngineMetaData()")
|
||||
KPluginInfo::List listDataEngineInfo(const QString &parentApp = QString());
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns a list of all known dataengines.
|
||||
*
|
||||
* @param parentApp the application to filter dataengines on. Uses the
|
||||
* X-KDE-ParentApp entry (if any) in the plugin info.
|
||||
* The default value of QString() will result in a
|
||||
* list of all dataengines
|
||||
* @return list of dataengines
|
||||
* @since 5.77
|
||||
**/
|
||||
QVector<KPluginMetaData> listDataEngineMetaData(const QString &parentApp = QString());
|
||||
|
||||
/**
|
||||
* Returns a list of all known ContainmentActions.
|
||||
|
Loading…
Reference in New Issue
Block a user