KPublicTransport

stopoverquerymodel.h
1/*
2 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KPUBLICTRANSPORT_STOPOVERQUERYMODEL_H
8#define KPUBLICTRANSPORT_STOPOVERQUERYMODEL_H
9
10#include "kpublictransport_export.h"
11#include "abstractquerymodel.h"
12
13#include <KPublicTransport/StopoverRequest>
14
15namespace KPublicTransport {
16
17class Stopover;
18class StopoverQueryModelPrivate;
19
20/**
21 * Model representing arrival or departure query results.
22 * This takes care of dynamically updating as results arrive from different
23 * backends, including merging them, as well as providing a way to search
24 * for earlier/later arrivals/departures for the initial request.
25 */
26class KPUBLICTRANSPORT_EXPORT StopoverQueryModel : public AbstractQueryModel
27{
29
30 /** Specify the actual departure query. */
31 Q_PROPERTY(KPublicTransport::StopoverRequest request READ request WRITE setRequest NOTIFY requestChanged)
32
33 /** Whether querying for later departures is possible. */
34 Q_PROPERTY(bool canQueryNext READ canQueryNext NOTIFY canQueryPrevNextChanged)
35 /** Whether querying for earlier journey is possible. */
36 Q_PROPERTY(bool canQueryPrevious READ canQueryPrevious NOTIFY canQueryPrevNextChanged)
37
38public:
39 explicit StopoverQueryModel(QObject *parent = nullptr);
40 ~StopoverQueryModel() override;
41
43 void setRequest(const StopoverRequest &req);
44
45 bool canQueryNext() const;
46 /** Search for later journeys.
47 * Has no effect if canQueryNext() returns @c false.
48 */
50
51 bool canQueryPrevious() const;
52 /** Search for earlier journeys.
53 * Has no effect if canQueryPrevious() returns @c false.
54 */
56
57 enum Roles {
58 DepartureRole = Qt::UserRole
59 };
60 Q_ENUM(Roles)
61
62 int rowCount(const QModelIndex &parent) const override;
63 QVariant data(const QModelIndex &index, int role) const override;
64 QHash<int, QByteArray> roleNames() const override;
65
66 /** The current model content. */
67 const std::vector<Stopover>& departures() const;
68
69Q_SIGNALS:
70 void requestChanged();
71 void canQueryPrevNextChanged();
72
73private:
74 friend class StopoverQueryModelPrivate;
75 Q_DECLARE_PRIVATE(StopoverQueryModel)
76};
77
78}
79
80#endif // KPUBLICTRANSPORT_STOPOVERQUERYMODEL_H
Common base class for query models, do not use directly.
Model representing arrival or departure query results.
bool canQueryNext
Whether querying for later departures is possible.
KPublicTransport::StopoverRequest request
Specify the actual departure query.
Q_INVOKABLE void queryNext()
Search for later journeys.
bool canQueryPrevious
Whether querying for earlier journey is possible.
Q_INVOKABLE void queryPrevious()
Search for earlier journeys.
Describes an arrival or departure search.
Information about an arrival and/or departure of a vehicle at a stop area.
Definition stopover.h:26
Query operations and data types for accessing realtime public transport information from online servi...
virtual QModelIndex parent(const QModelIndex &index) const const=0
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 11:52:18 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.