KPublicTransport

locationquerymodel.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_LOCATIONQUERYMODEL_H
8 #define KPUBLICTRANSPORT_LOCATIONQUERYMODEL_H
9 
10 #include "kpublictransport_export.h"
11 #include "abstractquerymodel.h"
12 
13 #include <KPublicTransport/LocationRequest>
14 
15 namespace KPublicTransport {
16 
17 class Location;
18 class LocationQueryModelPrivate;
19 
20 /**
21  * Model representing location query results.
22  * Intented as a basis for as-you-type completers for location searches.
23  */
24 class KPUBLICTRANSPORT_EXPORT LocationQueryModel : public AbstractQueryModel
25 {
26  Q_OBJECT
27  /** Specify the actual location query. */
28  Q_PROPERTY(KPublicTransport::LocationRequest request READ request WRITE setRequest NOTIFY requestChanged)
29 
30 public:
31  explicit LocationQueryModel(QObject *parent = nullptr);
33 
34  LocationRequest request() const;
35  void setRequest(const LocationRequest &req);
36 
37  enum Roles {
38  LocationRole = Qt::UserRole
39  };
40  Q_ENUM(Roles)
41 
42  int rowCount(const QModelIndex &parent) const override;
43  QVariant data(const QModelIndex &index, int role) const override;
44  QHash<int, QByteArray> roleNames() const override;
45 
46  /** The current model content. */
47  const std::vector<Location>& locations() const;
48 
49 Q_SIGNALS:
50  void requestChanged();
51 
52 private:
53  friend class LocationQueryModelPrivate;
54  Q_DECLARE_PRIVATE(LocationQueryModel)
55 };
56 
57 }
58 
59 #endif // KPUBLICTRANSPORT_LOCATIONQUERYMODEL_H
Query operations and data types for accessing realtime public transport information from online servi...
Definition: attribution.cpp:16
Model representing location query results.
Definition: location.h:16
UserRole
Describes a location search.
Common base class for query models, do not use directly.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:05:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.