Marble

Maneuver.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2011 Dennis Nienhüser <nienhueser@kde.org>
4//
5
6#include "Maneuver.h"
7#include "MarbleDirs.h"
8
9#include <QHash>
10
11namespace Marble
12{
13
14static QHash<Maneuver::Direction, QString> createTurnTypePixmapMap()
15{
17
18 turnTypePixmaps.insert(Maneuver::Unknown, QStringLiteral(":/data/bitmaps/routing_step.png"));
19 turnTypePixmaps.insert(Maneuver::Straight, QStringLiteral(":/data/bitmaps/turn-continue.png"));
20 turnTypePixmaps.insert(Maneuver::Continue, QStringLiteral(":/data/bitmaps/turn-continue.png"));
21 turnTypePixmaps.insert(Maneuver::Merge, QStringLiteral(":/data/bitmaps/turn-merge.png"));
22 turnTypePixmaps.insert(Maneuver::SlightRight, QStringLiteral(":/data/bitmaps/turn-slight-right.png"));
23 turnTypePixmaps.insert(Maneuver::Right, QStringLiteral(":/data/bitmaps/turn-right.png"));
24 turnTypePixmaps.insert(Maneuver::SharpRight, QStringLiteral(":/data/bitmaps/turn-sharp-right.png"));
25 turnTypePixmaps.insert(Maneuver::TurnAround, QStringLiteral(":/data/bitmaps/turn-around.png"));
26 turnTypePixmaps.insert(Maneuver::SharpLeft, QStringLiteral(":/data/bitmaps/turn-sharp-left.png"));
27 turnTypePixmaps.insert(Maneuver::Left, QStringLiteral(":/data/bitmaps/turn-left.png"));
28 turnTypePixmaps.insert(Maneuver::SlightLeft, QStringLiteral(":/data/bitmaps/turn-slight-left.png"));
29 turnTypePixmaps.insert(Maneuver::RoundaboutFirstExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-first.png"));
30 turnTypePixmaps.insert(Maneuver::RoundaboutSecondExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-second.png"));
31 turnTypePixmaps.insert(Maneuver::RoundaboutThirdExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-third.png"));
32 turnTypePixmaps.insert(Maneuver::RoundaboutExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-far.png"));
33 turnTypePixmaps.insert(Maneuver::ExitLeft, QStringLiteral(":/data/bitmaps/turn-exit-left.png"));
34 turnTypePixmaps.insert(Maneuver::ExitRight, QStringLiteral(":/data/bitmaps/turn-exit-right.png"));
35
36 return turnTypePixmaps;
37}
38
39Maneuver::Maneuver()
40 : m_direction(Unknown)
41 , m_waypointIndex(-1)
42{
43}
44
45Maneuver::Direction Maneuver::direction() const
46{
47 return m_direction;
48}
49
50QString Maneuver::directionPixmap() const
51{
52 static const QHash<Maneuver::Direction, QString> turnTypePixmaps = createTurnTypePixmapMap();
53
54 return turnTypePixmaps.value(direction());
55}
56
57bool Maneuver::operator==(const Maneuver &other) const
58{
59 return m_direction == other.m_direction && m_waypointIndex == other.m_waypointIndex && m_position == other.m_position && m_waypoint == other.m_waypoint
60 && m_instructionText == other.m_instructionText;
61}
62
63bool Maneuver::operator!=(const Maneuver &other) const
64{
65 return !(other == *this);
66}
67
68void Maneuver::setDirection(Direction direction)
69{
70 m_direction = direction;
71}
72
73GeoDataCoordinates Maneuver::position() const
74{
75 return m_position;
76}
77
78void Maneuver::setPosition(const GeoDataCoordinates &position)
79{
80 m_position = position;
81}
82
83GeoDataCoordinates Maneuver::waypoint() const
84{
85 return m_waypoint;
86}
87
88bool Maneuver::hasWaypoint() const
89{
90 return m_waypointIndex >= 0;
91}
92
93void Maneuver::setWaypoint(const GeoDataCoordinates &waypoint, int index)
94{
95 m_waypoint = waypoint;
96 m_waypointIndex = index;
97}
98
99int Maneuver::waypointIndex() const
100{
101 return m_waypointIndex;
102}
103
104QString Maneuver::instructionText() const
105{
106 return m_instructionText;
107}
108
109void Maneuver::setInstructionText(const QString &text)
110{
111 m_instructionText = text;
112}
113
114QString Maneuver::roadName() const
115{
116 return m_roadName;
117}
118
119void Maneuver::setRoadName(const QString &roadName)
120{
121 m_roadName = roadName;
122}
123
124}
Binds a QML item to a specific geodetic location in screen coordinates.
iterator insert(const Key &key, const T &value)
T value(const Key &key) const const
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.