File indexing completed on 2024-12-08 07:19:14
0001 /* 0002 SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "kpublictransportqmlplugin.h" 0008 #include "linemetadatawrapper.h" 0009 0010 #include <QQmlEngine> 0011 #include <QQmlContext> 0012 0013 #include <KPublicTransport/BackendModel> 0014 #include <KPublicTransport/CoverageArea> 0015 #include <KPublicTransport/Equipment> 0016 #include <KPublicTransport/IndividualTransport> 0017 #include <KPublicTransport/Journey> 0018 #include <KPublicTransport/JourneyQueryModel> 0019 #include <KPublicTransport/JourneyRequest> 0020 #include <KPublicTransport/Line> 0021 #include <KPublicTransport/LocationHistoryModel> 0022 #include <KPublicTransport/LocationQueryModel> 0023 #include <KPublicTransport/LocationRequest> 0024 #include <KPublicTransport/Manager> 0025 #include <KPublicTransport/Path> 0026 #include <KPublicTransport/PathModel> 0027 #include <KPublicTransport/Platform> 0028 #include <KPublicTransport/RentalVehicle> 0029 #include <KPublicTransport/StopoverRequest> 0030 #include <KPublicTransport/StopoverQueryModel> 0031 #include <KPublicTransport/Vehicle> 0032 #include <KPublicTransport/VehicleLayoutQueryModel> 0033 #include <KPublicTransport/VehicleLayoutRequest> 0034 0035 void KPublicTransportQmlPlugin::registerTypes(const char*) 0036 { 0037 qRegisterMetaType<KPublicTransport::CoverageArea>(); 0038 qRegisterMetaType<KPublicTransport::CoverageArea::Type>(); 0039 qRegisterMetaType<KPublicTransport::Equipment>(); 0040 qRegisterMetaType<KPublicTransport::Journey>(); 0041 qRegisterMetaType<KPublicTransport::Line>(); 0042 qRegisterMetaType<KPublicTransport::Line::Mode>(); 0043 qRegisterMetaType<KPublicTransport::LoadInfo>(); 0044 qRegisterMetaType<KPublicTransport::Location>(); 0045 qRegisterMetaType<KPublicTransport::Platform>(); 0046 qRegisterMetaType<KPublicTransport::RentalVehicle>(); 0047 qRegisterMetaType<KPublicTransport::RentalVehicleStation>(); 0048 qRegisterMetaType<KPublicTransport::Stopover>(); 0049 qRegisterMetaType<KPublicTransport::IndividualTransport>(); 0050 0051 #define REGISTER_METAOBJECT(Type) \ 0052 qmlRegisterUncreatableMetaObject(KPublicTransport::Type::staticMetaObject, "org.kde.kpublictransport", 1, 0, #Type, {}); 0053 0054 REGISTER_METAOBJECT(CoverageArea) 0055 REGISTER_METAOBJECT(Disruption) 0056 REGISTER_METAOBJECT(Equipment) 0057 REGISTER_METAOBJECT(IndividualTransport) 0058 REGISTER_METAOBJECT(JourneyRequest) 0059 REGISTER_METAOBJECT(JourneySection) 0060 REGISTER_METAOBJECT(Line) 0061 REGISTER_METAOBJECT(Load) 0062 REGISTER_METAOBJECT(Location) 0063 REGISTER_METAOBJECT(LocationRequest) 0064 REGISTER_METAOBJECT(PathSection) 0065 REGISTER_METAOBJECT(Platform) 0066 REGISTER_METAOBJECT(RentalVehicle) 0067 REGISTER_METAOBJECT(StopoverRequest) 0068 REGISTER_METAOBJECT(Vehicle) 0069 REGISTER_METAOBJECT(VehicleLayoutRequest) 0070 REGISTER_METAOBJECT(VehicleSection) 0071 0072 qmlRegisterType<KPublicTransport::Manager>("org.kde.kpublictransport", 1, 0, "Manager"); 0073 qmlRegisterType<KPublicTransport::JourneyQueryModel>("org.kde.kpublictransport", 1, 0, "JourneyQueryModel"); 0074 qmlRegisterType<KPublicTransport::LocationHistoryModel>("org.kde.kpublictransport", 1, 0, "LocationHistoryModel"); 0075 qmlRegisterType<KPublicTransport::LocationQueryModel>("org.kde.kpublictransport", 1, 0, "LocationQueryModel"); 0076 qmlRegisterType<KPublicTransport::BackendModel>("org.kde.kpublictransport", 1, 0, "BackendModel"); 0077 qmlRegisterType<KPublicTransport::StopoverQueryModel>("org.kde.kpublictransport", 1, 0, "StopoverQueryModel"); 0078 qmlRegisterType<KPublicTransport::VehicleLayoutQueryModel>("org.kde.kpublictransport", 1, 0, "VehicleLayoutQueryModel"); 0079 qmlRegisterType<KPublicTransport::PathModel>("org.kde.kpublictransport", 1, 0, "PathModel"); 0080 0081 qmlRegisterSingletonType("org.kde.kpublictransport", 1, 0, "LineMetaData", [](QQmlEngine*, QJSEngine *engine) -> QJSValue { 0082 return engine->toScriptValue(KPublicTransport::LineMetaDataWrapper()); 0083 }); 0084 }