File indexing completed on 2024-04-21 03:49:23

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org>
0004 //
0005 
0006 #ifndef MARBLE_ROUTEREQUEST_H
0007 #define MARBLE_ROUTEREQUEST_H
0008 
0009 #include "marble_export.h"
0010 #include "RoutingProfile.h"
0011 
0012 #include <QObject>
0013 
0014 namespace Marble
0015 {
0016 
0017 class GeoDataCoordinates;
0018 class GeoDataPlacemark;
0019 class RouteRequestPrivate;
0020 
0021 /**
0022   * @brief Points to be included in a route. An ordered list of
0023   * GeoDataCoordinates with change notification and Pixmap access, similar
0024   * to QAbstractItemModel.
0025   */
0026 class MARBLE_EXPORT RouteRequest: public QObject
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031 
0032     /** Constructor */
0033     explicit RouteRequest( QObject *parent = nullptr );
0034 
0035     /** Destructor */
0036     ~RouteRequest() override;
0037 
0038     /** The first point, or a default constructed if empty */
0039     GeoDataCoordinates source() const;
0040 
0041     /** The last point, or a default constructed if empty */
0042     GeoDataCoordinates destination() const;
0043 
0044     /** Number of points in the route */
0045     int size() const;
0046 
0047     /** Accessor for the n-th position */
0048     GeoDataCoordinates at( int index ) const;
0049 
0050     /** Add the given element to the end */
0051     void append( const GeoDataCoordinates &coordinates, const QString &name = QString() );
0052 
0053     void append( const GeoDataPlacemark &placemark );
0054 
0055     /** Add the given element at the given position */
0056     void insert( int index, const GeoDataCoordinates &coordinates, const QString &name = QString() );
0057 
0058     void insert(int index, const GeoDataPlacemark &placemark);
0059 
0060     /** Swaps the given elements at the given positions*/
0061     void swap( int index1, int index2 );
0062 
0063     /** Change the value of the element at the given position */
0064     void setPosition( int index, const GeoDataCoordinates &position, const QString &name = QString() );
0065 
0066     /** Remove the element at the given position */
0067     void remove( int index );
0068 
0069     /** Remove all elements */
0070     void clear();
0071 
0072     /**
0073       * Insert a via point. Order will be chosen such that the via point is not before
0074       * the start or after the destination. Furthermore the distance between neighboring
0075       * route points is minimized
0076       *
0077       * @note: This does not trigger an update of the route. It becomes "dirty"
0078       *
0079       * @todo: Minimizing the distance might not always be what the user wants
0080       */
0081     void addVia( const GeoDataCoordinates &position );
0082     void addVia( const GeoDataPlacemark &placemark );
0083 
0084     /** Returns a pixmap which indicates the position of the element */
0085     QPixmap pixmap( int index, int size=-1, int margin=2 ) const;
0086 
0087     void setName( int index, const QString &name );
0088 
0089     QString name( int index ) const;
0090 
0091     void setVisited( int index, bool visited );
0092 
0093     bool visited( int index ) const;
0094 
0095     void reverse();
0096 
0097     void setRoutingProfile( const RoutingProfile &profile );
0098 
0099     RoutingProfile routingProfile() const;
0100 
0101     GeoDataPlacemark & operator[] ( int index );
0102 
0103     GeoDataPlacemark const & operator[] ( int index ) const;
0104 
0105 Q_SIGNALS:
0106     /** The value of the n-th element was changed */
0107     void positionChanged( int index, const GeoDataCoordinates &position );
0108 
0109     /** An element was added at the given position */
0110     void positionAdded( int index );
0111 
0112     /** The element at the given position was removed */
0113     void positionRemoved( int index );
0114 
0115     /** The routing profile was changed */
0116     void routingProfileChanged();
0117 
0118 private:
0119     RouteRequestPrivate *const d;
0120 };
0121 
0122 } // namespace Marble
0123 
0124 #endif