Enroute Flight Navigation
A navigation app for VFR pilots
GeoMaps::VACLibrary Class Reference

Library of visual approach charts. More...

#include <VACLibrary.h>

Public Types

enum  Role : int { VacRole = Qt::UserRole + 1 , NameRole , SectionRole , CenterRole }
 Model roles. More...

Signals

void hasManuallyImportedChanged ()
 Notifier signal.
void isEmptyChanged ()
 Notifier signal.
void vacsChanged ()
 Notifier signal.
void importTripKitStatus (double percent)
 Progress report when importing a trip kit.

Public Member Functions

 VACLibrary (QObject *parent=nullptr)
 Constructor.
 ~VACLibrary () override
 Destructor.
bool hasManuallyImported () const
 Getter function for property of the same name.
QBindable< bool > bindableHasManuallyImported () const
 Getter function for property of the same name.
bool isEmpty () const
 Getter function for property of the same name.
QBindable< bool > bindableIsEmpty () const
 Getter function for property of the same name.
QList< GeoMaps::VACvacs () const
 Getter function for property of the same name.
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Re-implemented from QAbstractListModel.
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Re-implemented from QAbstractListModel.
QHash< int, QByteArray > roleNames () const override
 Re-implemented from QAbstractListModel.
Q_INVOKABLE void clear ()
 Removes all VACs.
Q_INVOKABLE GeoMaps::VAC get (const QString &name)
 Obtain VACs from the library.
Q_INVOKABLE QString importTripKit (const QString &fileName)
 Import trip kit.
Q_INVOKABLE GeoMaps::VAC materialize (const GeoMaps::VAC &vac)
 Obtain a VAC whose fileName points to a raster image file.
Q_INVOKABLE QString importVAC (GeoMaps::VAC vac)
 Import VAC.
Q_INVOKABLE void remove (const QString &name)
 Remove one VACs.
Q_INVOKABLE QString rename (const QString &oldName, const QString &newName)
 Rename a VACs.
Q_INVOKABLE QVector< GeoMaps::VACvacs4Point (const QGeoCoordinate &position)
 List of all VACs that contain a given point.

Properties

bool hasManuallyImported
 True if the library contains manually imported charts.
bool isEmpty
 True if library is empty.
QList< GeoMaps::VACvacs
 List of all VACs installed.

Detailed Description

Library of visual approach charts.

This class collects visual approach charts that the user has installed. The list is automatically loaded on startup, and saved every time that a change is made.

In addition to manually imported charts, this class presents the charts contained in the VAC collections managed by DataManagement::DataManager. These charts are not stored in the library data file, cannot be renamed or removed individually, and their raster data is extracted on demand; see materialize().

The library is a list model with one row per chart, sorted by section and name, and with the roles 'vac', 'name', 'section' and 'center'. Changes are announced with row-granular model signals, and with the coarse signal vacsChanged() for consumers of the property 'vacs'. In QML, bind a view to this singleton through a NameFilterProxyModel or a DistanceSortProxyModel.

Definition at line 54 of file VACLibrary.h.

Member Enumeration Documentation

◆ Role

Model roles.

Enumerator
VacRole 

The chart, of type GeoMaps::VAC.

NameRole 

Name of the chart, a QString.

SectionRole 

Section of the chart, a QString; see GeoMaps::VAC::section().

CenterRole 

Center of the chart, a QGeoCoordinate.

Definition at line 71 of file VACLibrary.h.

Constructor & Destructor Documentation

◆ VACLibrary()

GeoMaps::VACLibrary::VACLibrary ( QObject * parent = nullptr)

Constructor.

Parameters
parentStandard QObject parent

Member Function Documentation

◆ bindableHasManuallyImported()

QBindable< bool > GeoMaps::VACLibrary::bindableHasManuallyImported ( ) const
inlinenodiscard

Getter function for property of the same name.

Returns
Property hasManuallyImported

Definition at line 117 of file VACLibrary.h.

◆ bindableIsEmpty()

QBindable< bool > GeoMaps::VACLibrary::bindableIsEmpty ( ) const
inlinenodiscard

Getter function for property of the same name.

Returns
Property isEmpty

Definition at line 129 of file VACLibrary.h.

◆ clear()

Q_INVOKABLE void GeoMaps::VACLibrary::clear ( )

Removes all VACs.

This method also deletes the associated files.

◆ data()

QVariant GeoMaps::VACLibrary::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
nodiscardoverride

