Enroute Flight Navigation
A navigation app for VFR pilots
Flightlog::FlightLogStorage Class Reference

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ FlightLogStorage()

Flightlog::FlightLogStorage::FlightLogStorage ( QObject * parent)
explicit

Standard constructor.

Opens (creating if necessary) the userdata.db SQLite database and ensures the 'flights' table schema exists.

Parameters
parentThe standard QObject parent pointer

Member Function Documentation

◆ loadAll()

auto Flightlog::FlightLogStorage::loadAll ( ) -> QList< Flight >
nodiscard

Load all flights from the database.

Returns
All flights currently stored, in unspecified order

◆ remove()

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.

Parameters
uuidThe uuid of the flight to delete
Returns
True on success

◆ removeAll()

bool Flightlog::FlightLogStorage::removeAll ( )

Delete every flight.

Returns
True on success

◆ removeMany()

bool Flightlog::FlightLogStorage::removeMany ( const QList< QUuid > & uuids)

Delete multiple flights by uuid, in one transaction.

Parameters
uuidsThe uuids of the flights to delete
Returns
True on success

◆ saveError

void Flightlog::FlightLogStorage::saveError ( const QString & message)
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).

Parameters
messageHuman-readable error description

◆ upsert()

bool Flightlog::FlightLogStorage::upsert ( const Flight & flight)

Insert a flight, or update it if its uuid already exists.

Parameters
flightThe flight to persist
Returns
True on success

◆ upsertMany()

bool Flightlog::FlightLogStorage::upsertMany ( const QList< Flight > & flights)

Insert or update multiple flights, in one transaction.

Parameters
flightsThe flights to persist
Returns
True on success

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