26#include <QObjectBindableProperty>
32#include "GlobalObject.h"
33#include "flightlog/Flight.h"
34#include "flightlog/FlightDetector.h"
35#include "geomaps/Waypoint.h"
37using namespace Qt::Literals::StringLiterals;
83 static FlightLog* create(QQmlEngine* , QJSEngine* )
95 [[nodiscard]]
auto flights() const -> QList<
Flight> {
return m_flights; }
103 [[nodiscard]] auto
count() const ->
int {
return static_cast<int>(m_flights.value().size()); }
129 void setTrackRecording(
bool enabled);
138 void setShowCurrentFlightTrace(
bool enabled);
210 const QString& departureICAO,
211 const QString& arrivalICAO,
213 const QString& offBlockTimeStr,
214 const QString& startTimeStr,
215 const QString& landingTimeStr,
216 const QString& onBlockTimeStr,
217 const QString& pilotName,
218 const QString& aircraftCallsign,
219 const QString& comments);
251 Q_INVOKABLE static GeoMaps::Waypoint
nearestAirfield(const QGeoCoordinate& position = {},
double proximityM = 5000.0);
261 [[nodiscard]] Q_INVOKABLE QByteArray
exportToIGC(
const QString& uuid)
const;
281 [[nodiscard]] Q_INVOKABLE QByteArray
exportToJSON(
const QStringList& uuids)
const;
356 void onPositionUpdated();
359 void onDetectionStateChanged();
362 void onAutoFlightDetectionChanged();
367 void onReceivingPositionInfoChanged(
bool receiving);
371 void onTakeoffDetected(
const QString& departureICAO,
372 const QGeoCoordinate& departureCoordinate,
373 const QDateTime& startTime,
374 const QString& aircraftCallsign);
377 void onLandingDetected(
const QString& arrivalICAO,
378 const QGeoCoordinate& arrivalCoordinate,
379 const QDateTime& landingTime,
393 void resolveCoordinates(
Flight& flight);
396 void sortFlights(QList<Flight>&
flights);
399 [[nodiscard]]
auto flightsForUuids(
const QStringList& uuids)
const -> QList<Flight>;
402 static auto parseDateTime(
const QString& date,
const QString& timeStr) -> QDateTime;
407 QUuid m_currentFlightUuid;
410 QString m_displayedTrackFile;
413 QGeoPath m_displayedTrackPath;
419 std::unique_ptr<FlightRecorder> m_recorder;
422 std::unique_ptr<FlightLogStorage> m_storage;
426 bool m_foregroundServiceRunning {
false};
Abstract base class for automatic flight detection strategies.
DetectionState
Detection state for automatic takeoff/landing detection.
SQLite-backed storage for the flight log.
Q_INVOKABLE QByteArray exportToForeFlight(const QStringList &uuids) const
Generate ForeFlight CSV content for selected flights.
void flightsChanged()
Notifier signal.
Flightlog::FlightDetector::DetectionState detectionState
Current state of the automatic detection state machine.
void displayedTrackPathChanged()
Notifier signal for displayedTrackPath and displayedTrackIndex.
void detectionStateChanged()
Notifier signal.
FlightLog(QObject *parent=nullptr)
Standard constructor.
Q_INVOKABLE QString importFromJSON(const QString &fileName)
Import flights from a JSON file.
void saveError(const QString &message)
Emitted when saving the flight log database fails.
Q_INVOKABLE QString lastArrivalICAO(const QString &aircraftCallsign) const
Find the last arrival ICAO for a given aircraft.
void takeoffDetected(const QString &time)
Emitted when a takeoff is detected.
Q_INVOKABLE QByteArray exportToJSON(const QStringList &uuids) const
Generate JSON content for selected flights.
int count
Number of recorded flights.
Q_INVOKABLE void showTrack(const QString &uuid)
Show a flight's track on the map.
static Q_INVOKABLE GeoMaps::Waypoint nearestAirfield(const QGeoCoordinate &position={}, double proximityM=5000.0)
Find the nearest airfield within 5 km.
Q_INVOKABLE void removeFlights(const QStringList &uuids)
Remove multiple flights from the log by UUID.
Q_INVOKABLE void hideTrack()
Hide the currently displayed track from the map.
bool showCurrentFlightTrace
Whether the live trace of the current flight is shown on map.
QString displayedTrackUuid
UUID of the flight whose track is displayed, or empty string if none.
Q_INVOKABLE void endFlight()
Manually end the current in-flight recording.
void trackRecordingChanged()
Notifier signal.
void deferredInitialization() override
Non-constructor initialization.
Q_INVOKABLE void clearFlights()
Remove all flights from the log.
void showCurrentFlightTraceChanged()
Notifier signal.
Q_INVOKABLE void removeTrack(const QString &uuid)
Delete the recorded track for a flight.
~FlightLog() override
Standard destructor.
bool trackRecording
Whether GPS track recording is enabled.
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.
QList< Flightlog::Flight > flights
List of all recorded flights, newest first.
Q_INVOKABLE void addFlight(const Flightlog::Flight &flight)
Add a new flight to the log.
Q_INVOKABLE void updateFlight(const QString &uuid, const Flightlog::Flight &flight)
Update an existing flight in the log.
void landingDetected(const QString &time)
Emitted when a landing is detected.
Q_INVOKABLE QByteArray exportToIGC(const QString &uuid) const
Get IGC track content for a flight.
Q_INVOKABLE void removeFlight(const QString &uuid)
Remove a flight from the log by UUID.
QGeoPath displayedTrackPath
Coordinates of the track currently displayed on the map.
GPS track recorder and IGC file manager.
A single flight log entry.
GlobalObject(QObject *parent=nullptr)
Standard constructor.
static Q_INVOKABLE Flightlog::FlightLog * flightLog()
Pointer to appplication-wide static FlightLog instance.