Marble

RoutingModel.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_ROUTINGMODEL_H
7#define MARBLE_ROUTINGMODEL_H
8
9#include "marble_export.h"
10
11#include <QAbstractListModel>
12
13class QIODevice;
14
15/**
16 * A QAbstractItemModel that contains a list of routing instructions.
17 * Each item represents a routing step in the way from source to
18 * destination. Steps near the source come first, steps near the target
19 * last.
20 */
21namespace Marble
22{
23
24class RoutingModelPrivate;
25class Route;
26class RouteRequest;
27class GeoDataCoordinates;
28class PositionTracking;
29
30class MARBLE_EXPORT RoutingModel : public QAbstractListModel
31{
32 Q_OBJECT
33
34 Q_PROPERTY( bool deviatedFromRoute READ deviatedFromRoute NOTIFY deviatedFromRoute )
35
36public:
37 enum RoutingModelRoles {
38 CoordinateRole = Qt::UserRole + 3,
39 TurnTypeIconRole,
40 LongitudeRole,
41 LatitudeRole
42 };
43
44 /** Constructor */
45 explicit RoutingModel(RouteRequest *request, PositionTracking *positionTracking, QObject *parent = nullptr);
46
47 /** Destructor */
48 ~RoutingModel() override;
49
50 // Model querying
51
52 /** Overload of QAbstractListModel */
53 int rowCount ( const QModelIndex &parent = QModelIndex() ) const override;
54
55 /** Overload of QAbstractListModel */
56 QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
57
58 /** Overload of QAbstractListModel */
59 QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
60
61 /** Overload of QAbstractListModel */
62 QHash<int, QByteArray> roleNames() const override;
63
64 // Model data filling
65
66 /**
67 * Export waypoints and instructions in gpx format
68 */
69 void exportGpx( QIODevice *device ) const;
70
71 /**
72 * Clear any data held in the model
73 */
74 void clear();
75
76 /**
77 * Maps points from the provided route request to waypoints in the model
78 * according to their global minimal distance. Returns the right neighbor
79 * (next route request item along the waypoints) of the provided position.
80 * Provided route must not be null.
81 * @return -1 If the provided route is empty, the index of the right
82 * neighbor along the waypoints otherwise (result is a valid RouteRequest
83 * index in that case)
84 */
85 int rightNeighbor( const GeoDataCoordinates &position, RouteRequest const *const route ) const;
86
87 /**
88 * returns whether the gps location is on route
89 */
90 bool deviatedFromRoute() const;
91
92 const Route & route() const;
93
94public Q_SLOTS:
95 /**
96 * Old data in the model is discarded and a model reset is done
97 */
98 void setRoute( const Route &route );
99
100 void updatePosition( const GeoDataCoordinates&, qreal );
101
102Q_SIGNALS:
103 /**
104 * emits a signal regarding information about total time( seconds ) and distance( metres ) remaining to reach destination
105 */
106 void positionChanged();
107 void deviatedFromRoute( bool deviated );
108
109 /** A different route was loaded */
110 void currentRouteChanged();
111
112private:
113 RoutingModelPrivate *const d;
114};
115
116} // namespace Marble
117
118#endif
KGuiItem clear()
Binds a QML item to a specific geodetic location in screen coordinates.
UserRole
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.