BusPage.qml 4.77 KB
Newer Older
Volker Krause's avatar
Volker Krause committed
1
/*
2
    SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
Volker Krause's avatar
Volker Krause committed
3

4
    SPDX-License-Identifier: LGPL-2.0-or-later
Volker Krause's avatar
Volker Krause committed
5
6
7
8
9
*/

import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
10
import org.kde.kirigami 2.17 as Kirigami
Volker Krause's avatar
Volker Krause committed
11
12
13
14
15
16
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
17
    title: i18n("Bus Ticket")
Volker Krause's avatar
Volker Krause committed
18

19
20
21
    Component {
        id: alternativePage
        App.JourneyQueryPage {
22
            controller: root.controller
23
            publicTransportManager: LiveDataManager.publicTransportManager
24
25
26
        }
    }

27
28
29
30
31
32
33
34
35
    actions.main: Kirigami.Action {
        icon.name: "view-barcode-qr"
        text: i18n("Barcode Scan Mode")
        onTriggered: scanModeController.toggle()
        visible: ticketToken.hasBarcode
        checkable: true
        checked: scanModeController.enabled
    }

36
37
38
39
40
41
42
43
44
45
    Component {
        id: alternativeAction
        Kirigami.Action {
            text: i18n("Alternatives")
            iconName: "clock"
            onTriggered: {
                applicationWindow().pageStack.push(alternativePage);
            }
        }
    }
46
47
48
49
50
51
52
53
54
    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
        }
    }
55
56

    Component.onCompleted: {
57
        actions.contextualActions.push(alternativeAction.createObject(root), journeyDetailsAction.createObject(root));
58
59
    }

60
61
62
63
64
    BarcodeScanModeController {
        id: scanModeController
        page: root
    }

65
66
    ColumnLayout {
        width: parent.width
Volker Krause's avatar
Volker Krause committed
67
68

        QQC2.Label {
69
            Layout.fillWidth: true
70
            text: reservationFor.busName + " " + reservationFor.busNumber
Volker Krause's avatar
Volker Krause committed
71
72
73
74
75
76
            horizontalAlignment: Qt.AlignHCenter
            font.bold: true
        }

        // ticket barcode
        App.TicketTokenDelegate {
77
            id: ticketToken
78
            resIds: ReservationManager.reservationsForBatch(root.batchId)
79
80
81
82
83
            onCurrentReservationIdChanged: {
                if (!currentReservationId)
                    return;
                root.currentReservationId = currentReservationId;
            }
84
            onScanModeToggled: scanModeController.toggle()
Volker Krause's avatar
Volker Krause committed
85
86
        }

87
88
        Kirigami.FormLayout {
            Layout.fillWidth: true
Volker Krause's avatar
Volker Krause committed
89

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
            // departure data
            Kirigami.Separator {
                Kirigami.FormData.isSection: true
                Kirigami.FormData.label: i18n("Departure")
            }
            QQC2.Label {
                Kirigami.FormData.label: i18n("Time:")
                text: Localizer.formatDateTime(reservationFor, "departureTime")
            }
            QQC2.Label {
                Kirigami.FormData.label: i18n("Station:")
                text: reservationFor.departureBusStop.name
            }
            App.PlaceDelegate {
                place: reservationFor.departureBusStop
Volker Krause's avatar
Volker Krause committed
105
106
                controller: root.controller
                isRangeBegin: true
107
            }
Volker Krause's avatar
Volker Krause committed
108

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
            // arrival data
            Kirigami.Separator {
                Kirigami.FormData.label: i18n("Arrival")
                Kirigami.FormData.isSection: true
            }
            QQC2.Label {
                Kirigami.FormData.label: i18n("Time:")
                text: Localizer.formatDateTime(reservationFor, "arrivalTime")
            }
            QQC2.Label {
                Kirigami.FormData.label: i18n("Station:")
                text: reservationFor.arrivalBusStop.name
            }
            App.PlaceDelegate {
                place: reservationFor.arrivalBusStop
Volker Krause's avatar
Volker Krause committed
124
125
                controller: root.controller
                isRangeEnd: true
126
            }
Volker Krause's avatar
Volker Krause committed
127

128
129
130
131
            // seat reservation
            Kirigami.Separator {
                Kirigami.FormData.label: i18n("Seat")
                Kirigami.FormData.isSection: true
132
                visible: seatLabel.visible
133
134
            }
            QQC2.Label {
135
                id: seatLabel
136
137
                Kirigami.FormData.label: i18n("Seat:")
                text: reservation.reservedTicket.ticketedSeat.seatNumber
138
                visible: text !== ""
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
            }

            // booking details
            Kirigami.Separator {
                Kirigami.FormData.label: i18n("Booking")
                Kirigami.FormData.isSection: true
            }
            QQC2.Label {
                Kirigami.FormData.label: i18n("Reference:")
                text: reservation.reservationNumber
            }
            QQC2.Label {
                Kirigami.FormData.label: i18n("Under name:")
                text: reservation.underName.name
            }
Volker Krause's avatar
Volker Krause committed
154
155
156
        }
    }
}