diff --git a/src/app/BusPage.qml b/src/app/BusPage.qml index e7cc055..967a6d3 100644 --- a/src/app/BusPage.qml +++ b/src/app/BusPage.qml @@ -1,104 +1,105 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.5 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.1 as QQC2 import org.kde.kirigami 2.4 as Kirigami import org.kde.kitinerary 1.0 import org.kde.itinerary 1.0 import "." as App App.DetailsPage { id: root title: i18n("Bus Ticket") Kirigami.FormLayout { width: root.width + Component.onCompleted: Util.fixFormLayoutTouchTransparency(this) QQC2.Label { Kirigami.FormData.isSection: true text: reservationFor.busName + " " + reservationFor.busNumber horizontalAlignment: Qt.AlignHCenter font.bold: true } // ticket barcode App.TicketTokenDelegate { Kirigami.FormData.isSection: true resIds: root.resIds } // 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.departureStation.name } App.PlaceDelegate { place: reservationFor.departureStation } // 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.arrivalStation.name } App.PlaceDelegate { place: reservationFor.arrivalStation } // seat reservation Kirigami.Separator { Kirigami.FormData.label: i18n("Seat") Kirigami.FormData.isSection: true } QQC2.Label { Kirigami.FormData.label: i18n("Seat:") text: reservation.reservedTicket.ticketedSeat.seatNumber } // 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 } } } diff --git a/src/app/EventPage.qml b/src/app/EventPage.qml index 602a3b7..09f0adb 100644 --- a/src/app/EventPage.qml +++ b/src/app/EventPage.qml @@ -1,63 +1,63 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.5 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.1 as QQC2 import org.kde.kirigami 2.4 as Kirigami import org.kde.kitinerary 1.0 import org.kde.itinerary 1.0 import "." as App App.DetailsPage { id: root title: i18n("Event") Kirigami.FormLayout { - id: layout width: root.width + Component.onCompleted: Util.fixFormLayoutTouchTransparency(this) QQC2.Label { Kirigami.FormData.isSection: true text: reservationFor.name horizontalAlignment: Qt.AlignHCenter font.bold: true } QQC2.Label { Kirigami.FormData.label: i18n("Location:") text: reservationFor.location.name } App.PlaceDelegate { place: reservationFor.location } QQC2.Label { Kirigami.FormData.label: i18n("Entrance:") text: Localizer.formatDateTime(reservationFor, "doorTime") } QQC2.Label { Kirigami.FormData.label: i18n("Start Time:") text: Localizer.formatDateTime(reservationFor, "startDate") } QQC2.Label { Kirigami.FormData.label: i18n("End Time:") text: Localizer.formatDateTime(reservationFor, "endDate") } } } diff --git a/src/app/FlightPage.qml b/src/app/FlightPage.qml index bb3137f..c535830 100644 --- a/src/app/FlightPage.qml +++ b/src/app/FlightPage.qml @@ -1,132 +1,133 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.5 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.1 as QQC2 import org.kde.kirigami 2.4 as Kirigami import org.kde.kitinerary 1.0 import org.kde.itinerary 1.0 import "." as App App.DetailsPage { id: root title: i18n("Flight") editor: Component { App.FlightEditor { resIds: root.resIds } } Kirigami.FormLayout { width: root.width + Component.onCompleted: Util.fixFormLayoutTouchTransparency(this) QQC2.Label { Kirigami.FormData.isSection: true text: reservationFor.airline.iataCode + " " + reservationFor.flightNumber horizontalAlignment: Qt.AlignHCenter font.bold: true } // ticket barcode App.TicketTokenDelegate { Kirigami.FormData.isSection: true resIds: root.resIds } // flight details Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: i18n("Flight") } QQC2.Label { Kirigami.FormData.label: i18n("Boarding:") text: Localizer.formatDateTime(reservationFor, "boardingTime") } QQC2.Label { Kirigami.FormData.label: i18n("Boarding group:") text: reservation.boardingGroup } QQC2.Label { Kirigami.FormData.label: i18n("Seat:") text: reservation.airplaneSeat } QQC2.Label { Kirigami.FormData.label: i18n("Airline:") text: reservationFor.airline.name } // 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("Airport:") text: reservationFor.departureAirport.name + " (" + reservationFor.departureAirport.iataCode + ")" } App.PlaceDelegate { place: reservationFor.departureAirport } QQC2.Label { Kirigami.FormData.label: i18n("Terminal:") text: reservationFor.departureTerminal } QQC2.Label { Kirigami.FormData.label: i18n("Gate:") text: reservationFor.departureGate } // arrival data Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: i18n("Arrival") } QQC2.Label { Kirigami.FormData.label: i18n("Time:") text: Localizer.formatDateTime(reservationFor, "arrivalTime") } QQC2.Label { Kirigami.FormData.label: i18n("Airport:") text: reservationFor.arrivalAirport.name + " (" + reservationFor.arrivalAirport.iataCode + ")" } App.PlaceDelegate { place: reservationFor.arrivalAirport } // booking details Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: i18n("Booking") } QQC2.Label { Kirigami.FormData.label: i18n("Reference:") text: reservation.reservationNumber } QQC2.Label { Kirigami.FormData.label: i18n("Under name:") text: reservation.underName.name } } } diff --git a/src/app/HotelPage.qml b/src/app/HotelPage.qml index e3fe849..78f4ebf 100644 --- a/src/app/HotelPage.qml +++ b/src/app/HotelPage.qml @@ -1,73 +1,74 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.5 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.1 as QQC2 import org.kde.kirigami 2.4 as Kirigami import org.kde.kitinerary 1.0 import org.kde.itinerary 1.0 import "." as App App.DetailsPage { id: root title: i18n("Hotel Reservation") Kirigami.FormLayout { width: root.width + Component.onCompleted: Util.fixFormLayoutTouchTransparency(this) QQC2.Label { Kirigami.FormData.isSection: true text: reservationFor.name horizontalAlignment: Qt.AlignHCenter font.bold: true } App.PlaceDelegate { Kirigami.FormData.label: i18n("Location:") place: reservationFor } // TODO make these interactive QQC2.Label { Kirigami.FormData.label: i18n("Telephone:") text: reservationFor.telephone } QQC2.Label { Kirigami.FormData.label: i18n("Email:") text: reservationFor.email } QQC2.Label { Kirigami.FormData.label: i18n("Check-in time:") text: Localizer.formatDateTime(reservation, "checkinTime") } QQC2.Label { Kirigami.FormData.label: i18n("Check-out time:") text: Localizer.formatDateTime(reservation, "checkoutTime") } QQC2.Label { Kirigami.FormData.label: i18n("Booking reference:") text: reservation.reservationNumber } QQC2.Label { Kirigami.FormData.label: i18n("Under name:") text: reservation.underName.name } } } diff --git a/src/app/RestaurantPage.qml b/src/app/RestaurantPage.qml index 44bfd3f..ae61655 100644 --- a/src/app/RestaurantPage.qml +++ b/src/app/RestaurantPage.qml @@ -1,81 +1,82 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.5 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.1 as QQC2 import org.kde.kirigami 2.4 as Kirigami import org.kde.kitinerary 1.0 import org.kde.itinerary 1.0 import "." as App App.DetailsPage { id: root title: i18n("Restaurant Reservation") editor: Component { App.RestaurantEditor { resIds: root.resIds } } Kirigami.FormLayout { width: root.width + Component.onCompleted: Util.fixFormLayoutTouchTransparency(this) QQC2.Label { Kirigami.FormData.isSection: true text: reservationFor.name horizontalAlignment: Qt.AlignHCenter font.bold: true } App.PlaceDelegate { Kirigami.FormData.label: i18n("Location:") place: reservationFor } QQC2.Label { Kirigami.FormData.label: i18n("Telephone:") text: reservationFor.telephone } QQC2.Label { Kirigami.FormData.label: i18n("Email:") text: reservationFor.email } QQC2.Label { Kirigami.FormData.label: i18n("Start time:") text: Localizer.formatDateTime(reservation, "startTime") } QQC2.Label { Kirigami.FormData.label: i18n("End time:") text: Localizer.formatDateTime(reservation, "endTime") } QQC2.Label { Kirigami.FormData.label: i18n("Party size:") text: reservation.partySize } QQC2.Label { Kirigami.FormData.label: i18n("Booking reference:") text: reservation.reservationNumber } QQC2.Label { Kirigami.FormData.label: i18n("Under name:") text: reservation.underName.name } } } diff --git a/src/app/TouristAttractionPage.qml b/src/app/TouristAttractionPage.qml index d2c9ef7..7cf2d00 100644 --- a/src/app/TouristAttractionPage.qml +++ b/src/app/TouristAttractionPage.qml @@ -1,57 +1,57 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.5 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.1 as QQC2 import org.kde.kirigami 2.4 as Kirigami import org.kde.kitinerary 1.0 import org.kde.itinerary 1.0 import "." as App App.DetailsPage { id: root readonly property var touristAttraction: _reservationManager.reservation(root.resIds[0]).touristAttraction title: i18n("Tourist Attraction") Kirigami.FormLayout { - id: layout width: root.width + Component.onCompleted: Util.fixFormLayoutTouchTransparency(this) QQC2.Label { Kirigami.FormData.isSection: true text: touristAttraction.name horizontalAlignment: Qt.AlignHCenter font.bold: true } App.PlaceDelegate { Kirigami.FormData.label: i18n("Location:") place: touristAttraction } QQC2.Label { Kirigami.FormData.label: i18n("Arrival Time:") text: Localizer.formatDateTime(reservation, "arrivalTime") } QQC2.Label { Kirigami.FormData.label: i18n("Departure Time:") text: Localizer.formatDateTime(reservation, "departureTime") } } } diff --git a/src/app/TrainPage.qml b/src/app/TrainPage.qml index 0ecdd05..39d6351 100644 --- a/src/app/TrainPage.qml +++ b/src/app/TrainPage.qml @@ -1,116 +1,117 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.5 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.1 as QQC2 import org.kde.kirigami 2.4 as Kirigami import org.kde.kitinerary 1.0 import org.kde.itinerary 1.0 import "." as App App.DetailsPage { id: root title: i18n("Train Ticket") Kirigami.FormLayout { width: root.width + Component.onCompleted: Util.fixFormLayoutTouchTransparency(this) QQC2.Label { Kirigami.FormData.isSection: true text: reservationFor.trainName + " " + reservationFor.trainNumber horizontalAlignment: Qt.AlignHCenter font.bold: true } // ticket barcode App.TicketTokenDelegate { Kirigami.FormData.isSection: true resIds: root.resIds } // 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.departureStation.name } App.PlaceDelegate { place: reservationFor.departureStation } QQC2.Label { Kirigami.FormData.label: i18n("Platform:") text: reservationFor.departurePlatform } // arrival data Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: i18n("Arrival") } QQC2.Label { Kirigami.FormData.label: i18n("Arrival time:") text: Localizer.formatDateTime(reservationFor, "arrivalTime") } QQC2.Label { Kirigami.FormData.label: i18n("Station:") text: reservationFor.arrivalStation.name } App.PlaceDelegate { place: reservationFor.arrivalStation } QQC2.Label { Kirigami.FormData.label: i18n("Platform:") text: reservationFor.arrivalPlatform } // seat reservation Kirigami.Separator { Kirigami.FormData.label: i18n("Seat") Kirigami.FormData.isSection: true } QQC2.Label { Kirigami.FormData.label: i18n("Coach:") text: reservation.reservedTicket.ticketedSeat.seatSection } QQC2.Label { Kirigami.FormData.label: i18n("Seat:") text: reservation.reservedTicket.ticketedSeat.seatNumber } // 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 } } } diff --git a/src/app/util.cpp b/src/app/util.cpp index 4292d75..191d494 100644 --- a/src/app/util.cpp +++ b/src/app/util.cpp @@ -1,56 +1,66 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "util.h" #include #include #include +#include using namespace KItinerary; Util::Util(QObject* parent) : QObject(parent) { } Util::~Util() = default; QDateTime Util::dateTimeStripTimezone(const QVariant& obj, const QString& propertyName) const { auto dt = JsonLdDocument::readProperty(obj, propertyName.toUtf8().constData()).value(); if (!dt.isValid()) { return {}; } dt.setTimeSpec(Qt::LocalTime); return dt; } QVariant Util::setDateTimePreserveTimezone(const QVariant &obj, const QString& propertyName, QDateTime value) const { QVariant o(obj); const auto oldDt = JsonLdDocument::readProperty(obj, propertyName.toUtf8().constData()).value(); if (oldDt.isValid()) { value.setTimeZone(oldDt.timeZone()); } JsonLdDocument::writeProperty(o, propertyName.toUtf8().constData(), value); return o; } +void Util::fixFormLayoutTouchTransparency(QObject *obj) const +{ + // HACK: this seems very wrong, but it actually makes touch screen scrolling work... + QQuickItem *item = qobject_cast(obj); + if (item) { + item->setAcceptedMouseButtons(Qt::AllButtons); + } +} + #include "moc_util.cpp" diff --git a/src/app/util.h b/src/app/util.h index e09f2a1..4dd26ef 100644 --- a/src/app/util.h +++ b/src/app/util.h @@ -1,41 +1,44 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef UTIL_H #define UTIL_H #include class QDateTime; /** Misc utilities. */ class Util : public QObject { Q_OBJECT public: explicit Util(QObject *parent = nullptr); ~Util(); // workarounds for JS not preserving timezones /** Read a QDateTime property with the timezone stripped off. */ Q_INVOKABLE QDateTime dateTimeStripTimezone(const QVariant &obj, const QString &propertyName) const; /** Set a QDateTime property preserving the timezone of the current value. */ Q_INVOKABLE QVariant setDateTimePreserveTimezone(const QVariant &obj, const QString &propertyName, QDateTime value) const; + + /** HACK make Kirigami.FormLayout transparent for touch events so we can scroll. */ + Q_INVOKABLE void fixFormLayoutTouchTransparency(QObject *obj) const; }; #endif // UTIL_H