Enroute Flight Navigation
A navigation app for VFR pilots
WaypointSearchModel.h
1/***************************************************************************
2 * Copyright (C) 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 <QAbstractListModel>
24#include <QQmlEngine>
25
26#include "geomaps/Waypoint.h"
27
28namespace Ui {
29
50
51class WaypointSearchModel : public QAbstractListModel
52{
53 Q_OBJECT
54 QML_ELEMENT
55
56public:
58 enum Role : int {
60 WaypointRole = Qt::UserRole + 1,
61
64
67 };
68
73 explicit WaypointSearchModel(QObject* parent = nullptr);
74
75 // Default destructor
76 ~WaypointSearchModel() override = default;
77
78
79 //
80 // Methods
81 //
82
89 [[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override;
90
99 [[nodiscard]] QVariant data(const QModelIndex& index, int role) const override;
100
105 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
106
107private:
108 Q_DISABLE_COPY_MOVE(WaypointSearchModel)
109
110 // Replaces the map rows with the current aviation data
111 void resetMapWaypoints();
112
113 // Number of rows taken by the waypoint library
114 [[nodiscard]] static int libraryRowCount();
115
116 // Snapshots of GeoMapProvider::waypoints() and waypointSearchKeys(),
117 // implicitly shared with the provider
118 QList<GeoMaps::Waypoint> m_mapWaypoints;
119 QStringList m_mapSearchKeys;
120};
121
122} // namespace Ui
@ WaypointRole
The waypoint, of type GeoMaps::Waypoint.
@ SearchKeyRole
Pre-simplified search key, a QString.
@ NameRole
Name of the waypoint, a QString.
QHash< int, QByteArray > roleNames() const override
Implementation of QAbstractListModel::roleNames.
QVariant data(const QModelIndex &index, int role) const override
Implementation of QAbstractListModel::data.
WaypointSearchModel(QObject *parent=nullptr)
Standard constructor.
int rowCount(const QModelIndex &parent={}) const override
Implementation of QAbstractListModel::rowCount.