File indexing completed on 2024-04-21 14:56:36

0001 /*
0002     SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 #ifndef KGEOURIHANDLER_H
0007 #define KGEOURIHANDLER_H
0008 
0009 #include <QString>
0010 
0011 class QUrl;
0012 
0013 /** Fallback handler for geo: URIs by forwarding them to a web service.
0014  *
0015  *  This handles three cases of geo: URIs:
0016  *  - when containing a query argument, the query URL template is used
0017  *  - when containing valid WGS-84 coordinates, the coordinate URL template is used
0018  *  - otherwise the fallback URL is returned
0019  *
0020  *  URL templates can contain any number of the following placeholders in angle brackets:
0021  *  - @c LAT - the latitude
0022  *  - @c LON - the longitude
0023  *  - @c Q - the query string
0024  *  - @c Z - the zoom level for a Web Mercator map projection
0025  *
0026  *  @see https://en.wikipedia.org/wiki/Geo_URI_scheme
0027  *  @see https://datatracker.ietf.org/doc/html/rfc5870
0028  */
0029 class KGeoUriHandler
0030 {
0031 public:
0032     void setCoordinateTemplate(const QString &coordTmpl);
0033     void setQueryTemplate(const QString &queryTmpl);
0034     void setFallbackUrl(const QString &fallbackUrl);
0035 
0036     QString handleUri(const QUrl &geoUri);
0037 
0038 private:
0039     QString m_coordTmpl;
0040     QString m_queryTmpl;
0041     QString m_fallbackUrl;
0042 };
0043 
0044 #endif // KGEOURIHANDLER_H