Enroute Flight Navigation
A navigation app for VFR pilots
Ui::WaypointSearchModel Class Reference

Item model over all waypoints known to the app, for search lists. More...

#include <WaypointSearchModel.h>

Public Types

enum  Role : int { WaypointRole = Qt::UserRole + 1 , NameRole , SearchKeyRole }
 Model roles. More...

Public Member Functions

 WaypointSearchModel (QObject *parent=nullptr)
 Standard constructor.
int rowCount (const QModelIndex &parent={}) const override
 Implementation of QAbstractListModel::rowCount.
QVariant data (const QModelIndex &index, int role) const override
 Implementation of QAbstractListModel::data.
QHash< int, QByteArray > roleNames () const override
 Implementation of QAbstractListModel::roleNames.

Detailed Description

Item model over all waypoints known to the app, for search lists.

Rows are the waypoints of the WaypointLibrary (the user's own waypoints, first), followed by the waypoints of the installed aviation maps. Both groups are sorted by name. Library changes are forwarded row by row; a change of the aviation data replaces the map rows in a single reset.

The role 'searchKey' holds Librarian::simplify(name) + " " + Librarian::simplify(ICAO code). For the map rows it is precomputed on the worker thread that reads the aviation data, so that a NameFilterProxyModel with filterRoleIsSimplified can filter tens of thousands of rows on every keystroke without normalising a single name:

model: NameFilterProxyModel { sourceModel: WaypointSearchModel {} filterRoleName: "searchKey" filterRoleIsSimplified: true filter: textInput.filter }

Definition at line 51 of file WaypointSearchModel.h.

Member Enumeration Documentation

◆ Role

Model roles.

Enumerator
WaypointRole 

The waypoint, of type GeoMaps::Waypoint.

NameRole 

Name of the waypoint, a QString.

SearchKeyRole 

Pre-simplified search key, a QString.

Definition at line 58 of file WaypointSearchModel.h.

Constructor & Destructor Documentation

◆ WaypointSearchModel()

Ui::WaypointSearchModel::WaypointSearchModel ( QObject * parent = nullptr)
explicit

Standard constructor.

Parameters
parentThe standard QObject parent pointer

Member Function Documentation

◆ data()

QVariant Ui::WaypointSearchModel::data ( const QModelIndex & index,
int role ) const
nodiscardoverride

Implementation of QAbstractListModel::data.

Parameters
indexModel index
roleRole, see enum Role
Returns
Data for the role

◆ roleNames()

QHash< int, QByteArray > Ui::WaypointSearchModel::roleNames ( ) const
nodiscardoverride

Implementation of QAbstractListModel::roleNames.

Returns
Role names "waypoint", "name" and "searchKey"

◆ rowCount()

int Ui::WaypointSearchModel::rowCount ( const QModelIndex & parent = {}) const
nodiscardoverride

Implementation of QAbstractListModel::rowCount.

Parameters
parentParent index, ignored for a list
Returns
Number of library waypoints plus number of map waypoints

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