1 /* 2 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org> 3 4 SPDX-License-Identifier: LGPL-2.0-or-later 5 */ 6 7 #pragma once 8 9 #include "kitinerary_export.h" 10 11 class QVariant; 12 13 namespace KItinerary { 14 class Flight; 15 class Person; 16 17 /** Utilities for merging reservations or elements of them. */ 18 namespace MergeUtil 19 { 20 /** 21 * Checks if two Reservation or Trip values refer to the same booking element. 22 * 23 * This does not mean being exactly equal, but having matching identifying properties. 24 * What this means exactly depends on the data type: 25 * - Flights: booking reference, flight number and departure day match 26 * - Train trip: booking reference, train number and departure day match 27 * - Bus trip: booking ref and/or number and departure time match 28 * - Hotel booking: hotel name, booking reference and checkin day match 29 * 30 * For all reservation types, the Reservation::underName property is 31 * checked and either needs to be equal or absent in one of the values. 32 */ 33 KITINERARY_EXPORT bool isSame(const QVariant &lhs, const QVariant &rhs); 34 35 /** 36 * Checks if two Person objects refer to the same person. 37 * 38 * Essentially a case-insensitive comparison of the name components. 39 */ 40 KITINERARY_EXPORT bool isSamePerson(const Person &lhs, const Person &rhs); 41 42 /** 43 * Merge the two given objects. 44 * This is the same as JsonLdDocument::apply in most cases, but if one side 45 * can be determined to be "better", that one is preferred. 46 */ 47 KITINERARY_EXPORT QVariant merge(const QVariant &lhs, const QVariant &rhs); 48 } 49 50 } 51 52