File indexing completed on 2022-09-20 16:28:45

0001 /**
0002  * SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QDate>
0010 #include <QObject>
0011 #include <QTime>
0012 #include <QVariant>
0013 
0014 #include <KPublicTransport/JourneyRequest>
0015 #include <KPublicTransport/Location>
0016 #include <KPublicTransport/LocationRequest>
0017 #include <KPublicTransport/StopoverRequest>
0018 
0019 class Controller : public QObject
0020 {
0021     Q_OBJECT
0022     Q_PROPERTY(KPublicTransport::Location start READ start WRITE setStart NOTIFY startChanged)
0023     Q_PROPERTY(KPublicTransport::Location destination READ destination WRITE setDestination NOTIFY destinationChanged)
0024     Q_PROPERTY(QDate departureDate READ departureDate WRITE setDepartureDate NOTIFY departureDateChanged)
0025     Q_PROPERTY(QTime departureTime READ departureTime WRITE setDepartureTime NOTIFY departureTimeChanged)
0026 
0027 public:
0028     explicit Controller(QObject *parent = nullptr);
0029 
0030     KPublicTransport::Location start() const;
0031     void setStart(const KPublicTransport::Location &start);
0032 
0033     KPublicTransport::Location destination() const;
0034     void setDestination(const KPublicTransport::Location &destination);
0035 
0036     QDate departureDate() const;
0037     void setDepartureDate(const QDate &date);
0038 
0039     QTime departureTime() const;
0040     void setDepartureTime(const QTime &time);
0041 
0042     Q_INVOKABLE KPublicTransport::JourneyRequest createJourneyRequest();
0043     Q_INVOKABLE KPublicTransport::LocationRequest createLocationRequest(const QString &name);
0044     Q_INVOKABLE KPublicTransport::StopoverRequest createStopoverRequest();
0045 
0046     Q_INVOKABLE void showOnMap(KPublicTransport::Location location);
0047 
0048 Q_SIGNALS:
0049     void startChanged();
0050     void destinationChanged();
0051     void departureDateChanged();
0052     void departureTimeChanged();
0053 
0054 private:
0055     KPublicTransport::Location m_start;
0056     KPublicTransport::Location m_destination;
0057     QDate m_departureDate;
0058     QTime m_departureTime;
0059 };