|
Enroute Flight Navigation
A navigation app for VFR pilots
|
SQLite-backed storage for the flight log. More...
#include <FlightLogStorage.h>
Signals | |
| void | saveError (const QString &message) |
| Emitted when a database operation fails. | |
Public Member Functions | |
| FlightLogStorage (QObject *parent) | |
| Standard constructor. | |
| ~FlightLogStorage () override | |
| Standard destructor. | |
| auto | loadAll () -> QList< Flight > |
| Load all flights from the database. | |
| bool | upsert (const Flight &flight) |
| Insert a flight, or update it if its uuid already exists. | |
| bool | upsertMany (const QList< Flight > &flights) |
| Insert or update multiple flights, in one transaction. | |
| bool | remove (const QUuid &uuid) |
| Delete a flight by uuid. | |
| bool | removeMany (const QList< QUuid > &uuids) |
| Delete multiple flights by uuid, in one transaction. | |
| bool | removeAll () |
| Delete every flight. | |
SQLite-backed storage for the flight log.
Owns the app's user-data SQLite database (userdata.db, shared with other user data that may be added later, e.g. an aircraft list) and persists the 'flights' table within it.
Per-operation persistence: each method here writes only the row(s) it names, rather than reconciling the whole table against an in-memory list. FlightLog still keeps its own in-memory QList<Flight> (the app's dataset is small enough that this costs nothing, and most of FlightLog's logic — sorting, uuid lookups, export selection — is naturally list-shaped); this class exists purely to keep the on-disk copy in sync with each individual change as it happens.
Definition at line 47 of file FlightLogStorage.h.
|
explicit |
Standard constructor.
Opens (creating if necessary) the userdata.db SQLite database and ensures the 'flights' table schema exists.
| parent | The standard QObject parent pointer |
|
nodiscard |
Load all flights from the database.
| bool Flightlog::FlightLogStorage::remove | ( | const QUuid & | uuid | ) |
Delete a flight by uuid.
Does nothing (and still returns true) if no row with this uuid exists.
| uuid | The uuid of the flight to delete |
| bool Flightlog::FlightLogStorage::removeAll | ( | ) |
Delete every flight.
| bool Flightlog::FlightLogStorage::removeMany | ( | const QList< QUuid > & | uuids | ) |
Delete multiple flights by uuid, in one transaction.
| uuids | The uuids of the flights to delete |
|
signal |
Emitted when a database operation fails.
Always delivered via a queued connection, so it is safe to emit from the constructor (before any signal connections exist yet).
| message | Human-readable error description |
| bool Flightlog::FlightLogStorage::upsert | ( | const Flight & | flight | ) |
Insert a flight, or update it if its uuid already exists.
| flight | The flight to persist |
| bool Flightlog::FlightLogStorage::upsertMany | ( | const QList< Flight > & | flights | ) |
Insert or update multiple flights, in one transaction.
| flights | The flights to persist |