Enroute Flight Navigation
A navigation app for VFR pilots
Downloadable_Abstract.h
1/***************************************************************************
2 * Copyright (C) 2022--2024 by Stefan Kebekus *
3 * stefan.kebekus@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#pragma once
22
23#include <QGeoRectangle>
24#include <QProperty>
25#include <QQmlEngine>
26#include <QTimer>
27
28#include "units/ByteSize.h"
29
30
31namespace DataManagement {
32
42
43class Downloadable_Abstract : public QObject {
44 Q_OBJECT
45 QML_ELEMENT
46 QML_UNCREATABLE("")
47
48public:
59 Q_ENUM(ContentType)
60
61
65 explicit Downloadable_Abstract(QObject* parent = nullptr);
66
67 // standard destructor
68 ~Downloadable_Abstract() override = default;
69
70
71
72 //
73 // PROPERTIES
74 //
75
77 Q_PROPERTY(QGeoRectangle boundingBox READ boundingBox WRITE setBoundingBox NOTIFY boundingBoxChanged)
78
81
88 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
89
91 Q_PROPERTY(bool downloading READ downloading NOTIFY downloadingChanged)
92
96 Q_PROPERTY(QStringList files READ files NOTIFY filesChanged)
97
99 Q_PROPERTY(bool hasFile READ hasFile BINDABLE bindableHasFile NOTIFY hasFileChanged)
100
111 Q_PROPERTY(QString infoText READ infoText NOTIFY infoTextChanged)
112
119
130 Q_PROPERTY(QString section READ section WRITE setSection BINDABLE bindableSection NOTIFY sectionChanged)
131
138 Q_PROPERTY(Units::ByteSize updateSize READ updateSize NOTIFY updateSizeChanged)
139
142
143
144 //
145 // Getter Methods
146 //
147
152 [[nodiscard]] QGeoRectangle boundingBox() const {return m_boundingBox;}
153
158 [[nodiscard]] DataManagement::Downloadable_Abstract::ContentType contentType() const {return m_contentType;}
159
164 [[nodiscard]] virtual auto description() -> QString = 0;
165
170 [[nodiscard]] virtual auto downloading() -> bool = 0;
171
176 [[nodiscard]] virtual auto files() -> QStringList = 0;
177
182 [[nodiscard]] bool hasFile() const {return m_hasFile.value();}
183
188 [[nodiscard]] QBindable<bool> bindableHasFile() const {return &m_hasFile;}
189
194 [[nodiscard]] virtual auto infoText() -> QString = 0;
195
200 [[nodiscard]] virtual auto remoteFileSize() -> qint64 = 0;
201
206 [[nodiscard]] QString section() const { return m_section; }
207
212 [[nodiscard]] QBindable<QString> bindableSection() const { return &m_section; }
213
218 [[nodiscard]] virtual auto updateSize() -> Units::ByteSize = 0;
219
224 [[nodiscard]] virtual auto updateSizeString() -> QString;
225
226
227
228 //
229 // Setter Methods
230 //
231
236 void setBoundingBox(const QGeoRectangle& boundingBox);
237
243
248 void setSection(const QString& sectionName) {m_sectionBuffer = sectionName;}
249
250
251
252 //
253 // Methods
254 //
255
257 Q_INVOKABLE virtual void deleteFiles() = 0;
258
261 {
262 emitFileContentChanged_delayedTimer.stop();
263 }
264
266 Q_INVOKABLE virtual void startDownload() = 0;
267
269 Q_INVOKABLE virtual void stopDownload() = 0;
270
272 Q_INVOKABLE virtual void update() = 0;
273
274signals:
277
280
283
286
299 void error(QString objectName, QString message);
300
303
311
314
317
320
323
326
329
330protected:
332
333
334private:
335 Q_DISABLE_COPY_MOVE(Downloadable_Abstract)
336
337 // Property contentType
338 QGeoRectangle m_boundingBox;
339
340 // Property contentType
341 ContentType m_contentType {Data};
342
343 // Property section
345 QProperty<QString> m_sectionBuffer;
346
347 // Provisions to provide the signal localFileContentChanged_delayed
348 void emitFileContentChanged_delayed();
349 QTimer emitFileContentChanged_delayedTimer;
350};
351
352} // namespace DataManagement
Abstract base class for Downloadable_SingleFile and Downloadable_MultiFile.
QString section
Headline name for the Downloadable.
virtual Q_INVOKABLE void startDownload()=0
Initiate download(s)
void error(QString objectName, QString message)
Download error.
void downloadingChanged()
Notifier signal.
QString section() const
Getter function for the property with the same name.
void remoteFileSizeChanged()
Notifier signal.
void filesChanged()
Notifier signal.
virtual auto downloading() -> bool=0
Getter method for the property with the same name.
bool hasFile
Indicates if (at least one) local file exists.
void boundingBoxChanged()
Notifier signal.
void contentTypeChanged()
Notifier signal.
void setContentType(DataManagement::Downloadable_Abstract::ContentType contentType)
Setter function for the property with the same name.
ContentType
Type of content managed by this instance.
@ BaseMapVector
Base Map, in vector format.
@ BaseMapRaster
Base Map, in raster format.
virtual auto updateSizeString() -> QString
Getter function for the property with the same name.
Downloadable_Abstract(QObject *parent=nullptr)
Standard constructor.
Q_INVOKABLE void killFileContentChanged_delayed()
Kill pending emission of signal fileContentChanged_delayed.
virtual auto files() -> QStringList=0
Getter method for the property with the same name.
QString infoText
Short info text describing the state of the downloadable(s)
virtual auto description() -> QString=0
Getter method for the property with the same name.
virtual Q_INVOKABLE void stopDownload()=0
Stops download process(es)
virtual Q_INVOKABLE void update()=0
Starts download(s) if updatable.
QString description
Describe installed file(s)
void sectionChanged()
Notifier signal.
virtual auto remoteFileSize() -> qint64=0
Getter function for the property with the same name.
QBindable< QString > bindableSection() const
Getter function for the property with the same name.
void hasFileChanged()
Notifier signal.
void descriptionChanged()
Notifier signal.
qint64 remoteFileSize
Size of the remote file.
QBindable< bool > bindableHasFile() const
Getter method for the property with the same name.
void fileContentChanged_delayed()
Emitted some time after the content of one of the local files changes.
virtual auto updateSize() -> Units::ByteSize=0
Getter function for the property with the same name.
QString updateSizeString
Update size as a localized string.
void infoTextChanged()
Notifier signal.
virtual auto infoText() -> QString=0
Getter method for the property with the same name.
QGeoRectangle boundingBox
Geographic bounding box.
bool hasFile() const
Getter method for the property with the same name.
void setSection(const QString &sectionName)
Setter function for the property with the same name.
void setBoundingBox(const QGeoRectangle &boundingBox)
Setter function for the property with the same name.
DataManagement::Downloadable_Abstract::ContentType contentType() const
Getter method for the property with the same name.
bool downloading
Indicates whether a download process is currently running.
QStringList files
Names of all files that have been downloaded by any of the Downloadble objects in this group (and the...
void updateSizeChanged()
Notifier signal.
virtual Q_INVOKABLE void deleteFiles()=0
Deletes all local file(s)
void fileContentChanged()
Indicates that the content of a local file (or several local files) has changed.
DataManagement::Downloadable_Abstract::ContentType contentType
Most probable content of file(s) managed by this object.
Convenience class for size_t.
Definition ByteSize.h:37
Conversion between units used in aviation.
Definition Angle.h:34