Enroute Flight Navigation
A navigation app for VFR pilots
VACLibrary.h
1/***************************************************************************
2 * Copyright (C) 2024-2025 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 <QFile>
24#include <QStandardPaths>
25
26#include "geomaps/VAC.h"
27
28
29namespace GeoMaps
30{
31
38
39class VACLibrary : public QObject
40{
41 Q_OBJECT
42 QML_ELEMENT
43 QML_SINGLETON
44
45public:
50 VACLibrary(QObject *parent = nullptr);
51
53 ~VACLibrary() override;
54
55 //
56 // Properties
57 //
58
60 Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY dataChanged)
61
62
67 Q_PROPERTY(QList<GeoMaps::VAC> vacs READ vacs NOTIFY dataChanged)
68
69
70 //
71 // Getter Methods
72 //
73
78 [[nodiscard]] bool isEmpty() const { return m_vacs.isEmpty(); }
79
84 [[nodiscard]] QList<GeoMaps::VAC> vacs();
85
86
87 //
88 // Methods
89 //
90
95 Q_INVOKABLE void clear();
96
104 [[nodiscard]] Q_INVOKABLE GeoMaps::VAC get(const QString& name);
105
112 [[nodiscard]] Q_INVOKABLE QString importTripKit(const QString& fileName);
113
123 [[nodiscard]] Q_INVOKABLE QString importVAC(GeoMaps::VAC vac);
124
131 Q_INVOKABLE void remove(const QString& name);
132
141 [[nodiscard]] Q_INVOKABLE QString rename(const QString& oldName, const QString& newName);
142
154 [[nodiscard]] Q_INVOKABLE QVector<GeoMaps::VAC> vacsByDistance(const QGeoCoordinate& position, const QString& filter);
155
165 [[nodiscard]] Q_INVOKABLE QVector<GeoMaps::VAC> vacs4Point(const QGeoCoordinate& position);
166
167signals:
170
178 void importTripKitStatus(double percent);
179
180private:
181 Q_DISABLE_COPY_MOVE(VACLibrary)
182
183 // This method cleans the VAC directory. It deletes all VAC from m_vacs that
184 // have no raster image files. It looks for unmanaged raster image files and
185 // either imports them or deletes them.
186 void janitor();
187
188 // This method saves m_vacs to m_dataFile.
189 void save();
190
191 // This method returns the absolute path of a given VAC. Needed for iOS
192 // after App Update. See GeoMaps::VACLibrary::janitor
193 QString absolutePathForVac(const GeoMaps::VAC&);
194 QString absolutePathForVac(const QString& name);
195
196 QVector<GeoMaps::VAC> m_vacs;
197 QString m_vacDirectory {QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + u"/VAC"_s};
198 QFile m_dataFile {QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + u"/VAC.data"_s};
199
200};
201
202} // namespace GeoMaps
203
Q_INVOKABLE QVector< GeoMaps::VAC > vacsByDistance(const QGeoCoordinate &position, const QString &filter)
List of all VACs installed.
Q_INVOKABLE void clear()
Removes all VACs.
Q_INVOKABLE GeoMaps::VAC get(const QString &name)
Obtain VACs from the library.
Q_INVOKABLE void remove(const QString &name)
Remove one VACs.
void dataChanged()
Notifier signal.
Q_INVOKABLE QString importVAC(GeoMaps::VAC vac)
Import VAC.
~VACLibrary() override
Destructor.
VACLibrary(QObject *parent=nullptr)
Constructor.
QList< GeoMaps::VAC > vacs
List of all VACs installed.
Definition VACLibrary.h:67
bool isEmpty
True if library is empty.
Definition VACLibrary.h:60
Q_INVOKABLE QVector< GeoMaps::VAC > vacs4Point(const QGeoCoordinate &position)
List of all VACs that contain a given point.
QList< GeoMaps::VAC > vacs()
Getter function for property of the same name.
Q_INVOKABLE QString rename(const QString &oldName, const QString &newName)
Rename a VACs.
Q_INVOKABLE QString importTripKit(const QString &fileName)
Import trip kit.
void importTripKitStatus(double percent)
Progress report when importing a trip kit.
Visual approach chart.
Definition VAC.h:45