kpublictransportqmlplugin.cpp 4.78 KB
Newer Older
Nicolas Fella's avatar
Nicolas Fella committed
1
/*
2
    SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
Nicolas Fella's avatar
Nicolas Fella committed
3

4
    SPDX-License-Identifier: LGPL-2.0-or-later
Nicolas Fella's avatar
Nicolas Fella committed
5
*/
6

Nicolas Fella's avatar
Nicolas Fella committed
7
#include "kpublictransportqmlplugin.h"
8
#include "linemetadatawrapper.h"
Nicolas Fella's avatar
Nicolas Fella committed
9
10
11
12

#include <QQmlEngine>
#include <QQmlContext>

13
#include <KPublicTransport/BackendModel>
14
#include <KPublicTransport/Equipment>
15
#include <KPublicTransport/IndividualTransport>
Nicolas Fella's avatar
Nicolas Fella committed
16
#include <KPublicTransport/Journey>
17
#include <KPublicTransport/JourneyQueryModel>
18
#include <KPublicTransport/JourneyRequest>
19
#include <KPublicTransport/Line>
Volker Krause's avatar
Volker Krause committed
20
#include <KPublicTransport/LocationQueryModel>
21
#include <KPublicTransport/LocationRequest>
22
#include <KPublicTransport/Manager>
Volker Krause's avatar
Volker Krause committed
23
24
#include <KPublicTransport/Path>
#include <KPublicTransport/PathModel>
25
#include <KPublicTransport/Platform>
26
#include <KPublicTransport/RentalVehicle>
27
#include <KPublicTransport/StopoverRequest>
28
#include <KPublicTransport/StopoverQueryModel>
29
30
31
#include <KPublicTransport/Vehicle>
#include <KPublicTransport/VehicleLayoutQueryModel>
#include <KPublicTransport/VehicleLayoutRequest>
Nicolas Fella's avatar
Nicolas Fella committed
32
33
34

void KPublicTransportQmlPlugin::registerTypes(const char*)
{
35
    qRegisterMetaType<KPublicTransport::Equipment>();
36
    qRegisterMetaType<KPublicTransport::Line>();
37
    qRegisterMetaType<KPublicTransport::Line::Mode>();
38
    qRegisterMetaType<KPublicTransport::LoadInfo>();
Volker Krause's avatar
Volker Krause committed
39
    qRegisterMetaType<KPublicTransport::Location>();
40
    qRegisterMetaType<KPublicTransport::Platform>();
41
    qRegisterMetaType<KPublicTransport::RentalVehicle>();
Volker Krause's avatar
Volker Krause committed
42
    qRegisterMetaType<KPublicTransport::Stopover>();
43
    qRegisterMetaType<KPublicTransport::IndividualTransport>();
44
45
    // backward compat
    qRegisterMetaType<KPublicTransport::StopoverRequest>("KPublicTransport::DepartureRequest");
Volker Krause's avatar
Volker Krause committed
46

47
    qmlRegisterUncreatableMetaObject(KPublicTransport::Disruption::staticMetaObject, "org.kde.kpublictransport", 1, 0, "Disruption", {});
48
    qmlRegisterUncreatableMetaObject(KPublicTransport::Load::staticMetaObject, "org.kde.kpublictransport", 1, 0, "Load", {});
49

Nicolas Fella's avatar
Nicolas Fella committed
50
    qmlRegisterUncreatableType<KPublicTransport::Line>("org.kde.kpublictransport", 1, 0, "Line", {});
Volker Krause's avatar
Volker Krause committed
51
    qmlRegisterUncreatableType<KPublicTransport::Location>("org.kde.kpublictransport", 1, 0, "Location", {});
Nicolas Fella's avatar
Nicolas Fella committed
52
    qmlRegisterUncreatableType<KPublicTransport::JourneySection>("org.kde.kpublictransport", 1, 0, "JourneySection", {});
53
    qmlRegisterUncreatableType<KPublicTransport::Vehicle>("org.kde.kpublictransport", 1, 0, "Vehicle", {});
Volker Krause's avatar
Volker Krause committed
54
    qmlRegisterUncreatableType<KPublicTransport::VehicleSection>("org.kde.kpublictransport", 1, 0, "VehicleSection", {});
Volker Krause's avatar
Volker Krause committed
55
    qmlRegisterUncreatableType<KPublicTransport::PathSection>("org.kde.kpublictransport", 1, 0, "PathSection", {});
56
    qmlRegisterUncreatableType<KPublicTransport::Platform>("org.kde.kpublictransport", 1, 0, "Platform", {});
57
    qmlRegisterUncreatableType<KPublicTransport::RentalVehicle>("org.kde.kpublictransport", 1, 0, "RentalVehicle", {});
58
    qmlRegisterUncreatableType<KPublicTransport::Equipment>("org.kde.kpublictransport", 1, 0, "Equipment", {});
59

60
    qmlRegisterUncreatableType<KPublicTransport::JourneyRequest>("org.kde.kpublictransport", 1, 0, "JourneyRequest", {});
61
    qmlRegisterUncreatableType<KPublicTransport::LocationRequest>("org.kde.kpublictransport", 1, 0, "LocationRequest", {});
62
    qmlRegisterUncreatableType<KPublicTransport::StopoverRequest>("org.kde.kpublictransport", 1, 0, "StopoverRequest", {});
63
    qmlRegisterUncreatableType<KPublicTransport::VehicleLayoutRequest>("org.kde.kpublictransport", 1, 0, "VehicleLayoutRequery", {});
64
    qmlRegisterUncreatableType<KPublicTransport::IndividualTransport>("org.kde.kpublictransport", 1, 0, "IndividualTransport", {});
65
66
    // backward compat
    qmlRegisterUncreatableType<KPublicTransport::StopoverRequest>("org.kde.kpublictransport", 1, 0, "DepartureRequest", {});
67

68
    qmlRegisterType<KPublicTransport::Manager>("org.kde.kpublictransport", 1, 0, "Manager");
69
    qmlRegisterType<KPublicTransport::JourneyQueryModel>("org.kde.kpublictransport", 1, 0, "JourneyQueryModel");
Volker Krause's avatar
Volker Krause committed
70
    qmlRegisterType<KPublicTransport::LocationQueryModel>("org.kde.kpublictransport", 1, 0, "LocationQueryModel");
71
    qmlRegisterType<KPublicTransport::BackendModel>("org.kde.kpublictransport", 1, 0, "BackendModel");
72
    qmlRegisterType<KPublicTransport::StopoverQueryModel>("org.kde.kpublictransport", 1, 0, "StopoverQueryModel");
73
    qmlRegisterType<KPublicTransport::VehicleLayoutQueryModel>("org.kde.kpublictransport", 1, 0, "VehicleLayoutQueryModel");
Volker Krause's avatar
Volker Krause committed
74
    qmlRegisterType<KPublicTransport::PathModel>("org.kde.kpublictransport", 1, 0, "PathModel");
75
76
    // backward compat
    qmlRegisterType<KPublicTransport::StopoverQueryModel>("org.kde.kpublictransport", 1, 0, "DepartureQueryModel");
77
78
79
80

    qmlRegisterSingletonType("org.kde.kpublictransport", 1, 0, "LineMetaData", [](QQmlEngine*, QJSEngine *engine) -> QJSValue {
        return engine->toScriptValue(KPublicTransport::LineMetaDataWrapper());
    });
Nicolas Fella's avatar
Nicolas Fella committed
81
}