KPeople

actions.cpp
1 /*
2  SPDX-FileCopyrightText: 2015 Aleix Pol i Gonzalez <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6 
7 #include "actions.h"
8 #include "../backends/abstractpersonaction.h"
9 #include "kpeople_widgets_debug.h"
10 #include <KPeople/PersonData>
11 
12 #include <KPluginFactory>
13 #include <KPluginMetaData>
14 
15 #include <QAction>
16 
17 namespace KPeople
18 {
19 static QList<AbstractPersonAction *> actionsPlugins()
20 {
21  QList<AbstractPersonAction *> actionPlugins;
22  const QVector<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_WIDGETS_LOG) << "found plugin" << data.fileName();
27  AbstractPersonAction *plugin = pluginResult.plugin;
28  actionPlugins << plugin;
29  } else {
30  qCDebug(KPEOPLE_WIDGETS_LOG) << "could not load plugin" << data.fileName() << pluginResult.errorText;
31  }
32  }
33 
34  return actionPlugins;
35 }
36 
37 QList<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 }
static QVector< KPluginMetaData > findPlugins(const QString &directory, std::function< bool(const KPluginMetaData &)> filter={})
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jan 27 2022 22:42:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.