Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/actions.cpp
Show All 17 Lines | |||||
18 | 18 | | |||
19 | #include "actions.h" | 19 | #include "actions.h" | ||
20 | #include <QAction> | 20 | #include <QAction> | ||
21 | #include "kpeople_widgets_debug.h" | 21 | #include "kpeople_widgets_debug.h" | ||
22 | #include <KPluginLoader> | 22 | #include <KPluginLoader> | ||
23 | #include <KPluginFactory> | 23 | #include <KPluginFactory> | ||
24 | #include <KPluginMetaData> | 24 | #include <KPluginMetaData> | ||
25 | #include <KPeople/PersonData> | 25 | #include <KPeople/PersonData> | ||
26 | #include <KServiceTypeTrader> | | |||
27 | #include "../backends/abstractpersonaction.h" | 26 | #include "../backends/abstractpersonaction.h" | ||
28 | 27 | | |||
29 | namespace KPeople | 28 | namespace KPeople | ||
30 | { | 29 | { | ||
31 | 30 | | |||
32 | static QList<AbstractPersonAction *> actionsPlugins() | 31 | static QList<AbstractPersonAction *> actionsPlugins() | ||
33 | { | 32 | { | ||
34 | QList<AbstractPersonAction *> actionPlugins; | 33 | QList<AbstractPersonAction *> actionPlugins; | ||
35 | const QVector<KPluginMetaData> personPluginList = KPluginLoader::findPlugins(QStringLiteral("kpeople/actions")); | 34 | const QVector<KPluginMetaData> personPluginList = KPluginLoader::findPlugins(QStringLiteral("kpeople/actions")); | ||
36 | for (const KPluginMetaData &service : personPluginList) { | 35 | for (const KPluginMetaData &service : personPluginList) { | ||
37 | KPluginLoader loader(service.fileName()); | 36 | KPluginLoader loader(service.fileName()); | ||
38 | KPluginFactory *factory = loader.factory(); | 37 | KPluginFactory *factory = loader.factory(); | ||
39 | if (!factory) { | 38 | if (!factory) { | ||
40 | qCWarning(KPEOPLE_WIDGETS_LOG) << "Couldn't create the factory for" << service.name() << "at" << service.fileName(); | 39 | qCWarning(KPEOPLE_WIDGETS_LOG) << "Couldn't create the factory for" << service.name() << "at" << service.fileName(); | ||
41 | continue; | 40 | continue; | ||
42 | } | 41 | } | ||
43 | AbstractPersonAction *plugin = factory->create<AbstractPersonAction>(); | 42 | AbstractPersonAction *plugin = factory->create<AbstractPersonAction>(); | ||
44 | if (plugin) { | 43 | if (plugin) { | ||
45 | // qCDebug(KPEOPLE_WIDGETS_LOG) << "found plugin" << service->name(); | 44 | // qCDebug(KPEOPLE_WIDGETS_LOG) << "found plugin" << service->name(); | ||
46 | actionPlugins << plugin; | 45 | actionPlugins << plugin; | ||
47 | } | 46 | } | ||
48 | } | 47 | } | ||
49 | 48 | | |||
50 | //TODO: Remove as soon as KTp sources are released with the new plugin system | | |||
51 | const KService::List personServicesList = KServiceTypeTrader::self()->query(QStringLiteral("KPeople/Plugin")); | | |||
52 | for (const KService::Ptr &service : personServicesList) { | | |||
53 | AbstractPersonAction *plugin = service->createInstance<AbstractPersonAction>(nullptr); | | |||
54 | | ||||
55 | | ||||
56 | if (plugin) { | | |||
57 | // qCDebug(KPEOPLE_WIDGETS_LOG) << "found plugin" << service->name(); | | |||
58 | actionPlugins << plugin; | | |||
59 | } | | |||
60 | } | | |||
61 | | ||||
62 | return actionPlugins; | 49 | return actionPlugins; | ||
63 | } | 50 | } | ||
64 | 51 | | |||
65 | QList<QAction *> actionsForPerson(const QString &contactUri, QObject *parent) | 52 | QList<QAction *> actionsForPerson(const QString &contactUri, QObject *parent) | ||
66 | { | 53 | { | ||
67 | PersonData person(contactUri); | 54 | PersonData person(contactUri); | ||
68 | 55 | | |||
69 | QList<QAction *> actions; | 56 | QList<QAction *> actions; | ||
Show All 9 Lines |