reservationmanager.h 1.92 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
    Copyright (C) 2018 Volker Krause <vkrause@kde.org>

    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 <http://www.gnu.org/licenses/>.
*/

#ifndef RESERVATIONMANAGER_H
#define RESERVATIONMANAGER_H

21 22
#include <KItinerary/ExtractorRepository>

23 24
#include <QHash>
#include <QObject>
25
#include <QVariant>
26

27 28
class PkPassManager;

Volker Krause's avatar
Volker Krause committed
29 30
class QUrl;

31 32 33 34 35 36 37 38
/** Manages JSON-LD reservation data. */
class ReservationManager : public QObject
{
    Q_OBJECT
public:
    ReservationManager(QObject *parent = nullptr);
    ~ReservationManager();

39 40
    void setPkPassManager(PkPassManager *mgr);

41 42 43
    QVector<QString> reservations() const;
    QVariant reservation(const QString &id) const;

Volker Krause's avatar
Volker Krause committed
44
    Q_INVOKABLE void importReservation(const QUrl &filename);
45
    Q_INVOKABLE void addReservation(const QVariant &res);
46 47 48 49 50 51 52 53
    void removeReservation(const QString &id);

signals:
    void reservationAdded(const QString &id);
    void reservationUpdated(const QString &id);
    void reservationRemoved(const QString &id);

private:
54 55 56 57 58 59
    void importReservations(const QVector<QVariant> &resData);

    void passAdded(const QString &passId);
    void passUpdated(const QString &passId);
    void passRemoved(const QString &passId);

60
    mutable QHash<QString, QVariant> m_reservations;
61 62
    PkPassManager *m_passMgr = nullptr;
    KItinerary::ExtractorRepository m_extractorRepo;
63 64 65
};

#endif // RESERVATIONMANAGER_H