libosmscout 1.1.1
Loading...
Searching...
No Matches
MapDownloader.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_MAPMANAGER_H
2#define OSMSCOUT_CLIENT_QT_MAPMANAGER_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
24
25#include <osmscoutclient/MapProvider.h>
26#include <osmscoutclient/Settings.h>
27#include <osmscoutclient/MapDirectory.h>
28#include <osmscoutclient/MapManager.h>
29
32
33#include <QObject>
34#include <QStringList>
35#include <QList>
36#include <QDir>
37#include <QTimer>
38#include <QtGlobal>
39#include <QStorageInfo>
40
41namespace osmscout {
42
49{
50 Q_OBJECT
51
53
54public:
55
56 MapDownloadJob(QNetworkAccessManager *webCtrl, AvailableMapsModelMap map, QDir target, bool replaceExisting);
57
63 ~MapDownloadJob() override;
64
65 void start();
66
67 QString getMapName() const
68 {
69 return map.getName();
70 }
71
72 QStringList getMapPath() const
73 {
74 return map.getPath();
75 }
76
77 uint64_t expectedSize() const override
78 {
79 return map.getSize();
80 }
81};
82
89{
90 Q_OBJECT
91
92private:
93 QList<MapDownloadJob*> downloadJobs;
94 QNetworkAccessManager webCtrl;
95 MapManagerRef mapManager;
96
97public slots:
99 void onJobFailed(QString errorMessage);
100
101signals:
102 void mapDownloadFails(QString message);
104
105public:
106 MapDownloader(MapManagerRef mapManager, SettingsRef settings);
107
108 ~MapDownloader() override;
109
117 void downloadMap(AvailableMapsModelMap map, QDir dir, bool replaceExisting = true);
119
120 QList<MapDownloadJob*> getDownloadJobs() const {
121 return downloadJobs;
122 }
123};
124
128using MapDownloaderRef = std::shared_ptr<MapDownloader>;
129
130}
131
132#endif /* OSMSCOUT_CLIENT_QT_MAPMANAGER_H */
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
Definition AvailableMapsModel.h:122
DownloadJob(QNetworkAccessManager *webCtrl, QDir target, bool replaceExisting)
QNetworkAccessManager * webCtrl
Definition FileDownloader.h:138
QDir target
Definition FileDownloader.h:140
bool replaceExisting
Definition FileDownloader.h:151
QString getMapName() const
Definition MapDownloader.h:67
uint64_t expectedSize() const override
Definition MapDownloader.h:77
QStringList getMapPath() const
Definition MapDownloader.h:72
MapDownloadJob(QNetworkAccessManager *webCtrl, AvailableMapsModelMap map, QDir target, bool replaceExisting)
QList< MapDownloadJob * > getDownloadJobs() const
Definition MapDownloader.h:120
void mapDownloadFails(QString message)
MapDownloader(MapManagerRef mapManager, SettingsRef settings)
void onJobFailed(QString errorMessage)
void downloadMap(AvailableMapsModelMap map, QDir dir, bool replaceExisting=true)
std::shared_ptr< MapDownloader > MapDownloaderRef
Definition MapDownloader.h:128
Definition Area.h:39