File indexing completed on 2024-04-28 07:45:15
0001 /* 0002 SPDX-FileCopyrightText: 2016 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "qmlplugin.h" 0008 0009 #include "author.h" 0010 #include "categoriesmodel.h" 0011 #include "commentsmodel.h" 0012 #include "quickengine.h" 0013 #include "quickitemsmodel.h" 0014 #include "quickquestionlistener.h" 0015 #include "quicksettings.h" 0016 #include "searchpresetmodel.h" 0017 0018 #include "provider.h" 0019 #include "providersmodel.h" 0020 #include "question.h" 0021 0022 #include <QQmlEngine> 0023 #include <qqml.h> 0024 0025 void QmlPlugins::initializeEngine(QQmlEngine * /*engine*/, const char *) 0026 { 0027 } 0028 0029 void QmlPlugins::registerTypes(const char *uri) 0030 { 0031 const char *coreUri{"org.kde.newstuff.core"}; 0032 0033 // Initial version 0034 qmlRegisterType<Engine>(uri, 1, 0, "Engine"); 0035 qmlRegisterType<ItemsModel>(uri, 1, 0, "ItemsModel"); 0036 0037 // Version 1.62 0038 qmlRegisterType<KNewStuffQuick::Author>(uri, 1, 62, "Author"); 0039 qmlRegisterType<KNewStuffQuick::CommentsModel>(uri, 1, 62, "CommentsModel"); 0040 qmlRegisterUncreatableType<CategoriesModel>( 0041 uri, 0042 1, 0043 0, 0044 "CategoriesModel", 0045 QStringLiteral("This should only be created by the Engine, and provides the categories available in that engine")); 0046 qmlRegisterUncreatableMetaObject(KNSCore::Provider::staticMetaObject, 0047 coreUri, 0048 1, 0049 62, 0050 "Provider", 0051 QStringLiteral("Error: this only exists to forward enums")); 0052 qmlRegisterUncreatableMetaObject(KNSCore::Question::staticMetaObject, 0053 coreUri, 0054 1, 0055 62, 0056 "Question", 0057 QStringLiteral("Error: this only exists to forward enums")); 0058 qmlRegisterSingletonType<KNewStuffQuick::QuickQuestionListener>(uri, 0059 1, 0060 62, 0061 "QuickQuestionListener", 0062 [](QQmlEngine *engine, QJSEngine * /*scriptEngine*/) -> QObject * { 0063 engine->setObjectOwnership(KNewStuffQuick::QuickQuestionListener::instance(), 0064 QQmlEngine::CppOwnership); 0065 return KNewStuffQuick::QuickQuestionListener::instance(); 0066 }); 0067 qmlRegisterUncreatableMetaObject(KNSCore::Entry::staticMetaObject, uri, 1, 91, "Entry", QStringLiteral("Entries should only be created by the engine")); 0068 qmlRegisterUncreatableMetaObject(KNSCore::ErrorCode::staticMetaObject, 0069 uri, 0070 1, 0071 91, 0072 "ErrorCode", 0073 QStringLiteral("Only for access to the KNSCore::ErrorCode enum")); 0074 0075 // Version 1.81 0076 qmlRegisterSingletonType<KNewStuffQuick::Settings>(uri, 1, 81, "Settings", [](QQmlEngine *engine, QJSEngine * /*scriptEngine*/) -> QObject * { 0077 engine->setObjectOwnership(KNewStuffQuick::Settings::instance(), QQmlEngine::CppOwnership); 0078 return KNewStuffQuick::Settings::instance(); 0079 }); 0080 // Version 1.83 0081 qmlRegisterUncreatableType<SearchPresetModel>( 0082 uri, 0083 1, 0084 83, 0085 "SearchPresetModel", 0086 QStringLiteral("This should only be created by the Engine, and provides the SearchPresets available in that engine")); 0087 0088 // Version 1.85 0089 qmlRegisterType<KNSCore::ProvidersModel>(uri, 1, 85, "ProvidersModel"); 0090 } 0091 0092 #include "moc_qmlplugin.cpp"