|
| | Librarian (QObject *parent=nullptr) |
| | Default constructor.
|
| Q_INVOKABLE QStringList | entries (Librarian::Library library, const QString &filter=QString()) |
| | Lists all entries in the library whose name contains the string 'filter'.
|
| Q_INVOKABLE bool | matches (const QString &text, const QString &filter) |
| | Checks if a text matches a filter string, in a fuzzy way.
|
| QStringList | permissiveFilter (const QStringList &input, const QString &filter) |
| | Filters a QStringList in a fuzzy way.
|
| QString | simplifySpecialChars (const QString &string) |
| | Simplifies string by transforming and removing special characters.
|
|
| 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 QObject * | get (Librarian::Library library, const QString &baseName) |
| | Constructs an object from library entry.
|
| 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.
|
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 39 of file Librarian.h.
| Q_INVOKABLE QObject * Librarian::get |
( |
Librarian::Library | library, |
|
|
const QString & | baseName ) |
|
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.
- Parameters
-
| library | The library that is accessed |
| baseName | File name, without path and without extension |
- Returns
- Pointer to the object, or a nullptr in case of error.
| 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. Use it from QML to filter list models, as in
model: Array.from(SomeSingleton.items).filter((i) => Librarian.matches(i.name, filterField.filter))
- Parameters
-
| text | Text that is searched |
| filter | Filter, possibly consisting of several words |
- Returns
- True if the text matches the filter