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:
60 Q_ENUM(ContentType)
61
62
66 explicit Downloadable_Abstract(QObject* parent = nullptr);
67
68 // standard destructor
69 ~Downloadable_Abstract() override;
70
71
72
73 //
74 // PROPERTIES
75 //
76
78 Q_PROPERTY(QGeoRectangle boundingBox READ boundingBox WRITE setBoundingBox BINDABLE bindableBoundingBox NOTIFY boundingBoxChanged)
79 [[nodiscard]] QGeoRectangle boundingBox() const {return m_boundingBox.value();}
80 [[nodiscard]] QBindable<QGeoRectangle> bindableBoundingBox() {return &m_boundingBox;}
81 void setBoundingBox(const QGeoRectangle& boundingBox) {m_boundingBox = boundingBox;}
82
85
86
92 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
93
95 Q_PROPERTY(bool downloading READ downloading NOTIFY downloadingChanged)
96
100 Q_PROPERTY(QStringList files READ files NOTIFY filesChanged)
101
103 Q_PROPERTY(bool hasFile READ hasFile BINDABLE bindableHasFile NOTIFY hasFileChanged)
104
115 Q_PROPERTY(QString infoText READ infoText NOTIFY infoTextChanged)
116
123
134 Q_PROPERTY(QString section READ section WRITE setSection BINDABLE bindableSection NOTIFY sectionChanged)
135
142 Q_PROPERTY(Units::ByteSize updateSize READ updateSize NOTIFY updateSizeChanged)
143
146
147
148 //
149 // Getter Methods
150 //
151
156 [[nodiscard]] DataManagement::Downloadable_Abstract::ContentType contentType() const {return m_contentType;}
157
162 [[nodiscard]] virtual auto description() -> QString = 0;
163
168 [[nodiscard]] virtual auto downloading() -> bool = 0;
169
174 [[nodiscard]] virtual auto files() -> QStringList = 0;
175
180 [[nodiscard]] bool hasFile() const {return m_hasFile.value();}
181
186 [[nodiscard]] QBindable<bool> bindableHasFile() const {return &m_hasFile;}
187
192 [[nodiscard]] virtual auto infoText() -> QString = 0;
193
198 [[nodiscard]] virtual auto remoteFileSize() -> qint64 = 0;
199
204 [[nodiscard]] QString section() const { return m_section.value(); }
205
210 [[nodiscard]] QBindable<QString> bindableSection() const { return &m_section; }
211
221 [[nodiscard]] QString sectionUnmasked() const { return m_sectionBuffer.value(); }
222
227 [[nodiscard]] virtual auto updateSize() -> Units::ByteSize = 0;
228
233 [[nodiscard]] virtual auto updateSizeString() -> QString;
234
235
236
237 //
238 // Setter Methods
239 //
240
246
251 void setSection(const QString& sectionName) {m_sectionBuffer = sectionName;}
252
253
254
255 //
256 // Methods
257 //
258
260 Q_INVOKABLE virtual void deleteFiles() = 0;
261
264 {
265 emitFileContentChanged_delayedTimer.stop();
266 }
267
269 Q_INVOKABLE virtual void startDownload() = 0;
270
272 Q_INVOKABLE virtual void stopDownload() = 0;
273
275 Q_INVOKABLE virtual void update() = 0;
276
277signals:
280
283
286
289
302 void error(QString objectName, QString message);
303
306
314
317
320
323
326
329
332
333protected:
335
336
337private:
338 Q_DISABLE_COPY_MOVE(Downloadable_Abstract)
339
340 Q_OBJECT_BINDABLE_PROPERTY(DataManagement::Downloadable_Abstract, QGeoRectangle, m_boundingBox, &DataManagement::Downloadable_Abstract::boundingBoxChanged);
341
342 // Property contentType
343 ContentType m_contentType {Data};
344
345 // Property section
347 QProperty<QString> m_sectionBuffer;
348
349 // Provisions to provide the signal localFileContentChanged_delayed
350 void emitFileContentChanged_delayed();
351 QTimer emitFileContentChanged_delayedTimer;
352};
353
354} // 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.
@ VACCollection
Collection of Visual Approach Charts.
@ 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.
QString sectionUnmasked() const
Section, without masking for installed items.
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