TrainPage.qml 10.2 KB
Newer Older
1
/*
2
    SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
3

4
    SPDX-License-Identifier: LGPL-2.0-or-later
5
6
7
8
9
*/

import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
Volker Krause's avatar
Volker Krause committed
10
import org.kde.kirigami 2.12 as Kirigami
11
import org.kde.kpublictransport 1.0 as KPublicTransport
12
13
14
15
16
17
import org.kde.kitinerary 1.0
import org.kde.itinerary 1.0
import "." as App

App.DetailsPage {
    id: root
Volker Krause's avatar
Volker Krause committed
18
    title: i18n("Train Ticket")
19
20
21
22
23
    editor: Component {
        App.TrainEditor {
            batchId: root.batchId
        }
    }
24

25
26
    Component {
        id: alternativePage
27
        App.JourneyQueryPage {
28
            controller: root.controller
29
            publicTransportManager: LiveDataManager.publicTransportManager
30
31
32
        }
    }

33
34
35
36
    Component {
        id: vehicleLayoutPage
        App.VehicleLayoutPage {
            publicTransportManager: root.controller.liveDataManager.publicTransportManager
37
            selectedVehicleSection: root.reservation.reservedTicket.ticketedSeat.seatSection
38
            selectedClasses: root.reservation.reservedTicket.ticketedSeat.seatingType
39
            seat: root.reservation.reservedTicket.ticketedSeat.seatNumber
40
41
42
        }
    }

43
44
45
46
47
48
49
50
51
52
    Component {
        id: alternativeAction
        Kirigami.Action {
            text: i18n("Alternatives")
            iconName: "clock"
            onTriggered: {
                applicationWindow().pageStack.push(alternativePage);
            }
        }
    }
53
    Component {
54
        id: vehicleDepartureLayoutAction
55
        Kirigami.Action {
56
            text: i18n("Departure Vehicle Layout")
57
58
59
            iconName: "view-list-symbolic"
            enabled: departure && departure.route.line.mode == KPublicTransport.Line.LongDistanceTrain
            onTriggered: {
60
61
62
63
64
65
66
67
68
69
70
71
                applicationWindow().pageStack.push(vehicleLayoutPage, {"stopover": root.controller.departure});
            }
        }
    }
    Component {
        id: vehicleArrivalLayoutAction
        Kirigami.Action {
            text: i18n("Arrival Vehicle Layout")
            iconName: "view-list-symbolic"
            enabled: arrival && arrival.route.line.mode == KPublicTransport.Line.LongDistanceTrain
            onTriggered: {
                applicationWindow().pageStack.push(vehicleLayoutPage, {"stopover": root.controller.arrival});
72
73
74
            }
        }
    }
75
76
77
78
79
80
81
82
83
    Component {
        id: journeyDetailsAction
        Kirigami.Action {
            text: i18n("Journey Details")
            iconName: "view-calendar-day"
            onTriggered: applicationWindow().pageStack.push(journeySectionPage, {"journeySection": root.controller.journey});
            visible: root.controller.journey && root.controller.journey.intermediateStops.length > 0
        }
    }
84
85
86
87
88
    Component {
        id: notifyTestAction
        Kirigami.Action {
            text: "Test Notification"
            iconName: "notifications"
Volker Krause's avatar
Volker Krause committed
89
            visible: Settings.developmentMode
90
91
92
            onTriggered: LiveDataManager.showNotification(root.batchId)
        }
    }
93
94
95

    Component.onCompleted: {
        actions.contextualActions.push(alternativeAction.createObject(root));
96
        actions.contextualActions.push(journeyDetailsAction.createObject(root));
97
98
        actions.contextualActions.push(vehicleDepartureLayoutAction.createObject(root));
        actions.contextualActions.push(vehicleArrivalLayoutAction.createObject(root));
Volker Krause's avatar
Volker Krause committed
99
        actions.contextualActions.push(notifyTestAction.createObject(root));
100
101
    }

102
103
    ColumnLayout {
        width: parent.width
104
105

        QQC2.Label {
106
            Layout.fillWidth: true
107
            text: reservationFor.trainName + " " + reservationFor.trainNumber
108
109
110
111
112
113
            horizontalAlignment: Qt.AlignHCenter
            font.bold: true
        }

        // ticket barcode
        App.TicketTokenDelegate {
114
            resIds: ReservationManager.reservationsForBatch(root.batchId)
115
116
117
118
119
            onCurrentReservationIdChanged: {
                if (!currentReservationId)
                    return;
                root.currentReservationId = currentReservationId;
            }
120
121
        }

122
123
124
125
126
127
128
        Kirigami.FormLayout {
            Layout.fillWidth: true

            // departure data
            Kirigami.Separator {
                Kirigami.FormData.isSection: true
                Kirigami.FormData.label: i18n("Departure")
129
            }
130
            RowLayout {
131
                Kirigami.FormData.label: i18n("Departure time:")
132
133
134
135
136
137
138
139
                QQC2.Label {
                    text: Localizer.formatDateTime(reservationFor, "departureTime")
                }
                QQC2.Label {
                    text: (departure.departureDelay >= 0 ? "+" : "") + departure.departureDelay
                    color: (departure.departureDelay > 1) ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
                    visible: departure.hasExpectedDepartureTime
                }
140
            }
141
            QQC2.Label {
142
                Kirigami.FormData.label: i18nc("train station", "Station:")
143
144
145
146
                text: reservationFor.departureStation.name
            }
            App.PlaceDelegate {
                place: reservationFor.departureStation
Volker Krause's avatar
Volker Krause committed
147
148
                controller: root.controller
                isRangeBegin: true
149
150
151
            }
            RowLayout {
                Kirigami.FormData.label: i18n("Platform:")
152
                visible: departurePlatformLabel.text != ""
153
                QQC2.Label {
154
                    id: departurePlatformLabel
155
156
157
158
159
160
                    text: departure.hasExpectedPlatform ? departure.expectedPlatform : reservationFor.departurePlatform
                    color: departure.platformChanged ? Kirigami.Theme.negativeTextColor :
                        departure.hasExpectedPlatform ? Kirigami.Theme.positiveTextColor :
                        Kirigami.Theme.textColor;
                }
                QQC2.Label {
161
                    text: i18nc("previous platform", "(was: %1)", reservationFor.departurePlatform)
162
163
164
                    visible: departure.platformChanged && reservationFor.departurePlatform != ""
                }
            }
165
166
167
168
169
170
171
            QQC2.Label {
                Kirigami.FormData.isSection: true
                text: departure.notes.join("<br/>")
                textFormat: Text.RichText
                wrapMode: Text.Wrap
                visible: departure.notes.length > 0
                font.italic: true
172
                onLinkActivated: Qt.openUrlExternally(link)
173
            }
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189

            // arrival data
            Kirigami.Separator {
                Kirigami.FormData.isSection: true
                Kirigami.FormData.label: i18n("Arrival")
            }
            RowLayout {
                Kirigami.FormData.label: i18n("Arrival time:")
                QQC2.Label {
                    text: Localizer.formatDateTime(reservationFor, "arrivalTime")
                }
                QQC2.Label {
                    text: (arrival.arrivalDelay >= 0 ? "+" : "") + arrival.arrivalDelay
                    color: (arrival.arrivalDelay > 1) ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.positiveTextColor
                    visible: arrival.hasExpectedArrivalTime
                }
190
191
            }
            QQC2.Label {
192
                Kirigami.FormData.label: i18nc("train station", "Station:")
193
194
195
196
                text: reservationFor.arrivalStation.name
            }
            App.PlaceDelegate {
                place: reservationFor.arrivalStation
Volker Krause's avatar
Volker Krause committed
197
198
                controller: root.controller
                isRangeEnd: true
199
200
201
            }
            RowLayout {
                Kirigami.FormData.label: i18n("Platform:")
202
                visible: arrivalPlatformLabel.text != ""
203
                QQC2.Label {
204
                    id: arrivalPlatformLabel
205
206
207
208
209
210
                    text: arrival.hasExpectedPlatform ? arrival.expectedPlatform : reservationFor.arrivalPlatform
                    color: arrival.platformChanged ? Kirigami.Theme.negativeTextColor :
                        arrival.hasExpectedPlatform ? Kirigami.Theme.positiveTextColor :
                        Kirigami.Theme.textColor;
                }
                QQC2.Label {
211
                    text: i18nc("previous platform", "(was: %1)", reservationFor.arrivalPlatform)
212
213
                    visible: arrival.platformChanged && reservationFor.arrivalPlatform != ""
                }
214
            }
215
216
217
218
219
220
221
            QQC2.Label {
                Kirigami.FormData.isSection: true
                text: arrival.notes.join("<br/>")
                textFormat: Text.RichText
                wrapMode: Text.Wrap
                visible: arrival.notes.length > 0
                font.italic: true
222
                onLinkActivated: Qt.openUrlExternally(link)
223
            }
224

225
226
227
228
            // seat reservation
            Kirigami.Separator {
                Kirigami.FormData.label: i18n("Seat")
                Kirigami.FormData.isSection: true
Volker Krause's avatar
Volker Krause committed
229
230
231
                visible: reservation.reservedTicket.ticketedSeat.seatNumber != ""
                      || reservation.reservedTicket.ticketedSeat.seatSection != ""
                      || reservation.reservedTicket.ticketedSeat.seatingType != ""
232
            }
233
            QQC2.Label {
234
                Kirigami.FormData.label: i18nc("coach of a train", "Coach:")
235
236
                text: reservation.reservedTicket.ticketedSeat.seatSection
                visible: reservation.reservedTicket.ticketedSeat.seatSection != ""
237
238
            }
            QQC2.Label {
239
240
241
242
                Kirigami.FormData.label: i18n("Seat:")
                text: reservation.reservedTicket.ticketedSeat.seatNumber
                visible: reservation.reservedTicket.ticketedSeat.seatNumber != ""
            }
Volker Krause's avatar
Volker Krause committed
243
244
245
246
247
            QQC2.Label {
                Kirigami.FormData.label: i18n("Class:")
                text: reservation.reservedTicket.ticketedSeat.seatingType
                visible: reservation.reservedTicket.ticketedSeat.seatingType != ""
            }
248
249
250
251
252

            // booking details
            Kirigami.Separator {
                Kirigami.FormData.label: i18n("Booking")
                Kirigami.FormData.isSection: true
253
            }
254
            QQC2.Label {
255
256
                Kirigami.FormData.label: i18n("Reference:")
                text: reservation.reservationNumber
257
258
            }
            QQC2.Label {
259
260
                Kirigami.FormData.label: i18n("Under name:")
                text: reservation.underName.name
261
            }
262
263
264
        }
    }
}