File indexing completed on 2024-07-14 07:23:11

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org>
0004 // SPDX-FileCopyrightText: 2016 Piotr Wójcik <chocimier@tlen.pl>
0005 //
0006 
0007 
0008 #ifndef MARBLE_YOURSRUNNER_H
0009 #define MARBLE_YOURSRUNNER_H
0010 
0011 #include "RoutingRunner.h"
0012 
0013 #include <QNetworkAccessManager>
0014 #include <QNetworkReply>
0015 
0016 namespace Marble
0017 {
0018 
0019 class YoursRunner : public RoutingRunner
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     explicit YoursRunner( QObject *parent = nullptr );
0025 
0026     ~YoursRunner() override;
0027 
0028     // Overriding MarbleAbstractRunner
0029     void retrieveRoute( const RouteRequest *request ) override;
0030 
0031 private Q_SLOTS:
0032     /** Route data was retrieved via http */
0033     void retrieveData( QNetworkReply *reply );
0034 
0035     /** A network error occurred */
0036     void handleError( QNetworkReply::NetworkError );
0037 
0038     void get();
0039 
0040 private:
0041     static GeoDataDocument* parse( const QByteArray &input );
0042 
0043     static qreal distance( const GeoDataDocument* document );
0044 
0045     QNetworkAccessManager m_networkAccessManager;
0046 
0047     QNetworkRequest m_request;
0048 };
0049 
0050 }
0051 
0052 #endif