Commit 65484fcc authored by Volker Krause's avatar Volker Krause
Browse files

Expose path sections to QML

Still needs a proper model to compute headings and maneuver instructions.
parent a1468dd5
Pipeline #66122 passed with stage
in 1 minute and 11 seconds
......@@ -115,4 +115,9 @@ Path Path::fromJson(const QJsonObject &obj)
return path;
}
int Path::sectionCount() const
{
return d->sections.size();
}
#include "moc_path.cpp"
......@@ -61,6 +61,11 @@ class KPUBLICTRANSPORT_EXPORT Path
{
KPUBLICTRANSPORT_GADGET(Path)
/** Access to path sections for QML. */
Q_PROPERTY(std::vector<KPublicTransport::PathSection> sections READ sections)
/** Number of path sections for QML. */
Q_PROPERTY(int sectionCount READ sectionCount STORED false)
/** The length of this path in meters. */
Q_PROPERTY(int distance READ distance STORED false)
......@@ -82,11 +87,15 @@ public:
static QJsonObject toJson(const Path &path);
/** Deserialize an object from JSON. */
static Path fromJson(const QJsonObject &obj);
private:
int sectionCount() const;
};
}
Q_DECLARE_METATYPE(KPublicTransport::PathSection)
Q_DECLARE_METATYPE(std::vector<KPublicTransport::PathSection>)
Q_DECLARE_METATYPE(KPublicTransport::Path)
#endif // KPUBLICTRANSPORT_PATH_H
/*
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
Kirigami.ScrollablePage {
property var path
Component {
id: pathDelegate
Kirigami.BasicListItem {
text: modelData.description + " (" + modelData.distance + "m)"
}
}
ListView {
model: path.sections
delegate: pathDelegate
}
}
......@@ -324,7 +324,9 @@ Kirigami.ApplicationWindow {
}
onClicked: {
if (modelData.mode == JourneySection.PublicTransport) {
applicationWindow().pageStack.push(journeySectionPathPage, {"journeySection": modelData});
applicationWindow().pageStack.push(journeySectionPage, {"journeySection": modelData});
} else if ((modelData.mode == JourneySection.Walking || modelData.mode == JourneySection.Waiting) && modelData.path.sectionCount > 1) {
applicationWindow().pageStack.push(pathPage, {"path": modelData.path});
}
}
}
......@@ -338,10 +340,15 @@ Kirigami.ApplicationWindow {
}
Component {
id: journeySectionPathPage
id: journeySectionPage
JourneySectionPage {}
}
Component {
id: pathPage
PathPage {}
}
Component {
id: journyQueryPage
Kirigami.Page {
......
......@@ -10,6 +10,7 @@
<file>IndoorMapPage.qml</file>
<file>JourneySectionPage.qml</file>
<file>LocationDetailsSheet.qml</file>
<file>PathPage.qml</file>
<file>TestLocationsModel.qml</file>
<file>VehicleLayoutPage.qml</file>
</qresource>
......
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