KPublicTransport

abstractquerymodel.h
1 /*
2  SPDX-FileCopyrightText: 2019 Volker Krause <[email protected]>
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 
17 namespace KPublicTransport {
18 
19 class AbstractQueryModelPrivate;
20 class Attribution;
21 class Manager;
22 
23 /** Common base class for query models, do not use directly. */
24 class 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 
39 public:
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 
57 Q_SIGNALS:
58  void managerChanged();
59  void loadingChanged();
60  void errorMessageChanged();
61  void attributionsChanged();
62 
63 protected:
64  ///@cond internal
65  Q_DECL_HIDDEN explicit AbstractQueryModel(AbstractQueryModelPrivate *dd, QObject *parent);
66  std::unique_ptr<AbstractQueryModelPrivate> d_ptr;
67  ///@endcond
68 
69 private:
70  Q_DECL_HIDDEN QVariantList attributionsVariant() const;
71 };
72 
73 }
74 
75 #endif // KPUBLICTRANSPORT_ABSTRACTQUERYMODEL_H
Query operations and data types for accessing realtime public transport information from online servi...
Definition: attribution.cpp:16
Copyright and license information about the provided data.
Definition: attribution.h:28
Common base class for query models, do not use directly.
Entry point for starting public transport queries.
Definition: manager.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Oct 15 2021 23:07:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.