1/*
2 SPDX-FileCopyrightText: 2016 Dan Leinir Turthra Jensen <admin@leinir.dk>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "qmlplugin.h"
8
9#include "author.h"
10#include "categoriesmodel.h"
11#include "commentsmodel.h"
12#include "quickengine.h"
13#include "quickitemsmodel.h"
14#include "quickquestionlistener.h"
15#include "quicksettings.h"
16#include "searchpresetmodel.h"
17
18#include "provider.h"
19#include "providersmodel.h"
20#include "question.h"
21
22#include <QQmlEngine>
23#include <qqml.h>
24
25void QmlPlugins::initializeEngine(QQmlEngine * /*engine*/, const char *)
26{
27}
28
29void QmlPlugins::registerTypes(const char *uri)
30{
31 const char *coreUri{"org.kde.newstuff.core"};
32
33 // Initial version
34 qmlRegisterType<Engine>(uri, versionMajor: 1, versionMinor: 0, qmlName: "Engine");
35 qmlRegisterType<ItemsModel>(uri, versionMajor: 1, versionMinor: 0, qmlName: "ItemsModel");
36
37 // Version 1.62
38 qmlRegisterType<KNewStuffQuick::Author>(uri, versionMajor: 1, versionMinor: 62, qmlName: "Author");
39 qmlRegisterType<KNewStuffQuick::CommentsModel>(uri, versionMajor: 1, versionMinor: 62, qmlName: "CommentsModel");
40 qmlRegisterUncreatableType<CategoriesModel>(
41 uri,
42 versionMajor: 1,
43 versionMinor: 0,
44 qmlName: "CategoriesModel",
45 QStringLiteral("This should only be created by the Engine, and provides the categories available in that engine"));
46 qmlRegisterUncreatableMetaObject(staticMetaObject: KNSCore::Provider::staticMetaObject,
47 uri: coreUri,
48 versionMajor: 1,
49 versionMinor: 62,
50 qmlName: "Provider",
51 QStringLiteral("Error: this only exists to forward enums"));
52 qmlRegisterUncreatableMetaObject(staticMetaObject: KNSCore::Question::staticMetaObject,
53 uri: coreUri,
54 versionMajor: 1,
55 versionMinor: 62,
56 qmlName: "Question",
57 QStringLiteral("Error: this only exists to forward enums"));
58 qmlRegisterSingletonType<KNewStuffQuick::QuickQuestionListener>(uri,
59 versionMajor: 1,
60 versionMinor: 62,
61 typeName: "QuickQuestionListener",
62 callback: [](QQmlEngine *engine, QJSEngine * /*scriptEngine*/) -> QObject * {
63 engine->setObjectOwnership(KNewStuffQuick::QuickQuestionListener::instance(),
64 QQmlEngine::CppOwnership);
65 return KNewStuffQuick::QuickQuestionListener::instance();
66 });
67 qmlRegisterUncreatableMetaObject(staticMetaObject: KNSCore::Entry::staticMetaObject, uri, versionMajor: 1, versionMinor: 91, qmlName: "Entry", QStringLiteral("Entries should only be created by the engine"));
68 qmlRegisterUncreatableMetaObject(staticMetaObject: KNSCore::ErrorCode::staticMetaObject,
69 uri,
70 versionMajor: 1,
71 versionMinor: 91,
72 qmlName: "ErrorCode",
73 QStringLiteral("Only for access to the KNSCore::ErrorCode enum"));
74
75 // Version 1.81
76 qmlRegisterSingletonType<KNewStuffQuick::Settings>(uri, versionMajor: 1, versionMinor: 81, typeName: "Settings", callback: [](QQmlEngine *engine, QJSEngine * /*scriptEngine*/) -> QObject * {
77 engine->setObjectOwnership(KNewStuffQuick::Settings::instance(), QQmlEngine::CppOwnership);
78 return KNewStuffQuick::Settings::instance();
79 });
80 // Version 1.83
81 qmlRegisterUncreatableType<SearchPresetModel>(
82 uri,
83 versionMajor: 1,
84 versionMinor: 83,
85 qmlName: "SearchPresetModel",
86 QStringLiteral("This should only be created by the Engine, and provides the SearchPresets available in that engine"));
87
88 // Version 1.85
89 qmlRegisterType<KNSCore::ProvidersModel>(uri, versionMajor: 1, versionMinor: 85, qmlName: "ProvidersModel");
90}
91
92#include "moc_qmlplugin.cpp"
93

source code of knewstuff/src/qtquick/qmlplugin.cpp