KNewStuff

qmlplugin.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Dan Leinir Turthra Jensen <[email protected]>
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 "quickengine.h"
10 #include "quickitemsmodel.h"
11 #include "quickquestionlistener.h"
12 #include "author.h"
13 #include "categoriesmodel.h"
14 #include "commentsmodel.h"
15 #include "downloadlinkinfo.h"
16 #include "entrywrapper.h"
17 
18 #include "provider.h"
19 #include "question.h"
20 
21 #include <QQmlEngine>
22 #include <qqml.h>
23 
24 void QmlPlugins::initializeEngine(QQmlEngine *engine, const char *)
25 {
26  Q_UNUSED(engine);
27 }
28 
29 void 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<DownloadLinkInfo>(uri, 1, 0, "DownloadLinkInfo", QStringLiteral("This should only be created by the ItemsModel, and is associated with one entry in that model"));
41  qmlRegisterUncreatableType<CategoriesModel>(uri, 1, 0, "CategoriesModel", QStringLiteral("This should only be created by the Engine, and provides the categories available in that engine"));
42  qmlRegisterUncreatableMetaObject(KNSCore::Provider::staticMetaObject, coreUri, 1, 62, "Provider", QStringLiteral("Error: this only exists to forward enums"));
43  qmlRegisterUncreatableMetaObject(KNSCore::Question::staticMetaObject, coreUri, 1, 62, "Question", QStringLiteral("Error: this only exists to forward enums"));
44  qmlRegisterSingletonType<KNewStuffQuick::QuickQuestionListener>(uri, 1, 62, "QuickQuestionListener", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
45  Q_UNUSED(scriptEngine)
46  engine->setObjectOwnership(KNewStuffQuick::QuickQuestionListener::instance(), QQmlEngine::CppOwnership);
47  return KNewStuffQuick::QuickQuestionListener::instance();
48  });
49 
50  // Version 1.67
51  qmlRegisterUncreatableType<KNSCore::EntryWrapper>(coreUri, 1, 67, "EntryWrapper", QStringLiteral("This should only be created by the Engine, and wraps EntryInternal objects for passing through Qt Quick"));
52 }
Contains the core functionality for handling interaction with NewStuff providers. ...
Encapsulates a KNSCore::Engine for use in Qt Quick.
Definition: quickengine.h:23
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 18 2021 22:43:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.