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

Filters a list model by a fuzzy name match. More...

#include <NameFilterProxyModel.h>

Inheritance diagram for Ui::NameFilterProxyModel:
Ui::DistanceSortProxyModel

Signals

void filterChanged ()
 Notification signal for property with the same name.
void filterRoleNameChanged ()
 Notification signal for property with the same name.

Public Member Functions

 NameFilterProxyModel (QObject *parent=nullptr)
 Standard constructor.
QString filter () const
 Getter function for the property with the same name.
QString filterRoleName () const
 Getter function for the property with the same name.
void setFilter (const QString &newFilter)
 Setter function for the property with the same name.
void setFilterRoleName (const QString &newFilterRoleName)
 Setter function for the property with the same name.
void setSourceModel (QAbstractItemModel *newSourceModel) override
 Re-implemented from QAbstractProxyModel.

Protected Member Functions

bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override
 Re-implemented from QSortFilterProxyModel.
int roleForName (const QString &roleName) const
 Looks up a role by name in the source model.

Properties

QString filter
 Filter string.
QString filterRoleName
 Name of the source model role that the filter is matched against.

Detailed Description

Filters a list model by a fuzzy name match.

This proxy model accepts those rows of its source model whose entry for the role 'filterRoleName' matches the property 'filter', in the sense of Librarian::matches(). The order of the source model is preserved. Typical use in QML:

ListView {
sourceModel: WaypointLibrary
filter: filterField.filter
}
}
QString filter
Filter string.
NameFilterProxyModel(QObject *parent=nullptr)
Standard constructor.

Definition at line 60 of file NameFilterProxyModel.h.

Constructor & Destructor Documentation

◆ NameFilterProxyModel()

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

Standard constructor.

Parameters
parentThe standard QObject parent pointer

Member Function Documentation

◆ filter()

QString Ui::NameFilterProxyModel::filter ( ) const
inlinenodiscard

Getter function for the property with the same name.

Returns
Property filter

Definition at line 103 of file NameFilterProxyModel.h.

◆ filterAcceptsRow()

bool Ui::NameFilterProxyModel::filterAcceptsRow ( int sourceRow,
const QModelIndex & sourceParent ) const
nodiscardoverrideprotected

Re-implemented from QSortFilterProxyModel.

Parameters
sourceRowRow in the source model
sourceParentParent index in the source model
Returns
True if the row matches the filter

◆ filterRoleName()

QString Ui::NameFilterProxyModel::filterRoleName ( ) const
inlinenodiscard

Getter function for the property with the same name.

Returns
Property filterRoleName

Definition at line 109 of file NameFilterProxyModel.h.

◆ roleForName()

int Ui::NameFilterProxyModel::roleForName ( const QString & roleName) const
nodiscardprotected

Looks up a role by name in the source model.

Parameters
roleNameRole name, as found in QAbstractItemModel::roleNames()
Returns
The role, or -1 if there is no source model or no role of that name

◆ setFilter()

void Ui::NameFilterProxyModel::setFilter ( const QString & newFilter)

Setter function for the property with the same name.

Parameters
newFilterProperty filter

◆ setFilterRoleName()

void Ui::NameFilterProxyModel::setFilterRoleName ( const QString & newFilterRoleName)

Setter function for the property with the same name.

Parameters
newFilterRoleNameProperty filterRoleName

◆ setSourceModel()

void Ui::NameFilterProxyModel::setSourceModel ( QAbstractItemModel * newSourceModel)
override

Re-implemented from QAbstractProxyModel.

Parameters
newSourceModelSource model

Property Documentation

◆ filter

QString Ui::NameFilterProxyModel::filter
readwrite

Filter string.

Rows are accepted if Librarian::matches() holds for the filter and the text of the role 'filterRoleName'. The empty string accepts all rows.

Definition at line 85 of file NameFilterProxyModel.h.

◆ filterRoleName

QString Ui::NameFilterProxyModel::filterRoleName
readwrite

Name of the source model role that the filter is matched against.

Defaults to "name". Rows are accepted unconditionally if the source model has no role of this name.

Definition at line 92 of file NameFilterProxyModel.h.


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