Commit 9bddc259 authored by Volker Krause's avatar Volker Krause
Browse files

Show vehicle load information also in the journey summary

parent ee1f583e
......@@ -56,6 +56,7 @@ Kirigami.ScrollablePage {
App.JourneySummaryDelegate {
journey: top.journey
visible: journeyView.currentIndex != index
width: parent.width
}
QQC2.Button {
text: i18n("Save")
......
......@@ -13,8 +13,30 @@ import org.kde.itinerary 1.0
import "." as App
RowLayout {
id: root
property var journey
function maxLoad(loadInformation) {
var load = Load.Unknown;
for (var i = 0; i < loadInformation.length; ++i) {
load = Math.max(load, loadInformation[i].load);
}
return load;
}
readonly property int sectionWithMaxLoad: {
var loadMax = Load.Unknown;
var loadMaxIdx = -1;
for (var i = 0; journey != undefined && i < journey.sections.length; ++i) {
var l = maxLoad(journey.sections[i].loadInformation);
if (l > loadMax) {
loadMax = l;
loadMaxIdx = i;
}
}
return loadMaxIdx;
}
Repeater {
model: journey.sections
delegate: Kirigami.Icon {
......@@ -40,5 +62,10 @@ RowLayout {
}
QQC2.Label {
text: i18np("One change", "%1 changes", journey.numberOfChanges)
Layout.fillWidth: true
}
App.VehicleLoadIndicator {
loadInformation: sectionWithMaxLoad < 0 ? undefined : root.journey.sections[sectionWithMaxLoad].loadInformation
}
}
......@@ -72,6 +72,7 @@ Kirigami.AbstractCard {
App.JourneySummaryDelegate {
journey: transfer.journey
visible: transfer.state == Transfer.Selected && !journeyDetailsExpanded
width: parent.width
}
QQC2.Button {
text: i18n("Select...")
......
......@@ -88,6 +88,7 @@ Kirigami.ScrollablePage {
App.JourneySummaryDelegate {
journey: top.journey
visible: journeyView.currentIndex != index
width: parent.width
}
QQC2.Button {
text: i18n("Select")
......
......@@ -18,7 +18,7 @@ Item {
readonly property var maxLoad: {
var load = Load.Unknown;
for (var i = 0; i < loadInformation.length; ++i) {
for (var i = 0; loadInformation != undefined && i < loadInformation.length; ++i) {
load = Math.max(load, loadInformation[i].load);
}
return load;
......
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