Commit 6e85129b authored by Volker Krause's avatar Volker Krause
Browse files

Fix ReservationHelper::equals always returning false

We miss explicit equal comparator registration for types held as variants
inside Reservation objects. Ideally this is something done in the library
eventually, but it's not straightforward to do early enough there, in
particular in static builds. So we do this here for now.

This fixes live data updates triggering reservation changes
unconditionally, and thus everything that follows from there.
parent 26a03e5c
......@@ -10,11 +10,21 @@
#include <KItinerary/Flight>
#include <KItinerary/Reservation>
#include <KItinerary/TrainTrip>
#include <KItinerary/Ticket>
#include <QDateTime>
using namespace KItinerary;
void ReservationHelper::setup()
{
QMetaType::registerEqualsComparator<BusTrip>();
QMetaType::registerEqualsComparator<Flight>();
QMetaType::registerEqualsComparator<Person>();
QMetaType::registerEqualsComparator<Ticket>();
QMetaType::registerEqualsComparator<TrainTrip>();
}
std::pair<QString, QString> ReservationHelper::lineNameAndNumber(const QVariant &res)
{
if (JsonLd::isA<TrainReservation>(res)) {
......
......@@ -16,6 +16,11 @@ class QVariant;
/** Helper methods for dealing with KItinerary reservation elements. */
namespace ReservationHelper
{
/** Type registration setup.
* @todo This should happen automatically in KItinerary!
*/
void setup();
std::pair<QString, QString> lineNameAndNumber(const QVariant &res);
bool equals(const QVariant &lhs, const QVariant &rhs);
......
......@@ -6,6 +6,7 @@
#include "reservationmanager.h"
#include "pkpassmanager.h"
#include "reservationhelper.h"
#include "logging.h"
#include <KItinerary/ExtractorEngine>
......@@ -55,6 +56,8 @@ static bool isSameTrip(const QVariant &lhs, const QVariant &rhs)
ReservationManager::ReservationManager(QObject* parent)
: QObject(parent)
{
ReservationHelper::setup();
m_validator.setAcceptedTypes<
BusReservation,
EventReservation,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment