libosmscout  1.1.1
OsmTileDownloader.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_CLIENT_QT_OSMTILEDOWNLOADER_H
2 #define OSMSCOUT_CLIENT_QT_OSMTILEDOWNLOADER_H
3 
4 /*
5  OSMScout - a Qt backend for libosmscout and libosmscout-map
6  Copyright (C) 2016 Lukas Karas
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */
22 
23 #include <QObject>
24 #include <QByteArray>
25 #include <QNetworkAccessManager>
26 #include <QNetworkRequest>
27 #include <QNetworkReply>
28 #include <QImage>
29 #include <QNetworkDiskCache>
30 
31 #include <osmscout/TileCache.h>
33 #include <osmscout/Settings.h>
34 
35 namespace osmscout {
36 
40 class OsmTileDownloader : public QObject
41 {
42  Q_OBJECT
43 
44 public:
45  OsmTileDownloader(QString diskCacheDir,
46  const OnlineTileProvider &provider);
47  ~OsmTileDownloader() override;
48 
49 public slots:
50  void download(uint32_t zoomLevel, uint32_t x, uint32_t y);
51  void onlineTileProviderChanged(const OnlineTileProvider &provider);
52 
53 signals:
54  void downloaded(uint32_t zoomLevel, uint32_t x, uint32_t y, QImage image, QByteArray downloadedData);
55  void failed(uint32_t zoomLevel, uint32_t x, uint32_t y, bool zoomLevelOutOfRange);
56 
57 private slots:
58  void fileDownloaded(const TileCacheKey &key, QNetworkReply *reply);
59 
60 private:
61  quint32 serverNumber;
62  QNetworkAccessManager webCtrl;
63  QNetworkDiskCache diskCache;
64  OnlineTileProvider tileProvider;
65 
66 };
67 
68 }
69 
70 #endif /* OSMSCOUT_CLIENT_QT_OSMTILEDOWNLOADER_H */
OsmTileDownloader(QString diskCacheDir, const OnlineTileProvider &provider)
void onlineTileProviderChanged(const OnlineTileProvider &provider)
Definition: OsmTileDownloader.h:40
Definition: OnlineTileProvider.h:39
Definition: TileCache.h:52
Definition: Area.h:38
void download(uint32_t zoomLevel, uint32_t x, uint32_t y)
void failed(uint32_t zoomLevel, uint32_t x, uint32_t y, bool zoomLevelOutOfRange)
void downloaded(uint32_t zoomLevel, uint32_t x, uint32_t y, QImage image, QByteArray downloadedData)