|
Enroute Flight Navigation
A navigation app for VFR pilots
|
Manage libraries and text assets. More...
#include <Librarian.h>
Public Types | |
| enum | Library : quint8 { Aircraft , Routes } |
| Type of library. More... | |
Public Member Functions | |
| Librarian (QObject *parent=nullptr) | |
| Default constructor. | |
| FileLibraryModel * | aircraftModel () const |
| Getter function for the property with the same name. | |
| FileLibraryModel * | routesModel () const |
| Getter function for the property with the same name. | |
| FileLibraryModel * | model (Librarian::Library library) const |
| Model listing the entries of a library. | |
| Q_INVOKABLE bool | matches (const QString &text, const QString &filter) |
| Checks if a text matches a filter string, in a fuzzy way. | |
| QString | simplifySpecialChars (const QString &string) |
| Simplifies string by transforming and removing special characters. | |
Static Public Member Functions | |
| static Q_INVOKABLE bool | contains (const Navigation::Aircraft &acft) |
| Check if an object exists in the library. | |
| static Q_INVOKABLE bool | contains (const QObject *route) |
| Check if a flight route exists in the library. | |
| static Q_INVOKABLE QString | directory (Librarian::Library library) |
| Name of the directory containing the given. | |
| static Q_INVOKABLE bool | exists (Librarian::Library library, const QString &baseName) |
| Check if an entry with the given name exists in the library. | |
| static Q_INVOKABLE QString | fullPath (Librarian::Library library, const QString &baseName) |
| Full path of a library entry. | |
| static Q_INVOKABLE Navigation::FlightRoute * | get (Librarian::Library library, const QString &baseName) |
| Constructs an object from library entry. | |
| static QString | manualLocation () |
| Location of the user manual. | |
| static Q_INVOKABLE QString | getStringFromRessource (const QString &name) |
| Exposes string stored in QRessource to QML. | |
| static Q_INVOKABLE Units::ByteSize | getStringHashFromRessource (const QString &name) |
| Exposes the hash of string stored in QRessource to QML. | |
| static Q_INVOKABLE QString | import (Librarian::Library library, const QString &fileName) |
| Import a file into a library. | |
| static Q_INVOKABLE void | remove (Librarian::Library library, const QString &baseName) |
| Removes an entry from a library. | |
| static Q_INVOKABLE void | rename (Librarian::Library library, const QString &oldName, const QString &newName) |
| Renames an entry in a library. | |
Properties | |
| QML_SINGLETONQString | manualLocation |
| Location of the user manual, see manualLocation(). | |
| FileLibraryModel * | aircraftModel |
| Model listing the entries of the aircraft library, see model(). | |
| FileLibraryModel * | routesModel |
| Model listing the entries of the flight route library, see model(). | |
Manage libraries and text assets.
This class manages libraries of aircrafts and routes, as well as text assets, and exposes these objects to QML.
Definition at line 41 of file Librarian.h.
| enum Librarian::Library : quint8 |
Type of library.
| Enumerator | |
|---|---|
| Aircraft | Aircraft library. |
| Routes | Flight route library. |
Definition at line 77 of file Librarian.h.
|
explicit |
Default constructor.
| parent | The standard QObject parent pointer |
|
inlinenodiscard |
Getter function for the property with the same name.
Definition at line 91 of file Librarian.h.
|
staticnodiscard |
Check if an object exists in the library.
| acft | Aircraft object |
|
staticnodiscard |
Check if a flight route exists in the library.
At the moment, only flight routes are supported.
| route | Pointer to the route |
|
staticnodiscard |
Name of the directory containing the given.
| library | The library that is accessed |
|
staticnodiscard |
Check if an entry with the given name exists in the library.
| library | The library that is accessed |
| baseName | File name, without path and without extension |
|
staticnodiscard |
Full path of a library entry.
| library | The library that is accessed |
| baseName | Name of the entry, without path and without extension |
|
staticnodiscard |
Constructs an object from library entry.
This method constructs an object from a library entry.
If the entry is a route, the route is construted with aircraft and wind set to nullptr, so that no wind computations are possible. It is, however, possible to export the flight route (for instance to GeoJSON or GPX format).
Ownership is transferred to the caller, so it is up to the caller to delete the flight route once it is no longer used. Note that QML does that automatically.
| library | The library that is accessed |
| baseName | File name, without path and without extension |
|
static |
Exposes string stored in QRessource to QML.
This method reads a string from a file stored in the QRessource system. The method expects that the file contains a string in UTF8 encoding. There are a few special strings that are not read from QRessource, but are stored internally and that will be translated. These are the following.
| name | Name of the file in the QRessource, such as ":text/bugReport.html" |
|
static |
Exposes the hash of string stored in QRessource to QML.
This method reads a string from a file stored in the QRessource system. The method expects that the file contains a string in UTF8 encoding.
| name | Name of the file in the QRessource, such as ":text/bugReport.html" |
|
staticnodiscard |
Import a file into a library.
This method imports a file into a library.
| library | The library to import the file. At the moment, only routs is supported. |
| fileName | Full file name |
|
staticnodiscard |
Location of the user manual.
| Q_INVOKABLE bool Librarian::matches | ( | const QString & | text, |
| const QString & | filter ) |
Checks if a text matches a filter string, in a fuzzy way.
This method splits the filter into words at whitespace. The text matches if it contains every one of these words. The comparison ignores case and special characters, so that "Zürich" matches "u", "Ü", "ù" and "zurich". An empty filter matches every text.
This is the single filter primitive of this app. Lists over item models use it through Ui::NameFilterProxyModel; ad-hoc lists use it from QML, as in
model: Array.from(SomeSingleton.items).filter((i) => Librarian.matches(i.name, filterField.filter))
| text | Text that is searched |
| filter | Filter, possibly consisting of several words |
|
nodiscard |
Model listing the entries of a library.
The model follows the library directory and announces changes with row-granular signals. It is owned by this instance.
| library | The library |
|
static |
Removes an entry from a library.
| library | The library that is accessed |
| baseName | File name, without path and without extension |
|
static |
Renames an entry in a library.
| library | The library that is accessed |
| oldName | Name of the file that is to be renamed, without path and without extension |
| newName | New file name, without path and without extension. A file with that name must not exist in the library |
|
inlinenodiscard |
Getter function for the property with the same name.
Definition at line 97 of file Librarian.h.
| QString Librarian::simplifySpecialChars | ( | const QString & | string | ) |
Simplifies string by transforming and removing special characters.
This helper method simplifies a unicode string, by transforming it to QString::NormalizationForm_KD and then removing all 'special' character. The results are cached for better performance.
| string | Input string |