KOSMIndoorMap

mapcssloader.h
1/*
2 SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KOSMINDOORMAP_MAPCSSLOADER_H
7#define KOSMINDOORMAP_MAPCSSLOADER_H
8
9#include "kosmindoormap_export.h"
10
11#include <KOSMIndoorMap/NetworkAccessManagerFactory>
12
13#include <QObject>
14#include <QUrl>
15
16#include <memory>
17
18namespace KOSMIndoorMap {
19
20class MapCSSLoaderPrivate;
21class MapCSSStyle;
22
23/** Asynchronous loader for (remote) MapCSS assets. */
24class KOSMINDOORMAP_EXPORT MapCSSLoader : public QObject {
25 Q_OBJECT
26public:
27 /** Create MapCSS loading/parsing job for @p style.
28 * This will download online assets if necessary.
29 * @param style Resolved style URL, can be local file, qrc or HTTP.
30 * @see start(), finished()
31 */
32 explicit MapCSSLoader(const QUrl &style, const NetworkAccessManagerFactory &nam, QObject *parent = nullptr);
34
35 /** Start loading. */
36 void start();
37
38 /** The fully loaded and parsed style.
39 * Only valid when hasError() returns @c false and finished() has been emitted.
40 */
41 [[nodiscard]] MapCSSStyle&& takeStyle();
42
43 /** Check whether loading or parsing failed in some way. */
44 [[nodiscard]] bool hasError() const;
45 [[nodiscard]] QString errorMessage() const;
46
47 /** Resolve @p style to an absolute URL to load.
48 * @param baseUrl the location to use for resolving relative imports.
49 */
50 [[nodiscard]] static QUrl resolve(const QString &style, const QUrl &baseUrl = {});
51
52 /** Translate local or remote URL to locally loadable (cache) file. */
53 [[nodiscard]] static QString toLocalFile(const QUrl &url);
54
55 /** Expire locally cached remote MapCSS assets. */
56 static void expire();
57
58Q_SIGNALS:
59 /** Loading is done, successfully or with an error. */
60 void finished();
61
62private:
63 Q_DECL_HIDDEN void download(const QUrl &url);
64 std::unique_ptr<MapCSSLoaderPrivate> d;
65};
66
67}
68
69#endif
Asynchronous loader for (remote) MapCSS assets.
void finished()
Loading is done, successfully or with an error.
A parsed MapCSS style sheet.
Definition mapcssstyle.h:33
Q_SCRIPTABLE Q_NOREPLY void start()
OSM-based multi-floor indoor maps for buildings.
std::function< QNetworkAccessManager *()> NetworkAccessManagerFactory
Network access manager factory.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:06:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.