libosmscout 1.1.1
Loading...
Searching...
No Matches
VoiceManager.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_VOICEMANAGER_H
2#define OSMSCOUT_CLIENT_QT_VOICEMANAGER_H
3
4/*
5 OSMScout - a Qt backend for libosmscout and libosmscout-map
6 Copyright (C) 2020 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
28
29#include <memory>
30
31namespace osmscout {
32
39{
40 Q_OBJECT
41
42public:
43 VoiceDownloadJob(QNetworkAccessManager *webCtrl,
44 const AvailableVoice &voice,
45 const QDir &target,
46 bool replaceExisting);
47
49
50 void start();
51
52 uint64_t expectedSize() const override
53 {
54 return 0;
55 }
56
58 {
59 return voice;
60 }
61
62private:
63 AvailableVoice voice;
64};
65
66
72class OSMSCOUT_CLIENT_QT_API VoiceManager: public QObject {
73 Q_OBJECT
74
75signals:
76 void reloaded();
77
79 void downloaded(const AvailableVoice &item);
80 void removed(const AvailableVoice &item);
81
82 void voiceDownloadFails(const QString &errorMessage);
83
84public slots:
85 void reload();
86
87 void download(const AvailableVoice &item);
88 void remove(const AvailableVoice &item);
89 void cancelDownload(const AvailableVoice &item);
90
92 void onJobFailed(QString errorMessage);
93
94public:
96
97 VoiceManager(const VoiceManager&) = delete;
99
102
103 ~VoiceManager() override;
104
105 QList<Voice> getInstalledVoices() const
106 {
107 return installedVoices;
108 }
109
110 bool isDownloaded(const AvailableVoice &voice) const;
111 bool isDownloading(const AvailableVoice &voice) const;
112
114
115private:
116 QList<Voice> installedVoices;
117 QList<VoiceDownloadJob*> downloadJobs;
118 QNetworkAccessManager webCtrl;
119 QString lookupDir;
120};
121
125using VoiceManagerRef = std::shared_ptr<VoiceManager>;
126
127}
128#endif //OSMSCOUT_CLIENT_QT_VOICEMANAGER_H
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
Definition Voice.h:31
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
AvailableVoice getVoice() const
Definition VoiceManager.h:57
uint64_t expectedSize() const override
Definition VoiceManager.h:52
VoiceDownloadJob(QNetworkAccessManager *webCtrl, const AvailableVoice &voice, const QDir &target, bool replaceExisting)
QList< Voice > getInstalledVoices() const
Definition VoiceManager.h:105
void removed(const AvailableVoice &item)
void startDownloading(const AvailableVoice &item)
VoiceManager & operator=(VoiceManager &&)=delete
void downloaded(const AvailableVoice &item)
bool isDownloading(const AvailableVoice &voice) const
VoiceManager(VoiceManager &&)=delete
bool isDownloaded(const AvailableVoice &voice) const
void cancelDownload(const AvailableVoice &item)
void remove(const AvailableVoice &item)
VoiceManager(const VoiceManager &)=delete
void onJobFailed(QString errorMessage)
void voiceDownloadFails(const QString &errorMessage)
VoiceManager & operator=(const VoiceManager &)=delete
void download(const AvailableVoice &item)
std::shared_ptr< VoiceManager > VoiceManagerRef
Definition VoiceManager.h:125
Definition Area.h:39