Marble

AlternativeRoutesModel.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org>
4//
5
6#ifndef MARBLE_ALTERNATIVEROUTESMODEL_H
7#define MARBLE_ALTERNATIVEROUTESMODEL_H
8
9#include "marble_export.h"
10
11#include <QAbstractListModel>
12
13/**
14 * A QAbstractItemModel that contains a list of routing instructions.
15 * Each item represents a routing step in the way from source to
16 * destination. Steps near the source come first, steps near the target
17 * last.
18 */
19namespace Marble
20{
21
22class RouteRequest;
23class GeoDataDocument;
24class GeoDataLineString;
25
26class MARBLE_EXPORT AlternativeRoutesModel : public QAbstractListModel
27{
28 Q_OBJECT
29
30public:
31 enum WritePolicy {
32 Instant,
33 Lazy
34 };
35
36 /** Constructor */
37 explicit AlternativeRoutesModel(QObject *parent = nullptr);
38
39 /** Destructor */
40 ~AlternativeRoutesModel() override;
41
42 // Model querying
43
44 /** Overload of QAbstractListModel */
45 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
46
47 /** Overload of QAbstractListModel */
48 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
49
50 /** Overload of QAbstractListModel */
51 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
52
53 QHash<int, QByteArray> roleNames() const override;
54
55 const GeoDataDocument *route(int index) const;
56
57 // Model data filling
58
59 /** Invalidate the current alternative routes and prepare for new ones to arrive */
60 void newRequest(RouteRequest *request);
61
62 /**
63 * Old data in the model is discarded, the parsed content of the provided document
64 * is used as the new model data and a model reset is done
65 * @param document The route to add
66 * @param policy In lazy mode (default), a short amount of time is waited for
67 * other addRoute() calls before adding the route to the model. Otherwise, the
68 * model is changed immediately.
69 */
70 void addRoute(GeoDataDocument *document, WritePolicy policy = Lazy);
71
72 /** Remove all alternative routes from the model */
73 void clear();
74
75 const GeoDataDocument *currentRoute() const;
76
77 /** Returns the waypoints contained in the route as a linestring */
78 static const GeoDataLineString *waypoints(const GeoDataDocument *document);
79
80public Q_SLOTS:
81 void setCurrentRoute(int index);
82
83Q_SIGNALS:
84 void currentRouteChanged(const GeoDataDocument *newRoute);
85 void currentRouteChanged(int index);
86
87private Q_SLOTS:
88 void addRestrainedRoutes();
89
90private:
91 class Private;
92 Private *const d;
93};
94
95} // namespace Marble
96
97#endif
Binds a QML item to a specific geodetic location in screen coordinates.
@ Instant
Change camera position immediately (no interpolation)
DisplayRole
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.