Enroute Flight Navigation
A navigation app for VFR pilots
Downloadable_Abstract.h
1/***************************************************************************
2 * Copyright (C) 2022--2026 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 BINDABLE bindableBoundingBox NOTIFY boundingBoxChanged)
78 [[nodiscard]] QGeoRectangle boundingBox() const {return m_boundingBox.value();}
79 [[nodiscard]] QBindable<QGeoRectangle> bindableBoundingBox() {return &m_boundingBox;}
80 void setBoundingBox(const QGeoRectangle& boundingBox) {m_boundingBox = boundingBox;}
81
84
85
91 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
92
94 Q_PROPERTY(bool downloading READ downloading NOTIFY downloadingChanged)
95
99 Q_PROPERTY(QStringList files READ files NOTIFY filesChanged)
100
102 Q_PROPERTY(bool hasFile READ hasFile BINDABLE bindableHasFile NOTIFY hasFileChanged)
103
114 Q_PROPERTY(QString infoText READ infoText NOTIFY infoTextChanged)
115
122
133 Q_PROPERTY(QString section READ section WRITE setSection BINDABLE bindableSection NOTIFY sectionChanged)
134
141 Q_PROPERTY(Units::ByteSize updateSize READ updateSize NOTIFY updateSizeChanged)
142
145
146
147 //
148 // Getter Methods
149 //
150
155 [[nodiscard]] DataManagement::Downloadable_Abstract::ContentType contentType() const {return m_contentType;}
156
161 [[nodiscard]] virtual auto description() -> QString = 0;
162
167 [[nodiscard]] virtual auto downloading() -> bool = 0;
168
173 [[nodiscard]] virtual auto files() -> QStringList = 0;
174
179 [[nodiscard]] bool hasFile() const {return m_hasFile.value();}
180
185 [[nodiscard]] QBindable<bool> bindableHasFile() const {return &m_hasFile;}
186
191 [[nodiscard]] virtual auto infoText() -> QString = 0;
192
197 [[nodiscard]] virtual auto remoteFileSize() -> qint64 = 0;
198
203 [[nodiscard]] QString section() const { return m_section.value(); }
204
209 [[nodiscard]] QBindable<QString> bindableSection() const { return &m_section; }
210
215 [[nodiscard]] virtual auto updateSize() -> Units::ByteSize = 0;
216
221 [[nodiscard]] virtual auto updateSizeString() -> QString;
222
223
224
225 //
226 // Setter Methods
227 //
228
234
239 void setSection(const QString& sectionName) {m_sectionBuffer = sectionName;}
240
241
242
243 //
244 // Methods
245 //
246
248 Q_INVOKABLE virtual void deleteFiles() = 0;
249
252 {
253 emitFileContentChanged_delayedTimer.stop();
254 }
255
257 Q_INVOKABLE virtual void startDownload() = 0;
258
260 Q_INVOKABLE virtual void stopDownload() = 0;
261
263 Q_INVOKABLE virtual void update() = 0;
264
265signals:
268
271
274
277
290 void error(QString objectName, QString message);
291
294
302
305
308
311
314
317
320
321protected:
323
324
325private:
326 Q_DISABLE_COPY_MOVE(Downloadable_Abstract)
327
328 Q_OBJECT_BINDABLE_PROPERTY(DataManagement::Downloadable_Abstract, QGeoRectangle, m_boundingBox, &DataManagement::Downloadable_Abstract::boundingBoxChanged);
329
330 // Property contentType
331 ContentType m_contentType {Data};
332
333 // Property section
335 QProperty<QString> m_sectionBuffer;
336
337 // Provisions to provide the signal localFileContentChanged_delayed
338 void emitFileContentChanged_delayed();
339 QTimer emitFileContentChanged_delayedTimer;
340};
341
342} // 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.
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