diff --git a/src/app/BusPage.qml b/src/app/BusPage.qml index 46c86cd..3ee54d9 100644 --- a/src/app/BusPage.qml +++ b/src/app/BusPage.qml @@ -1,105 +1,104 @@ /* 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: _reservationManager.reservationsForBatch(root.batchId) } // 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 } // 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 } // 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/CarRentalPage.qml b/src/app/CarRentalPage.qml index 5fed99e..73bf435 100644 --- a/src/app/CarRentalPage.qml +++ b/src/app/CarRentalPage.qml @@ -1,100 +1,99 @@ /* 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("Rental Car") Kirigami.FormLayout { width: root.width - Component.onCompleted: Util.fixFormLayoutTouchTransparency(this) Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: i18n("Pick-up") } QQC2.Label { Kirigami.FormData.label: i18n("Time:") text: Localizer.formatDateTime(reservation, "pickupTime") } QQC2.Label { Kirigami.FormData.label: i18n("Location:") text: reservation.pickupLocation.name } App.PlaceDelegate { place: reservation.pickupLocation } Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: i18n("Drop-off") } QQC2.Label { Kirigami.FormData.label: i18n("Time:") text: Localizer.formatDateTime(reservation, "pickupTime") } QQC2.Label { Kirigami.FormData.label: i18n("Location:") text: reservation.dropoffLocation.name } App.PlaceDelegate { place: reservation.dropoffLocation } Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: i18n("Vehicle") } QQC2.Label { Kirigami.FormData.label: i18n("Type:") text: reservationFor.name visible: reservationFor.name != "" } QQC2.Label { Kirigami.FormData.label: i18n("Model:") text: reservationFor.model visible: reservationFor.model != "" } QQC2.Label { Kirigami.FormData.label: i18n("Brand:") text: reservationFor.brand.name visible: reservationFor.brand.name != "" } Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: i18n("Reservation") } QQC2.Label { Kirigami.FormData.label: i18n("Under name:") text: reservation.underName.name } QQC2.Label { Kirigami.FormData.label: i18n("Reference:") text: reservation.reservationNumber } } } diff --git a/src/app/EventPage.qml b/src/app/EventPage.qml index 304ecb5..8f0eb06 100644 --- a/src/app/EventPage.qml +++ b/src/app/EventPage.qml @@ -1,68 +1,67 @@ /* 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 { width: root.width - Component.onCompleted: Util.fixFormLayoutTouchTransparency(this) QQC2.Label { Kirigami.FormData.isSection: true text: reservationFor.name horizontalAlignment: Qt.AlignHCenter font.bold: true } App.TicketTokenDelegate { Kirigami.FormData.isSection: true resIds: _reservationManager.reservationsForBatch(root.batchId) } 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 924e144..ede9fe6 100644 --- a/src/app/FlightPage.qml +++ b/src/app/FlightPage.qml @@ -1,152 +1,151 @@ /* 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") property var resIds: _reservationManager.reservationsForBatch(root.batchId) editor: Component { App.FlightEditor { batchId: root.batchId } } 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: _reservationManager.reservationsForBatch(root.batchId) onCurrentReservationIdChanged: root.currentReservationId = currentReservationId } // 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") visible: reservationFor.boardingTime > 0 } QQC2.Label { Kirigami.FormData.label: i18n("Boarding group:") text: reservation.boardingGroup visible: reservation.boardingGroup.length > 0 } QQC2.Label { Kirigami.FormData.label: i18n("Seat:") text: reservation.airplaneSeat visible: reservation.airplaneSeat.length > 0 } QQC2.Label { Kirigami.FormData.label: i18n("Airline:") text: reservationFor.airline.name visible: reservationFor.airline.name.length > 0 } // 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") visible: reservationFor.departureTime > 0 } QQC2.Label { Kirigami.FormData.label: i18n("Airport:") text: reservationFor.departureAirport.name + " (" + reservationFor.departureAirport.iataCode + ")" visible: reservationFor.departureAirport.name.length > 0 } App.PlaceDelegate { place: reservationFor.departureAirport } QQC2.Label { Kirigami.FormData.label: i18n("Terminal:") text: reservationFor.departureTerminal visible: reservationFor.departureTerminal.length > 0 } QQC2.Label { Kirigami.FormData.label: i18n("Gate:") text: reservationFor.departureGate visible: reservationFor.departureGate.length > 0 } // 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") visible: reservationFor.arrivalTime > 0 } QQC2.Label { Kirigami.FormData.label: i18n("Airport:") text: reservationFor.arrivalAirport.name + " (" + reservationFor.arrivalAirport.iataCode + ")" visible: reservationFor.arrivalAirport.name.length > 0 } App.PlaceDelegate { place: reservationFor.arrivalAirport } QQC2.Label { Kirigami.FormData.label: i18n("Terminal:") text: reservationFor.arrivalTerminal visible: reservationFor.arrivalTerminal.length > 0 } // booking details Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: i18n("Booking") } Repeater { model: resIds.length * 2 delegate: QQC2.Label { property var res: _reservationManager.reservation(resIds[Math.floor(index/2)]); Kirigami.FormData.label: index % 2 == 0 ? i18n("Under name:") : i18n("Reference:") text: index % 2 == 0 ? res.underName.name : res.reservationNumber } } } } diff --git a/src/app/HotelPage.qml b/src/app/HotelPage.qml index 01096d0..5e36bb5 100644 --- a/src/app/HotelPage.qml +++ b/src/app/HotelPage.qml @@ -1,74 +1,73 @@ /* 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 d4d7e73..f994183 100644 --- a/src/app/RestaurantPage.qml +++ b/src/app/RestaurantPage.qml @@ -1,82 +1,81 @@ /* 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 { batchId: root.batchId } } 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 da2c417..10184a3 100644 --- a/src/app/TouristAttractionPage.qml +++ b/src/app/TouristAttractionPage.qml @@ -1,57 +1,56 @@ /* 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.batchId).touristAttraction title: i18n("Tourist Attraction") Kirigami.FormLayout { 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 f95534f..196b66c 100644 --- a/src/app/TrainPage.qml +++ b/src/app/TrainPage.qml @@ -1,176 +1,175 @@ /* 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") property var arrival: _liveDataManager.arrival(batchId) property var departure: _liveDataManager.departure(batchId) Component { id: alternativePage App.TrainJourneyQueryPage { batchId: root.batchId } } Component { id: alternativeAction Kirigami.Action { text: i18n("Alternatives") iconName: "clock" onTriggered: { applicationWindow().pageStack.push(alternativePage); } } } Component.onCompleted: { actions.contextualActions.push(alternativeAction.createObject(root)); } 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: _reservationManager.reservationsForBatch(root.batchId) } // departure data Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: i18n("Departure") } RowLayout { Kirigami.FormData.label: i18n("Time:") 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 } } QQC2.Label { Kirigami.FormData.label: i18n("Station:") text: reservationFor.departureStation.name } App.PlaceDelegate { place: reservationFor.departureStation } RowLayout { Kirigami.FormData.label: i18n("Platform:") QQC2.Label { text: departure.hasExpectedPlatform ? departure.expectedPlatform : reservationFor.departurePlatform color: departure.platformChanged ? Kirigami.Theme.negativeTextColor : departure.hasExpectedPlatform ? Kirigami.Theme.positiveTextColor : Kirigami.Theme.textColor; } QQC2.Label { text: i18n("(was: %1)", reservationFor.departurePlatform) visible: departure.platformChanged && reservationFor.departurePlatform != "" } } // 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 } } QQC2.Label { Kirigami.FormData.label: i18n("Station:") text: reservationFor.arrivalStation.name } App.PlaceDelegate { place: reservationFor.arrivalStation } RowLayout { Kirigami.FormData.label: i18n("Platform:") QQC2.Label { text: arrival.hasExpectedPlatform ? arrival.expectedPlatform : reservationFor.arrivalPlatform color: arrival.platformChanged ? Kirigami.Theme.negativeTextColor : arrival.hasExpectedPlatform ? Kirigami.Theme.positiveTextColor : Kirigami.Theme.textColor; } QQC2.Label { text: i18n("(was: %1)", reservationFor.arrivalPlatform) visible: arrival.platformChanged && reservationFor.arrivalPlatform != "" } } // seat reservation Kirigami.Separator { Kirigami.FormData.label: i18n("Seat") Kirigami.FormData.isSection: true visible: reservation.reservedTicket.ticketedSeat.seatNumber != "" || reservation.reservedTicket.ticketedSeat.seatSection != "" } QQC2.Label { Kirigami.FormData.label: i18n("Coach:") text: reservation.reservedTicket.ticketedSeat.seatSection visible: reservation.reservedTicket.ticketedSeat.seatSection != "" } QQC2.Label { Kirigami.FormData.label: i18n("Seat:") text: reservation.reservedTicket.ticketedSeat.seatNumber visible: 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 7572036..9ff8be4 100644 --- a/src/app/util.cpp +++ b/src/app/util.cpp @@ -1,66 +1,56 @@ /* 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()).toDateTime(); 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()).toDateTime(); 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 bcdf0e3..aee0043 100644 --- a/src/app/util.h +++ b/src/app/util.h @@ -1,44 +1,41 @@ /* 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