|
Enroute Flight Navigation
A navigation app for VFR pilots
|
List of the entries of a file-based library. More...
#include <FileLibraryModel.h>
Public Types | |
| enum | Role : int { NameRole = Qt::UserRole + 1 } |
| Model roles. More... | |
Public Slots | |
| void | refresh () |
| Rescans the directory. | |
Public Member Functions | |
| FileLibraryModel (QString directory, QString suffix, QObject *parent=nullptr) | |
| Standard constructor. | |
| QStringList | names () const |
| Base names of the library entries. | |
| 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. | |
List of the entries of a file-based library.
A file-based library is a directory that holds one file per entry, all with the same suffix. This model lists the base names of these files under the role 'name', sorted case-insensitively.
The directory is watched with a QFileSystemWatcher, so that the model follows every writer, including those that do not go through Librarian. Changes to the directory are coalesced and applied with row-granular model signals. Writers inside the app call refresh() to apply their changes immediately.
Instances are owned by Librarian, see Librarian::aircraftModel and Librarian::routesModel. In QML, bind a view to one of them through a NameFilterProxyModel.
Definition at line 46 of file FileLibraryModel.h.
| enum FileLibraryModel::Role : int |
Model roles.
| Enumerator | |
|---|---|
| NameRole | Base name of the entry, a QString. |
Definition at line 54 of file FileLibraryModel.h.
|
explicit |
Standard constructor.
| directory | Directory holding the library files. Created if it does not exist. |
| suffix | Suffix of the library files, including the dot, such as ".json" |
| parent | The standard QObject parent pointer |
|
nodiscardoverride |
Re-implemented from QAbstractListModel.
| index | Model index |
| role | One of the roles in FileLibraryModel::Role |
|
inlinenodiscard |
Base names of the library entries.
Definition at line 83 of file FileLibraryModel.h.
|
slot |
Rescans the directory.
Compares the directory content with the model and announces the difference with row-granular signals. This is called automatically when the directory changes; writers inside the app call it to apply their changes without delay.
|
nodiscardoverride |
Re-implemented from QAbstractListModel.
|
nodiscardoverride |
Re-implemented from QAbstractListModel.
| parent | Parent index, invalid for the list itself |