23#include <QAbstractListModel>
25#include <QStandardPaths>
27#include "GlobalObject.h"
28#include "geomaps/Waypoint.h"
131 [[nodiscard]]
int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
141 [[nodiscard]] QVariant
data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
147 [[nodiscard]] QHash<int, QByteArray>
roleNames()
const override;
173 return m_waypoints.contains(waypoint);
196 [[nodiscard]] Q_INVOKABLE QString
import(
const QString& fileName,
bool skip);
250 [[nodiscard]] Q_INVOKABLE QString
save(QString fileName = {})
const;
260 [[nodiscard]] Q_INVOKABLE QByteArray
toGpx()
const;
275 [[nodiscard]]
int insertionRow(
const QString& name)
const;
278 static void sortByName(QList<GeoMaps::Waypoint>&
waypoints);
281 QString stdFileName{QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) +
"/waypoint library.geojson"};
284 QList<GeoMaps::Waypoint> m_waypoints;
Library of user-defined waypoints.
Q_INVOKABLE bool contains(const GeoMaps::Waypoint &waypoint) const
Checks if library contains an given waypoint.
QByteArray GeoJSON
List of waypoints.
Q_INVOKABLE QByteArray toGpx() const
Serialize into GPX document.
Q_INVOKABLE bool hasNearbyEntry(const GeoMaps::Waypoint &waypoint) const
Check if the library contains a waypoint near to a given one.
WaypointLibrary(QObject *parent=nullptr)
Creates a new waypoint library.
Q_INVOKABLE void clear()
Clears the waypoint library.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Re-implemented from QAbstractListModel.
void waypointsChanged()
Notification signal for the property with the same name.
Q_INVOKABLE void add(const GeoMaps::Waypoint &waypoint)
Adds a waypoint to the library.
QHash< int, QByteArray > roleNames() const override
Re-implemented from QAbstractListModel.
QList< GeoMaps::Waypoint > waypoints
List of waypoints.
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.
@ NameRole
Name of the waypoint, a QString.
@ WaypointRole
The waypoint, of type GeoMaps::Waypoint.
Q_INVOKABLE QString save(QString fileName={}) const
Save to file.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Re-implemented from QAbstractListModel.
QByteArray GeoJSON() const
Getter function for property with the same name.
Waypoint, such as an airfield, a navaid station or a reporting point.
static Q_INVOKABLE GeoMaps::WaypointLibrary * waypointLibrary()
Pointer to appplication-wide static WaypointLibrary instance.