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 const GeoDataDocument *route(int index) const;
54
55 // Model data filling
56
57 /** Invalidate the current alternative routes and prepare for new ones to arrive */
58 void newRequest( RouteRequest *request );
59
60 /**
61 * Old data in the model is discarded, the parsed content of the provided document
62 * is used as the new model data and a model reset is done
63 * @param document The route to add
64 * @param policy In lazy mode (default), a short amount of time is waited for
65 * other addRoute() calls before adding the route to the model. Otherwise, the
66 * model is changed immediately.
67 */
68 void addRoute( GeoDataDocument* document, WritePolicy policy = Lazy );
69
70 /** Remove all alternative routes from the model */
71 void clear();
72
73 const GeoDataDocument *currentRoute() const;
74
75 /** Returns the waypoints contained in the route as a linestring */
76 static const GeoDataLineString* waypoints( const GeoDataDocument* document );
77
78public Q_SLOTS:
79 void setCurrentRoute( int index );
80
81Q_SIGNALS:
82 void currentRouteChanged(const GeoDataDocument *newRoute);
83 void currentRouteChanged( int index );
84
85private Q_SLOTS:
86 void addRestrainedRoutes();
87
88private:
89 class Private;
90 Private *const d;
91};
92
93} // namespace Marble
94
95#endif
KGuiItem clear()
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 Fri Jun 14 2024 11:54:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.