Commit ee1f583e authored by Volker Krause's avatar Volker Krause
Browse files

Add a standalone test app for the journey query UI as well

This allows much easier testing of various scenarios without having to
have the corresponding bookings in the real app.
parent c48fddfc
......@@ -20,6 +20,7 @@ App.DetailsPage {
id: alternativePage
App.JourneyQueryPage {
controller: root.controller
publicTransportManager: LiveDataManager.publicTransportManager
}
}
......
......@@ -35,7 +35,7 @@ Rectangle {
QQC2.Label {
text: (journey.departureDelay >= 0 ? "+" : "") + journey.departureDelay;
color: journey.departureDelay > 1 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor;
visible: journey.hasExpectedDepartureTime && modelData.disruption != Disruption.NoService
visible: journey.hasExpectedDepartureTime && journey.disruption != Disruption.NoService
}
QQC2.Label {
......
......@@ -14,13 +14,13 @@ import "." as App
Kirigami.ScrollablePage {
property QtObject controller;
property alias publicTransportManager: journeyModel.manager
id: root
title: i18n("Alternative Connections")
JourneyQueryModel {
id: journeyModel
manager: LiveDataManager.publicTransportManager
request: controller.journeyRequest
}
......
......@@ -26,6 +26,7 @@ App.DetailsPage {
id: alternativePage
App.JourneyQueryPage {
controller: root.controller
publicTransportManager: LiveDataManager.publicTransportManager
}
}
......
......@@ -4,5 +4,8 @@
add_executable(pkpassviewer pkpassviewer.cpp pkpassviewer.qrc)
target_link_libraries(pkpassviewer itinerary)
add_executable(journeyquerytest journeyquerytest.cpp journeyquerytest.qrc)
target_link_libraries(journeyquerytest itinerary)
add_executable(vehiclelayoutviewer vehiclelayoutviewer.cpp vehiclelayoutviewer.qrc)
target_link_libraries(vehiclelayoutviewer itinerary)
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "publictransport.h"
#include "localizer.h"
#include "util.h"
#include <KPublicTransport/JourneyRequest>
#include <KPublicTransport/Location>
#include <KLocalizedContext>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QCommandLineParser>
#include <QDebug>
#include <QFile>
#include <QGuiApplication>
#include <QUrl>
#include <QSortFilterProxyModel>
int main(int argc, char **argv)
{
QCoreApplication::setApplicationName(QStringLiteral("journeyquerytest"));
QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication app(argc, argv);
QCommandLineParser parser;
parser.addHelpOption();
QCommandLineOption backendOpt(QStringLiteral("b"), QStringLiteral("KPT backend"), QStringLiteral("backend id"));
parser.addOption(backendOpt);
QCommandLineOption fromOpt(QStringLiteral("f"), QStringLiteral("Origin station name"), QStringLiteral("from"));
parser.addOption(fromOpt);
QCommandLineOption toOpt(QStringLiteral("t"), QStringLiteral("Desitination station name"), QStringLiteral("to"));
parser.addOption(toOpt);
parser.process(app);
if (!parser.isSet(fromOpt) || !parser.isSet(backendOpt) || !parser.isSet(backendOpt)) {
parser.showHelp(1);
}
KPublicTransport::JourneyRequest req;
req.setBackendIds({parser.value(backendOpt)});
KPublicTransport::Location from;
from.setName(parser.value(fromOpt));
req.setFrom(from);
KPublicTransport::Location to;
to.setName(parser.value(toOpt));
req.setTo(to);
req.setIncludeIntermediateStops(true);
qmlRegisterType<QSortFilterProxyModel>("org.kde.itinerary", 1, 0, "SortFilterProxyModel");
qmlRegisterSingletonType("org.kde.itinerary", 1, 0, "Localizer", [](QQmlEngine*, QJSEngine *engine) -> QJSValue { \
return engine->toScriptValue(Localizer()); \
});
qmlRegisterSingletonType("org.kde.itinerary", 1, 0, "PublicTransport", [](QQmlEngine*, QJSEngine *engine) -> QJSValue { \
return engine->toScriptValue(PublicTransport()); \
});
qmlRegisterSingletonType<Util>("org.kde.itinerary", 1, 0, "Util", [](QQmlEngine*, QJSEngine*) -> QObject*{
return new Util;
});
QQmlApplicationEngine engine;
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.rootContext()->setContextProperty(QStringLiteral("_request"), req);
engine.load(QStringLiteral("qrc:/journeyquerytest.qml"));
return app.exec();
}
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
import org.kde.kirigami 2.12 as Kirigami
import org.kde.kpublictransport 1.0 as KPT
import "." as App
Kirigami.ApplicationWindow {
title: "Journey Query Test"
reachableModeEnabled: false
width: 480
height: 720
pageStack.initialPage: jnyQueryPage
KPT.Manager {
id: ptMgr;
}
QtObject {
id: dummyController
property var journeyRequest: _request
}
Component {
id: journeySectionPage
App.JourneySectionPage {}
}
Component {
id: jnyQueryPage
App.JourneyQueryPage {
controller: dummyController
publicTransportManager: ptMgr
}
}
}
<!--
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: CC0-1.0
-->
<RCC>
<qresource prefix="/">
<file>journeyquerytest.qml</file>
<file alias="JourneyDelegateHeader.qml">../src/app/JourneyDelegateHeader.qml</file>
<file alias="JourneyQueryPage.qml">../src/app/JourneyQueryPage.qml</file>
<file alias="JourneySectionDelegate.qml">../src/app/JourneySectionDelegate.qml</file>
<file alias="JourneySectionPage.qml">../src/app/JourneySectionPage.qml</file>
<file alias="JourneySectionStopDelegate.qml">../src/app/JourneySectionStopDelegate.qml</file>
<file alias="JourneySummaryDelegate.qml">../src/app/JourneySummaryDelegate.qml</file>
<file alias="VehicleLoadIndicator.qml">../src/app/VehicleLoadIndicator.qml</file>
<file alias="images/bike.svg">../src/app/images/bike.svg</file>
<file alias="images/bus.svg">../src/app/images/bus.svg</file>
<file alias="images/cablecar.svg">../src/app/images/cablecar.svg</file>
<file alias="images/car.svg">../src/app/images/car.svg</file>
<file alias="images/coach.svg">../src/app/images/coach.svg</file>
<file alias="images/ferry.svg">../src/app/images/ferry.svg</file>
<file alias="images/flight.svg">../src/app/images/flight.svg</file>
<file alias="images/foodestablishment.svg">../src/app/images/foodestablishment.svg</file>
<file alias="images/funicular.svg">../src/app/images/funicular.svg</file>
<file alias="images/longdistancetrain.svg">../src/app/images/longdistancetrain.svg</file>
<file alias="images/rapidtransit.svg">../src/app/images/rapidtransit.svg</file>
<file alias="images/seat.svg">../src/app/images/seat.svg</file>
<file alias="images/shuttle.svg">../src/app/images/shuttle.svg</file>
<file alias="images/subway.svg">../src/app/images/subway.svg</file>
<file alias="images/taxi.svg">../src/app/images/taxi.svg</file>
<file alias="images/train.svg">../src/app/images/train.svg</file>
<file alias="images/tramway.svg">../src/app/images/tramway.svg</file>
<file alias="images/transfer.svg">../src/app/images/transfer.svg</file>
<file alias="images/wait.svg">../src/app/images/wait.svg</file>
<file alias="images/walk.svg">../src/app/images/walk.svg</file>
</qresource>
</RCC>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment