KPublicTransport

abstractquerymodel.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_ABSTRACTQUERYMODEL_H
8#define KPUBLICTRANSPORT_ABSTRACTQUERYMODEL_H
9
10#include "kpublictransport_export.h"
11
12#include <QAbstractListModel>
13
14#include <memory>
15#include <vector>
16
17namespace KPublicTransport {
18
19class AbstractQueryModelPrivate;
20class Attribution;
21class Manager;
22
23/** Common base class for query models, do not use directly. */
24class KPUBLICTRANSPORT_EXPORT AbstractQueryModel : public QAbstractListModel
25{
26 Q_OBJECT
27
28 /** Sets the KPublicTransport::Manager instance. Necessary for this to work at all. */
29 Q_PROPERTY(KPublicTransport::Manager* manager READ manager WRITE setManager NOTIFY managerChanged)
30
31 /** @c true if there is still an ongoing network operation. */
32 Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged)
33 /** Contains the error message if all backends failed to provide a result. */
34 Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
35
36 /** Attributions for the provided data. */
37 Q_PROPERTY(QVariantList attributions READ attributionsVariant NOTIFY attributionsChanged)
38
39public:
40 ~AbstractQueryModel() override;
41
42 Manager* manager() const;
43 void setManager(Manager *mgr);
44
45 bool isLoading() const;
46 QString errorMessage() const;
47
48 /** The attribution information for the current model content. */
49 const std::vector<Attribution>& attributions() const;
50
51 /** Cancel ongoing query operations, but keep the results that are already there. */
52 Q_INVOKABLE void cancel();
53
54 /** Cancel any ongoing query operations, and clear the results. */
55 Q_INVOKABLE void clear();
56
57Q_SIGNALS:
58 void managerChanged();
59 void loadingChanged();
60 void errorMessageChanged();
61 void attributionsChanged();
62
63protected:
64 ///@cond internal
65 Q_DECL_HIDDEN explicit AbstractQueryModel(AbstractQueryModelPrivate *dd, QObject *parent);
66 std::unique_ptr<AbstractQueryModelPrivate> d_ptr;
67 ///@endcond
68
69private:
70 Q_DECL_HIDDEN QVariantList attributionsVariant() const;
71};
72
73}
74
75#endif // KPUBLICTRANSPORT_ABSTRACTQUERYMODEL_H
Common base class for query models, do not use directly.
Copyright and license information about the provided data.
Definition attribution.h:29
Entry point for starting public transport queries.
Definition manager.h:42
Query operations and data types for accessing realtime public transport information from online servi...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.