KNewStuff

qmlplugin.cpp
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, 1, 0, "Engine");
35 qmlRegisterType<ItemsModel>(uri, 1, 0, "ItemsModel");
36
37 // Version 1.62
38 qmlRegisterType<KNewStuffQuick::Author>(uri, 1, 62, "Author");
39 qmlRegisterType<KNewStuffQuick::CommentsModel>(uri, 1, 62, "CommentsModel");
40 qmlRegisterUncreatableType<CategoriesModel>(
41 uri,
42 1,
43 0,
44 "CategoriesModel",
45 QStringLiteral("This should only be created by the Engine, and provides the categories available in that engine"));
46 qmlRegisterUncreatableMetaObject(KNSCore::Provider::staticMetaObject,
47 coreUri,
48 1,
49 62,
50 "Provider",
51 QStringLiteral("Error: this only exists to forward enums"));
52 qmlRegisterUncreatableMetaObject(KNSCore::Question::staticMetaObject,
53 coreUri,
54 1,
55 62,
56 "Question",
57 QStringLiteral("Error: this only exists to forward enums"));
58 qmlRegisterSingletonType<KNewStuffQuick::QuickQuestionListener>(uri,
59 1,
60 62,
61 "QuickQuestionListener",
62 [](QQmlEngine *engine, QJSEngine * /*scriptEngine*/) -> QObject * {
63 engine->setObjectOwnership(KNewStuffQuick::QuickQuestionListener::instance(),
65 return KNewStuffQuick::QuickQuestionListener::instance();
66 });
67 qmlRegisterUncreatableMetaObject(KNSCore::Entry::staticMetaObject, uri, 1, 91, "Entry", QStringLiteral("Entries should only be created by the engine"));
68 qmlRegisterUncreatableMetaObject(KNSCore::ErrorCode::staticMetaObject,
69 uri,
70 1,
71 91,
72 "ErrorCode",
73 QStringLiteral("Only for access to the KNSCore::ErrorCode enum"));
74
75 // Version 1.81
76 qmlRegisterSingletonType<KNewStuffQuick::Settings>(uri, 1, 81, "Settings", [](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 1,
84 83,
85 "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, 1, 85, "ProvidersModel");
90}
91
92#include "moc_qmlplugin.cpp"
void setObjectOwnership(QObject *object, ObjectOwnership ownership)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.