|
Enroute Flight Navigation
A navigation app for VFR pilots
|
Library of user-defined waypoints. More...
#include <WaypointLibrary.h>
Public Types | |
| enum | Role : int { WaypointRole = Qt::UserRole + 1 , NameRole } |
| Model roles. More... | |
Signals | |
| void | waypointsChanged () |
| Notification signal for the property with the same name. | |
Public Member Functions | |
| WaypointLibrary (QObject *parent=nullptr) | |
| Creates a new waypoint library. | |
| QList< GeoMaps::Waypoint > | waypoints () const |
| Getter function for property with the same name. | |
| QByteArray | GeoJSON () const |
| Getter function for property with 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 | add (const GeoMaps::Waypoint &waypoint) |
| Adds a waypoint to the library. | |
| Q_INVOKABLE void | clear () |
| Clears the waypoint library. | |
| Q_INVOKABLE bool | contains (const GeoMaps::Waypoint &waypoint) const |
| Checks if library contains an given waypoint. | |
| Q_INVOKABLE bool | hasNearbyEntry (const GeoMaps::Waypoint &waypoint) const |
| Check if the library contains a waypoint near to a given one. | |
| Q_INVOKABLE QString | import (const QString &fileName, bool skip) |
| Import waypoints into the library. | |
| Q_INVOKABLE QString | loadFromGeoJSON (QString fileName={}) |
| Read from file. | |
| Q_INVOKABLE bool | remove (const GeoMaps::Waypoint &waypoint) |
| Remove waypoint. | |
| Q_INVOKABLE bool | replace (const GeoMaps::Waypoint &oldWaypoint, const GeoMaps::Waypoint &newWaypoint) |
| Replace waypoint. | |
| Q_INVOKABLE QString | save (QString fileName={}) const |
| Save to file. | |
| Q_INVOKABLE QByteArray | toGpx () const |
| Serialize into GPX document. | |
Properties | |
| QList< GeoMaps::Waypoint > | waypoints |
| List of waypoints. | |
| QByteArray | GeoJSON |
| List of waypoints. | |
Library of user-defined waypoints.
This class holds the list of user-defined waypoints, sorted by name, and exposes it as a list model with the roles 'waypoint' and 'name'. The library is loaded from a GeoJSON file on construction and saved every time that a change is made.
Changes are announced with row-granular model signals, so that views bound to this model update incrementally, and with the coarse signal waypointsChanged() for consumers of the property 'waypoints'. In QML, bind a view to this singleton through a NameFilterProxyModel.
Definition at line 46 of file WaypointLibrary.h.
| enum GeoMaps::WaypointLibrary::Role : int |
Model roles.
| Enumerator | |
|---|---|
| WaypointRole | The waypoint, of type GeoMaps::Waypoint. |
| NameRole | Name of the waypoint, a QString. |
Definition at line 75 of file WaypointLibrary.h.
|
explicit |
Creates a new waypoint library.
This constructor creates a new WaypointLibrary instance. The library is loaded from a GeoJSON file whose name is found in the private member stdFileName.
| parent | The standard QObject parent |
| Q_INVOKABLE void GeoMaps::WaypointLibrary::add | ( | const GeoMaps::Waypoint & | waypoint | ) |
Adds a waypoint to the library.
| waypoint | Waypoint to be added. If that waypoint is invalid, this method will not do anything |
|
inlinenodiscard |
Checks if library contains an given waypoint.
| waypoint | Waypoint |
Definition at line 171 of file WaypointLibrary.h.
|
nodiscardoverride |
Re-implemented from QAbstractListModel.
| index | Model index |
| role | One of the roles in WaypointLibrary::Role |
|
nodiscard |
Getter function for property with the same name.
|
nodiscard |
Check if the library contains a waypoint near to a given one.
The method checks proximity with the method GeoMaps::Waypoint::isNear
| waypoint | Waypoint |
|
nodiscard |
Import waypoints into the library.
This method reads waypoints from a file and adds them to the library.
| fileName | Name of file to import. Must be in CUP, GPX or GeoJSON format. |
| skip | If true, skip over waypoints that already exist in the library |
|
nodiscard |
Read from file.
Reads the library from a file in GeoJSON format. On sucess, the current library is replaced in full. On error, the current library is not touched at all.
| fileName | File name. If emty, a standard file name will be used, in QStandardPaths::AppDataLocation. See the private member stdFileName for details. |
| Q_INVOKABLE bool GeoMaps::WaypointLibrary::remove | ( | const GeoMaps::Waypoint & | waypoint | ) |
Remove waypoint.
Removes the first waypoint from the list that matches the given waypoint exactly. If no waypoint matches, this method does nothing.
| waypoint | Waypoint to be removed |
| Q_INVOKABLE bool GeoMaps::WaypointLibrary::replace | ( | const GeoMaps::Waypoint & | oldWaypoint, |
| const GeoMaps::Waypoint & | newWaypoint ) |
Replace waypoint.
Replaces the first waypoint from the list that matches the given oldWaypoint exactly. If no waypoint matches, this method does nothing.
| oldWaypoint | Waypoint that shall be replaced |
| newWaypoint | Waypoint replacement. If this waypoint is invalid, the method returns immediately and does nothing. |
|
nodiscardoverride |
Re-implemented from QAbstractListModel.
|
nodiscardoverride |
Re-implemented from QAbstractListModel.
| parent | Parent index, invalid for the list itself |
|
nodiscard |
Save to file.
Saves the library in GeoJSON format.
| fileName | File name. If emty, a standard file name will be used, in QStandardPaths::AppDataLocation. See the private member stdFileName for details. |
|
nodiscard |
|
inlinenodiscard |
Getter function for property with the same name.
Definition at line 109 of file WaypointLibrary.h.
|
signal |
Notification signal for the property with the same name.
This coarse signal is emitted after every change, following the row-granular model signals.
|
read |
List of waypoints.
This property holds the list of waypoints, in alphabetical order.
Definition at line 98 of file WaypointLibrary.h.
|
read |
List of waypoints.
This property holds the list of waypoints, in alphabetical order
Definition at line 92 of file WaypointLibrary.h.