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 <actions.h>
11 #include <personactionsmodel_p.h>
12 #include <persondata.h>
13 #include <personpluginmanager.h>
14 #include <personsmodel.h>
15 #include <personssortfilterproxymodel.h>
16 
17 #include "declarativepersondata.h"
18 #include <qqml.h>
19 
20 class ActionTypeWrapper : public QObject
21 {
22  Q_OBJECT
23 
24 public:
25  enum ActionType {
26  TextChatAction = KPeople::TextChatAction,
27  AudioCallAction = KPeople::AudioCallAction,
28  VideoCallAction = KPeople::VideoCallAction,
29  SendEmailAction = KPeople::SendEmailAction,
30  SendFileAction = KPeople::SendFileAction,
31  OtherAction = KPeople::OtherAction,
32  };
33  Q_ENUM(ActionType)
34 };
35 
36 class DeclarativePersonPluginManager : public QObject
37 {
38  Q_OBJECT
39 public:
40  Q_SCRIPTABLE bool addContact(const QVariantMap &properties)
41  {
43  }
44  Q_SCRIPTABLE bool deleteContact(const QString &uri)
45  {
47  }
48 };
49 
50 void PeopleQMLPlugin::registerTypes(const char *uri)
51 {
52  qmlRegisterType<KPeople::PersonsModel>(uri, 1, 0, "PersonsModel");
53  qmlRegisterType<KPeople::PersonsSortFilterProxyModel>(uri, 1, 0, "PersonsSortFilterProxyModel");
54  qmlRegisterType<KPeople::PersonActionsModel>(uri, 1, 0, "PersonActions");
55  qmlRegisterType<DeclarativePersonData>(uri, 1, 0, "PersonData");
56  qmlRegisterAnonymousType<KPeople::PersonData>(uri, 1);
57  qmlRegisterUncreatableType<ActionTypeWrapper>(uri, 1, 0, "ActionType", QStringLiteral("You cannot create ActionType"));
58  qmlRegisterSingletonType<DeclarativePersonPluginManager>(uri, 1, 0, "PersonPluginManager", [](QQmlEngine *, QJSEngine *) -> QObject * {
59  return new DeclarativePersonPluginManager;
60  });
61 
62  qmlRegisterUncreatableMetaObject(KPeople::staticMetaObject, uri, 1, 0, "KPeople", QStringLiteral("Access to enums & flags only"));
63 }
64 
65 #include "peopleqmlplugin.moc"
Q_ENUM(...)
Q_OBJECTQ_OBJECT
static bool deleteContact(const QString &uri)
Deletes a contact with the specified &p uri.
static bool addContact(const QVariantMap &properties)
Creates a contact with the specified properties.
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.