KPublicTransport

locationquerymodel.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_LOCATIONQUERYMODEL_H
8#define KPUBLICTRANSPORT_LOCATIONQUERYMODEL_H
9
10#include "kpublictransport_export.h"
11#include "abstractquerymodel.h"
12
13#include <KPublicTransport/LocationRequest>
14
15namespace KPublicTransport {
16
17class Location;
18class LocationQueryModelPrivate;
19
20/**
21 * Model representing location query results.
22 * Intented as a basis for as-you-type completers for location searches.
23 */
24class 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 /** Delay in milliseconds until the query is actually performed.
31 * Useful when expecting high frequency changes to the request, eg. for completion during typing.
32 * @default no delay
33 */
34 Q_PROPERTY(int queryDelay READ queryDelay WRITE setQueryDelay NOTIFY queryDelayChanged)
35
36public:
37 explicit LocationQueryModel(QObject *parent = nullptr);
38 ~LocationQueryModel() override;
39
40 LocationRequest request() const;
41 void setRequest(const LocationRequest &req);
42
43 int queryDelay() const;
44 void setQueryDelay(int ms);
45
46 enum Roles {
47 LocationRole = Qt::UserRole
48 };
49 Q_ENUM(Roles)
50
51 int rowCount(const QModelIndex &parent) const override;
52 QVariant data(const QModelIndex &index, int role) const override;
53 QHash<int, QByteArray> roleNames() const override;
54
55 /** The current model content. */
56 const std::vector<Location>& locations() const;
57
58Q_SIGNALS:
59 void requestChanged();
60 void queryDelayChanged();
61
62private:
63 friend class LocationQueryModelPrivate;
64 Q_DECLARE_PRIVATE(LocationQueryModel)
65};
66
67}
68
69#endif // KPUBLICTRANSPORT_LOCATIONQUERYMODEL_H
Common base class for query models, do not use directly.
Model representing location query results.
Describes a location search.
Query operations and data types for accessing realtime public transport information from online servi...
UserRole
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.