File indexing completed on 2024-05-05 03:49:20
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2011 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #ifndef MARBLE_DECLARATIVE_ROUTING_H 0007 #define MARBLE_DECLARATIVE_ROUTING_H 0008 0009 #include <QQuickItem> 0010 0011 #include <Placemark.h> 0012 #include <routing/RoutingModel.h> 0013 #include <RouteRequestModel.h> 0014 0015 namespace Marble { 0016 0017 class MarbleMap; 0018 class RoutingPrivate; 0019 0020 class Routing : public QQuickItem 0021 { 0022 Q_OBJECT 0023 Q_PROPERTY( MarbleMap* marbleMap READ marbleMap WRITE setMarbleMap NOTIFY marbleMapChanged) 0024 Q_PROPERTY( QString routingProfile READ routingProfile WRITE setRoutingProfile NOTIFY routingProfileChanged ) 0025 Q_PROPERTY( bool hasRoute READ hasRoute NOTIFY hasRouteChanged ) 0026 Q_PROPERTY( bool hasWaypoints READ hasWaypoints NOTIFY hasWaypointsChanged ) 0027 Q_PROPERTY( RoutingModel* routingModel READ routingModel NOTIFY routingModelChanged) 0028 Q_PROPERTY( QQmlComponent* waypointDelegate READ waypointDelegate WRITE setWaypointDelegate NOTIFY waypointDelegateChanged) 0029 Q_PROPERTY( RouteRequestModel* routeRequestModel READ routeRequestModel NOTIFY routeRequestModelChanged) 0030 0031 public: 0032 enum RoutingProfile { Motorcar, Bicycle, Pedestrian }; 0033 0034 explicit Routing( QQuickItem* parent = nullptr ); 0035 0036 ~Routing() override; 0037 0038 void setMarbleMap( MarbleMap* marbleMap ); 0039 0040 MarbleMap *marbleMap(); 0041 0042 QString routingProfile() const; 0043 0044 void setRoutingProfile( const QString & profile ); 0045 0046 bool hasRoute() const; 0047 0048 bool hasWaypoints() const; 0049 0050 RoutingModel *routingModel(); 0051 0052 QQmlComponent * waypointDelegate() const; 0053 0054 Q_INVOKABLE int waypointCount() const; 0055 0056 RouteRequestModel* routeRequestModel(); 0057 0058 public Q_SLOTS: 0059 void addVia( qreal lon, qreal lat ); 0060 0061 void addViaAtIndex( int index, qreal lon, qreal lat ); 0062 0063 void addViaByPlacemark( Placemark * placemark ); 0064 0065 void addViaByPlacemarkAtIndex( int index, Placemark * placemark ); 0066 0067 void setVia( int index, qreal lon, qreal lat ); 0068 0069 void removeVia( int index ); 0070 0071 void swapVias( int index1, int index2 ); 0072 0073 void reverseRoute(); 0074 0075 void clearRoute(); 0076 0077 void updateRoute(); 0078 0079 void openRoute( const QString &filename ); 0080 0081 void saveRoute( const QString &filename ); 0082 0083 QObject* waypointModel(); 0084 0085 void setWaypointDelegate(QQmlComponent * waypointDelegate); 0086 0087 int addSearchResultPlacemark( Placemark * placemark ); 0088 0089 void clearSearchResultPlacemarks(); 0090 0091 Q_SIGNALS: 0092 void marbleMapChanged(); 0093 0094 void routingProfileChanged(); 0095 0096 void hasRouteChanged(); 0097 0098 void hasWaypointsChanged(); 0099 0100 void routingModelChanged(); 0101 0102 void waypointDelegateChanged(QQmlComponent * waypointDelegate); 0103 0104 void routeRequestModelChanged(RouteRequestModel* routeRequestModel); 0105 0106 protected: 0107 // Implements QQuickItem interface 0108 QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override; 0109 0110 private Q_SLOTS: 0111 void updateWaypointItems(); 0112 0113 void updateSearchResultPlacemarks(); 0114 0115 private: 0116 RoutingPrivate* const d; 0117 }; 0118 0119 } 0120 0121 #endif