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