Re-implemented from QAbstractListModel.

Parameters
indexModel index
roleOne of the roles in VACLibrary::Role
Returns
Data for the role, or an invalid QVariant

◆ get()

Q_INVOKABLE GeoMaps::VAC GeoMaps::VACLibrary::get ( const QString & name)
nodiscard

Obtain VACs from the library.

Parameters
nameName of the VAC
Returns
Returns an invalid, default-constructed VAC if the name does not exist in the library.

◆ hasManuallyImported()

bool GeoMaps::VACLibrary::hasManuallyImported ( ) const
inlinenodiscard

Getter function for property of the same name.

Returns
Property hasManuallyImported

Definition at line 111 of file VACLibrary.h.

◆ importTripKit()

Q_INVOKABLE QString GeoMaps::VACLibrary::importTripKit ( const QString & fileName)
nodiscard

Import trip kit.

Parameters
fileNameName of the trip kit file
Returns
A localized error message, or an empty string on success

◆ importTripKitStatus

void GeoMaps::VACLibrary::importTripKitStatus ( double percent)
signal

Progress report when importing a trip kit.

This signal is emitted when TripKits are imported. At the end of the import, the precise value 1.0 is emitted.

Parameters
percentA number between 0.0 and 1.0.

◆ importVAC()

Q_INVOKABLE QString GeoMaps::VACLibrary::importVAC ( GeoMaps::VAC vac)
nodiscard

Import VAC.

This method copies the file 'fileName' to the library directory. It does not take ownership of the file, and does not delete the file.

Parameters
vacVAC to be imported
Returns
A localized error message, or an empty string on success

◆ isEmpty()

bool GeoMaps::VACLibrary::isEmpty ( ) const
inlinenodiscard

Getter function for property of the same name.

Returns
Property isEmpty

Definition at line 123 of file VACLibrary.h.

◆ materialize()

Q_INVOKABLE GeoMaps::VAC GeoMaps::VACLibrary::materialize ( const GeoMaps::VAC & vac)
nodiscard

Obtain a VAC whose fileName points to a raster image file.

Charts from VAC collections have their member 'fileName' set to the name of the collection file. This method extracts the raster image of such a chart to a cache directory and returns a copy of the VAC whose 'fileName' points to the extracted image, ready for display in the moving map. Manually imported charts are returned unchanged.

Parameters
vacVAC to materialize
Returns
A VAC whose fileName points to a raster image file, or the unchanged input on error.

◆ remove()

Q_INVOKABLE void GeoMaps::VACLibrary::remove ( const QString & name)

Remove one VACs.

Parameters
nameName of the VAC

This method also deletes the associated file.

◆ rename()

Q_INVOKABLE QString GeoMaps::VACLibrary::rename ( const QString & oldName,
const QString & newName )
nodiscard

Rename a VACs.

Parameters
oldNameName of the VAC to be removed
newNameNew name of the VAC
Returns
A localized error message, or an empty string on success

◆ roleNames()

QHash< int, QByteArray > GeoMaps::VACLibrary::roleNames ( ) const
nodiscardoverride

Re-implemented from QAbstractListModel.

Returns
Names of the roles in VACLibrary::Role

◆ rowCount()

int GeoMaps::VACLibrary::rowCount ( const QModelIndex & parent = QModelIndex()) const
nodiscardoverride

Re-implemented from QAbstractListModel.

Parameters
parentParent index, invalid for the list itself
Returns
Number of charts, or zero for a valid parent

◆ vacs()

QList< GeoMaps::VAC > GeoMaps::VACLibrary::vacs ( ) const
inlinenodiscard

Getter function for property of the same name.

Returns
Property vacs

Definition at line 135 of file VACLibrary.h.

◆ vacs4Point()

Q_INVOKABLE QVector< GeoMaps::VAC > GeoMaps::VACLibrary::vacs4Point ( const QGeoCoordinate & position)
nodiscard

List of all VACs that contain a given point.

This method returns the list of all installed VACs that contain the given point.

Parameters
positionGeographic position
Returns
List of all VACs containing the given point.

Property Documentation

◆ vacs

QList<GeoMaps::VAC> GeoMaps::VACLibrary::vacs
read

List of all VACs installed.

This property holds the list of all installed VACs, in model order: sorted by section, then by name.

Definition at line 100 of file VACLibrary.h.


The documentation for this class was generated from the following file: