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

Flight log manager with pluggable automatic flight detection. More...

#include <FlightLog.h>

Inheritance diagram for Flightlog::FlightLog:
GlobalObject

Signals

void flightsChanged ()
 Notifier signal.
void detectionStateChanged ()
 Notifier signal.
void displayedTrackPathChanged ()
 Notifier signal for displayedTrackPath and displayedTrackIndex.
void trackRecordingChanged ()
 Notifier signal.
void showCurrentFlightTraceChanged ()
 Notifier signal.
void takeoffDetected (const QString &time)
 Emitted when a takeoff is detected.
void landingDetected (const QString &time)
 Emitted when a landing is detected.
void saveError (const QString &message)
 Emitted when saving the flight log file fails.

Public Member Functions

 FlightLog (QObject *parent=nullptr)
 Standard constructor.
void deferredInitialization () override
 Non-constructor initialization.
 ~FlightLog () override=default
 Standard destructor.
Q_INVOKABLE void addFlight (const Flightlog::Flight &flight)
 Add a new flight to the log.
Q_INVOKABLE void removeFlight (const QString &uuid)
 Remove a flight from the log by UUID.
Q_INVOKABLE void removeFlights (const QStringList &uuids)
 Remove multiple flights from the log by UUID.
Q_INVOKABLE void clearFlights ()
 Remove all flights from the log.
Q_INVOKABLE void updateFlight (const QString &uuid, const Flightlog::Flight &flight)
 Update an existing flight in the log.
Q_INVOKABLE void endFlight ()
 Manually end the current in-flight recording.
Q_INVOKABLE QString lastArrivalICAO (const QString &aircraftCallsign) const
 Find the last arrival ICAO for a given aircraft.
Q_INVOKABLE QByteArray exportToIGC (const QString &uuid) const
 Get IGC track content for a flight.
Q_INVOKABLE QByteArray exportToForeFlight (const QStringList &uuids) const
 Generate ForeFlight CSV content for selected flights.
Q_INVOKABLE QByteArray exportToJSON (const QStringList &uuids) const
 Generate JSON content for selected flights.
Q_INVOKABLE void removeTrack (const QString &uuid)
 Delete the recorded track for a flight.
Q_INVOKABLE void showTrack (const QString &uuid)
 Show a flight's track on the map.
Q_INVOKABLE void hideTrack ()
 Hide the currently displayed track from the map.
Public Member Functions inherited from GlobalObject
 GlobalObject (QObject *parent=nullptr)
 Standard constructor.
 ~GlobalObject () override=default
 Standard deconstructor.

Static Public Member Functions

static Q_INVOKABLE Flightlog::Flight createFlight (const QString &departureICAO, const QString &arrivalICAO, const QString &date, const QString &offBlockTimeStr, const QString &startTimeStr, const QString &landingTimeStr, const QString &onBlockTimeStr, const QString &pilotName, const QString &aircraftCallsign, const QString &comments)
 Create a Flight value from individual field strings.
static Q_INVOKABLE GeoMaps::Waypoint nearestAirfield (const QGeoCoordinate &position={}, double proximityM=5000.0)
 Find the nearest airfield within 5 km.
Static Public Member Functions inherited from GlobalObject
static void clear ()
 Deletes all globally defined objects.
static Q_INVOKABLE bool canConstruct ()
 Indicates if the static methods are ready to be used.
static Q_INVOKABLE Navigation::Clockclock ()
 Pointer to appplication-wide static Navigation::Clock instance.
static Q_INVOKABLE DataManagement::DataManagerdataManager ()
 Pointer to appplication-wide static GeoMaps::DataManager instance.
static Q_INVOKABLE DemoRunnerdemoRunner ()
 Pointer to appplication-wide static DemoRunner instance.
static Q_INVOKABLE Traffic::FlarmnetDBflarmnetDB ()
 Pointer to appplication-wide static FlarmnetDB instance.
static Q_INVOKABLE Platform::FileExchangefileExchange ()
 Pointer to appplication-wide static FileExchange instance.
static Q_INVOKABLE Flightlog::FlightLogflightLog ()
 Pointer to appplication-wide static FlightLog instance.
static Q_INVOKABLE GeoMaps::GeoMapProvidergeoMapProvider ()
 Pointer to appplication-wide static GeoMaps::GeoMapProvider instance.
static Q_INVOKABLE GlobalSettingsglobalSettings ()
 Pointer to appplication-wide static Settings instance.
static Q_INVOKABLE Librarianlibrarian ()
 Pointer to appplication-wide static librarian instance.
static Q_INVOKABLE Platform::PlatformAdaptorplatformAdaptor ()
 Pointer to appplication-wide static PlatformAdaptor instance.
static Q_INVOKABLE Sensorssensors ()
 Pointer to appplication-wide static Navigation::Clock instance.
static Q_INVOKABLE Navigation::Navigatornavigator ()
 Pointer to appplication-wide static Navigation::Navigator instance.
static Q_INVOKABLE Traffic::PasswordDBpasswordDB ()
 Pointer to appplication-wide static PasswordDB instance.
static Q_INVOKABLE Positioning::PositionProviderpositionProvider ()
 Pointer to appplication-wide static PositionProvider instance.
static Q_INVOKABLE NOTAM::NOTAMProvidernotamProvider ()
 Pointer to appplication-wide static notification manager instance.
static Q_INVOKABLE Notifications::NotificationManagernotificationManager ()
 Pointer to appplication-wide static notification manager instance.
static Q_INVOKABLE QNetworkAccessManager * networkAccessManager ()
 Pointer to appplication-wide static QNetworkAccessManager instance.
static Q_INVOKABLE DataManagement::SSLErrorHandlersslErrorHandler ()
 Pointer to appplication-wide static QNetworkAccessManager instance.
static Q_INVOKABLE Traffic::TrafficDataProvidertrafficDataProvider ()
 Pointer to appplication-wide static TrafficDataProvider instance.
static Q_INVOKABLE GeoMaps::WaypointLibrarywaypointLibrary ()
 Pointer to appplication-wide static WaypointLibrary instance.
static Q_INVOKABLE Weather::WeatherDataProviderweatherDataProvider ()
 Pointer to appplication-wide static WeatherDataProvider instance.

Properties

QList< Flightlog::Flightflights
 List of all recorded flights, newest first.
Flightlog::FlightDetector::DetectionState detectionState
 Current state of the automatic detection state machine.
int count
 Number of recorded flights.
QGeoPath displayedTrackPath
 Coordinates of the track currently displayed on the map.
QString displayedTrackUuid
 UUID of the flight whose track is displayed, or empty string if none.
bool trackRecording
 Whether GPS track recording is enabled.
bool showCurrentFlightTrace
 Whether the live trace of the current flight is shown on map.

Detailed Description

Flight log manager with pluggable automatic flight detection.

This class manages a persistent list of flight log entries and provides CRUD operations for flights. Automatic takeoff/landing detection is delegated to a FlightDetector subclass, which can be swapped at runtime to support different types of flying (e.g. powered aircraft, paragliders).

The detection state is forwarded from the active FlightDetector and exposed to QML via the detectionState property.

Definition at line 52 of file FlightLog.h.

Constructor & Destructor Documentation

◆ FlightLog()

Flightlog::FlightLog::FlightLog ( QObject * parent = nullptr)
explicit

Standard constructor.

Parameters
parentThe standard QObject parent pointer

Member Function Documentation

◆ addFlight()

Q_INVOKABLE void Flightlog::FlightLog::addFlight ( const Flightlog::Flight & flight)

Add a new flight to the log.

The flight is prepended (newest first). Coordinates are resolved from the ICAO codes if possible.

Parameters
flightThe flight to add

◆ clearFlights()

Q_INVOKABLE void Flightlog::FlightLog::clearFlights ( )

Remove all flights from the log.

Deletes every flight entry and its associated track file, then saves and emits flightsChanged() once.

◆ createFlight()

Q_INVOKABLE Flightlog::Flight Flightlog::FlightLog::createFlight ( const QString & departureICAO,
const QString & arrivalICAO,
const QString & date,
const QString & offBlockTimeStr,
const QString & startTimeStr,
const QString & landingTimeStr,
const QString & onBlockTimeStr,
const QString & pilotName,
const QString & aircraftCallsign,
const QString & comments )
static

Create a Flight value from individual field strings.

This factory method is intended for QML use, where constructing a Q_GADGET value type with all properties is cumbersome.

Parameters
departureICAOICAO code of departure airport
arrivalICAOICAO code of arrival airport
dateDate string in yyyy-MM-dd format
offBlockTimeStrOff-block time string in HH:mm format, or empty
startTimeStrStart time string in HH:mm format
landingTimeStrLanding time string in HH:mm format
onBlockTimeStrOn-block time string in HH:mm format, or empty
pilotNamePilot name, or empty
aircraftCallsignAircraft callsign (e.g. D-KEBE), or empty
commentsFree-text comments, or empty
Returns
A new Flight with the given values

◆ deferredInitialization()

void Flightlog::FlightLog::deferredInitialization ( )
overridevirtual

Non-constructor initialization.

This method is called by the static methods that create global instances immediately after the constructor returns. This class can be re-implemented to perform initialization steps that refer to other singleton objects.

Reimplemented from GlobalObject.

◆ endFlight()

Q_INVOKABLE void Flightlog::FlightLog::endFlight ( )

Manually end the current in-flight recording.

Delegates to the active FlightDetector. If the detector is in InFlight or LandingPhase state, it completes the flight entry with the current UTC time. Does nothing if not in InFlight or LandingPhase.

◆ exportToForeFlight()

Q_INVOKABLE QByteArray Flightlog::FlightLog::exportToForeFlight ( const QStringList & uuids) const
nodiscard

Generate ForeFlight CSV content for selected flights.

Returns the CSV bytes ready for sharing. If uuids is empty, all flights are included.

Parameters
uuidsUUIDs of the flights to include; empty means all
Returns
CSV content as UTF-8, or empty if no matching flights

◆ exportToIGC()

Q_INVOKABLE QByteArray Flightlog::FlightLog::exportToIGC ( const QString & uuid) const
nodiscard

Get IGC track content for a flight.

Returns the raw IGC file bytes ready for sharing. Returns an empty array if the flight has no track or the file cannot be read.

Parameters
uuidUUID of the flight to export (with or without braces)
Returns
IGC file content, or empty

◆ exportToJSON()

Q_INVOKABLE QByteArray Flightlog::FlightLog::exportToJSON ( const QStringList & uuids) const
nodiscard

Generate JSON content for selected flights.

Returns the JSON bytes ready for sharing. Uses the same internal format as the persisted flight log file. If uuids is empty, all flights are included.

Parameters
uuidsUUIDs of the flights to include; empty means all
Returns
JSON content, or empty if no matching flights

◆ landingDetected

void Flightlog::FlightLog::landingDetected ( const QString & time)
signal

Emitted when a landing is detected.

Parameters
timeThe landing time as a human-readable UTC string (HH:mm)

◆ lastArrivalICAO()

Q_INVOKABLE QString Flightlog::FlightLog::lastArrivalICAO ( const QString & aircraftCallsign) const

Find the last arrival ICAO for a given aircraft.

Searches the flight log for the most recent flight with the given aircraft callsign and returns its arrival ICAO code. Returns an empty string if no matching flight is found.

Parameters
aircraftCallsignThe callsign to search for
Returns
Arrival ICAO of the most recent matching flight

◆ nearestAirfield()

Q_INVOKABLE GeoMaps::Waypoint Flightlog::FlightLog::nearestAirfield ( const QGeoCoordinate & position = {},
double proximityM = 5000.0 )
static

Find the nearest airfield within 5 km.

Returns the closest airfield (type "AD") to the given position, provided it is within proximityM metres. Returns an invalid Waypoint if none found. If no position is given (or an invalid one), the last valid coordinate from PositionProvider is used.

Parameters
positionThe geographic position to search near (default: current GPS position)
proximityMMaximum search radius in metres (default: 5000)
Returns
The nearest airfield, or an invalid Waypoint

◆ removeFlight()

Q_INVOKABLE void Flightlog::FlightLog::removeFlight ( const QString & uuid)

Remove a flight from the log by UUID.

Does nothing if no flight with the given UUID exists.

Parameters
uuidThe UUID of the flight to remove (with or without braces)

◆ removeFlights()

Q_INVOKABLE void Flightlog::FlightLog::removeFlights ( const QStringList & uuids)

Remove multiple flights from the log by UUID.

Removes all flights whose UUIDs appear in uuids. Saves and emits flightsChanged() exactly once regardless of how many are removed. Does nothing if none of the UUIDs match.

Parameters
uuidsUUIDs of the flights to remove (with or without braces)

◆ removeTrack()

Q_INVOKABLE void Flightlog::FlightLog::removeTrack ( const QString & uuid)

Delete the recorded track for a flight.

Removes the IGC file from disk and clears the trackFile property on the flight entry.

Parameters
uuidUUID of the flight whose track to delete (with or without braces)

◆ saveError

void Flightlog::FlightLog::saveError ( const QString & message)
signal

Emitted when saving the flight log file fails.

The previously saved flight log on disk remains intact, but the latest change could not be persisted.

Parameters
messageHuman-readable error description

◆ showTrack()

Q_INVOKABLE void Flightlog::FlightLog::showTrack ( const QString & uuid)

Show a flight's track on the map.

Loads the track if needed and sets it as the displayed track. Only one track can be displayed at a time.

Parameters
uuidUUID of the flight whose track to show (with or without braces)

◆ takeoffDetected

void Flightlog::FlightLog::takeoffDetected ( const QString & time)
signal

Emitted when a takeoff is detected.

Parameters
timeThe takeoff time as a human-readable UTC string (HH:mm)

◆ updateFlight()

Q_INVOKABLE void Flightlog::FlightLog::updateFlight ( const QString & uuid,
const Flightlog::Flight & flight )

Update an existing flight in the log.

Coordinates are re-resolved from the ICAO codes. If resolution fails, old coordinates are preserved.

Parameters
uuidUUID of the flight to update (with or without braces)
flightThe updated flight data

Property Documentation

◆ displayedTrackPath

QGeoPath Flightlog::FlightLog::displayedTrackPath
read

Coordinates of the track currently displayed on the map.

Returns the geo path of the selected saved track, or the live recording track if in flight and no saved track is selected. Empty when no track is displayed.

Definition at line 108 of file FlightLog.h.

◆ displayedTrackUuid

QString Flightlog::FlightLog::displayedTrackUuid
read

UUID of the flight whose track is displayed, or empty string if none.

Computed from the displayed track file. Returns an empty string when showing the live track or no track.

Definition at line 116 of file FlightLog.h.

◆ showCurrentFlightTrace

bool Flightlog::FlightLog::showCurrentFlightTrace
readwrite

Whether the live trace of the current flight is shown on map.

When true, the current in-memory live track is exposed through displayedTrackPath while no saved track is selected. Default is true.

Definition at line 133 of file FlightLog.h.

◆ trackRecording

bool Flightlog::FlightLog::trackRecording
readwrite

Whether GPS track recording is enabled.

When true, the recorder captures track points during flight and saves them as IGC files on landing. Default is true.

Definition at line 124 of file FlightLog.h.


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