File indexing completed on 2024-05-12 11:43:06
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2011 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #include "Maneuver.h" 0007 #include "MarbleDirs.h" 0008 0009 #include <QHash> 0010 0011 namespace Marble 0012 { 0013 0014 static QHash<Maneuver::Direction, QString> createTurnTypePixmapMap() 0015 { 0016 QHash<Maneuver::Direction, QString> turnTypePixmaps; 0017 0018 turnTypePixmaps.insert(Maneuver::Unknown, QStringLiteral(":/data/bitmaps/routing_step.png")); 0019 turnTypePixmaps.insert(Maneuver::Straight, QStringLiteral(":/data/bitmaps/turn-continue.png")); 0020 turnTypePixmaps.insert(Maneuver::Continue, QStringLiteral(":/data/bitmaps/turn-continue.png")); 0021 turnTypePixmaps.insert(Maneuver::Merge, QStringLiteral(":/data/bitmaps/turn-merge.png")); 0022 turnTypePixmaps.insert(Maneuver::SlightRight, QStringLiteral(":/data/bitmaps/turn-slight-right.png")); 0023 turnTypePixmaps.insert(Maneuver::Right, QStringLiteral(":/data/bitmaps/turn-right.png")); 0024 turnTypePixmaps.insert(Maneuver::SharpRight, QStringLiteral(":/data/bitmaps/turn-sharp-right.png")); 0025 turnTypePixmaps.insert(Maneuver::TurnAround, QStringLiteral(":/data/bitmaps/turn-around.png")); 0026 turnTypePixmaps.insert(Maneuver::SharpLeft, QStringLiteral(":/data/bitmaps/turn-sharp-left.png")); 0027 turnTypePixmaps.insert(Maneuver::Left, QStringLiteral(":/data/bitmaps/turn-left.png")); 0028 turnTypePixmaps.insert(Maneuver::SlightLeft, QStringLiteral(":/data/bitmaps/turn-slight-left.png")); 0029 turnTypePixmaps.insert(Maneuver::RoundaboutFirstExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-first.png")); 0030 turnTypePixmaps.insert(Maneuver::RoundaboutSecondExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-second.png")); 0031 turnTypePixmaps.insert(Maneuver::RoundaboutThirdExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-third.png")); 0032 turnTypePixmaps.insert(Maneuver::RoundaboutExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-far.png")); 0033 turnTypePixmaps.insert(Maneuver::ExitLeft, QStringLiteral(":/data/bitmaps/turn-exit-left.png")); 0034 turnTypePixmaps.insert(Maneuver::ExitRight, QStringLiteral(":/data/bitmaps/turn-exit-right.png")); 0035 0036 return turnTypePixmaps; 0037 } 0038 0039 0040 Maneuver::Maneuver() : 0041 m_direction( Unknown ), 0042 m_waypointIndex( -1 ) 0043 { 0044 } 0045 0046 Maneuver::Direction Maneuver::direction() const 0047 { 0048 return m_direction; 0049 } 0050 0051 QString Maneuver::directionPixmap() const 0052 { 0053 static const QHash<Maneuver::Direction, QString> turnTypePixmaps = createTurnTypePixmapMap(); 0054 0055 return turnTypePixmaps.value(direction()); 0056 } 0057 0058 bool Maneuver::operator ==(const Maneuver &other) const 0059 { 0060 return m_direction == other.m_direction && 0061 m_waypointIndex == other.m_waypointIndex && 0062 m_position == other.m_position && 0063 m_waypoint == other.m_waypoint && 0064 m_instructionText == other.m_instructionText; 0065 } 0066 0067 bool Maneuver::operator !=(const Maneuver &other) const 0068 { 0069 return !(other == *this); 0070 } 0071 0072 void Maneuver::setDirection( Direction direction ) 0073 { 0074 m_direction = direction; 0075 } 0076 0077 GeoDataCoordinates Maneuver::position() const 0078 { 0079 return m_position; 0080 } 0081 0082 void Maneuver::setPosition( const GeoDataCoordinates &position ) 0083 { 0084 m_position = position; 0085 } 0086 0087 GeoDataCoordinates Maneuver::waypoint() const 0088 { 0089 return m_waypoint; 0090 } 0091 0092 bool Maneuver::hasWaypoint() const 0093 { 0094 return m_waypointIndex >= 0; 0095 } 0096 0097 void Maneuver::setWaypoint( const GeoDataCoordinates &waypoint, int index ) 0098 { 0099 m_waypoint = waypoint; 0100 m_waypointIndex = index; 0101 } 0102 0103 int Maneuver::waypointIndex() const 0104 { 0105 return m_waypointIndex; 0106 } 0107 0108 QString Maneuver::instructionText() const 0109 { 0110 return m_instructionText; 0111 } 0112 0113 void Maneuver::setInstructionText( const QString &text ) 0114 { 0115 m_instructionText = text; 0116 } 0117 0118 QString Maneuver::roadName() const 0119 { 0120 return m_roadName; 0121 } 0122 0123 void Maneuver::setRoadName(const QString &roadName) 0124 { 0125 m_roadName = roadName; 0126 } 0127 0128 }