KPeople

peopleqmlplugin.cpp
1 /*
2  Persons Model
3  SPDX-FileCopyrightText: 2012 Aleix Pol Gonzalez <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7 
8 #include "peopleqmlplugin.h"
9 
10 #include <QQmlEngine>
11 
12 #include <actions.h>
13 #include <personactionsmodel_p.h>
14 #include <persondata.h>
15 #include <personpluginmanager.h>
16 #include <personsmodel.h>
17 #include <personssortfilterproxymodel.h>
18 
19 #include "avatarimageprovider.h"
20 #include "declarativepersondata.h"
21 
22 class ActionTypeWrapper : public QObject
23 {
24  Q_OBJECT
25 
26 public:
27  enum ActionType {
28  TextChatAction = KPeople::TextChatAction,
29  AudioCallAction = KPeople::AudioCallAction,
30  VideoCallAction = KPeople::VideoCallAction,
31  SendEmailAction = KPeople::SendEmailAction,
32  SendFileAction = KPeople::SendFileAction,
33  OtherAction = KPeople::OtherAction,
34  };
35  Q_ENUM(ActionType)
36 };
37 
38 class DeclarativePersonPluginManager : public QObject
39 {
40  Q_OBJECT
41 public:
42  Q_SCRIPTABLE bool addContact(const QVariantMap &properties)
43  {
45  }
46  Q_SCRIPTABLE bool deleteContact(const QString &uri)
47  {
49  }
50 };
51 
52 void PeopleQMLPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
53 {
54  Q_ASSERT(uri == QByteArrayLiteral("org.kde.people"));
55  engine->addImageProvider(QStringLiteral("kpeople-avatar"), new AvatarImageProvider());
56 }
57 
58 void PeopleQMLPlugin::registerTypes(const char *uri)
59 {
60  qmlRegisterType<KPeople::PersonsModel>(uri, 1, 0, "PersonsModel");
61  qmlRegisterType<KPeople::PersonsSortFilterProxyModel>(uri, 1, 0, "PersonsSortFilterProxyModel");
62  qmlRegisterType<KPeople::PersonActionsModel>(uri, 1, 0, "PersonActions");
63  qmlRegisterType<DeclarativePersonData>(uri, 1, 0, "PersonData");
64  qmlRegisterAnonymousType<KPeople::PersonData>(uri, 1);
65  qmlRegisterUncreatableType<ActionTypeWrapper>(uri, 1, 0, "ActionType", QStringLiteral("You cannot create ActionType"));
66  qmlRegisterSingletonType<DeclarativePersonPluginManager>(uri, 1, 0, "PersonPluginManager", [](QQmlEngine *, QJSEngine *) -> QObject * {
67  return new DeclarativePersonPluginManager;
68  });
69 
70  qmlRegisterUncreatableMetaObject(KPeople::staticMetaObject, uri, 1, 0, "KPeople", QStringLiteral("Access to enums & flags only"));
71 }
72 
73 #include "peopleqmlplugin.moc"
Q_OBJECTQ_OBJECT
Q_ENUM(...)
void addImageProvider(const QString &providerId, QQmlImageProviderBase *provider)
static bool addContact(const QVariantMap &properties)
Creates a contact with the specified properties.
An image provider for displaying a contact's photo.
static bool deleteContact(const QString &uri)
Deletes a contact with the specified &p uri.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Aug 14 2022 04:09:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.