KPeople

actions.cpp
1/*
2 SPDX-FileCopyrightText: 2015 Aleix Pol i Gonzalez <aleixpol@blue-systems.com>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#include "actions.h"
8#include "backends/abstractpersonaction.h"
9#include "kpeople_debug.h"
10#include <KPeople/PersonData>
11
12#include <KPluginFactory>
13#include <KPluginMetaData>
14
15#include <QAction>
16
17namespace KPeople
18{
19static QList<AbstractPersonAction *> actionsPlugins()
20{
22 const QList<KPluginMetaData> personPluginList = KPluginMetaData::findPlugins(QStringLiteral("kpeople/actions"));
23 for (const KPluginMetaData &data : personPluginList) {
24 auto pluginResult = KPluginFactory::instantiatePlugin<AbstractPersonAction>(data);
25 if (pluginResult) {
26 qCDebug(KPEOPLE_LOG) << "found plugin" << data.fileName();
27 AbstractPersonAction *plugin = pluginResult.plugin;
28 actionPlugins << plugin;
29 } else {
30 qCDebug(KPEOPLE_LOG) << "could not load plugin" << data.fileName() << pluginResult.errorText;
31 }
32 }
33
34 return actionPlugins;
35}
36
37QList<QAction *> actionsForPerson(const QString &contactUri, QObject *parent)
38{
39 PersonData person(contactUri);
40
41 QList<QAction *> actions;
42 const auto lst = actionsPlugins();
43 for (KPeople::AbstractPersonAction *plugin : lst) {
44 actions << plugin->actionsForPerson(person, parent);
45 }
46
47 return actions;
48}
49
50}
51
52#include "moc_actions.cpp"
static QList< KPluginMetaData > findPlugins(const QString &directory, std::function< bool(const KPluginMetaData &)> filter={}, KPluginMetaDataOptions options={})
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.