24#include <QObjectBindableProperty>
26#include <QStandardPaths>
31#include "GlobalObject.h"
32#include "flightlog/Flight.h"
33#include "flightlog/FlightDetector.h"
34#include "flightlog/FlightRecorder.h"
35#include "geomaps/Waypoint.h"
37using namespace Qt::Literals::StringLiterals;
80 static FlightLog* create(QQmlEngine* , QJSEngine* )
92 [[nodiscard]]
auto flights() const -> QList<
Flight> {
return m_flights; }
100 [[nodiscard]] auto
count() const ->
int {
return static_cast<int>(m_flights.value().size()); }
126 void setTrackRecording(
bool enabled);
135 void setShowCurrentFlightTrace(
bool enabled);
204 const QString& departureICAO,
205 const QString& arrivalICAO,
207 const QString& offBlockTimeStr,
208 const QString& startTimeStr,
209 const QString& landingTimeStr,
210 const QString& onBlockTimeStr,
211 const QString& pilotName,
212 const QString& aircraftCallsign,
213 const QString& comments);
245 Q_INVOKABLE static GeoMaps::Waypoint
nearestAirfield(const QGeoCoordinate& position = {},
double proximityM = 5000.0);
255 [[nodiscard]] Q_INVOKABLE QByteArray
exportToIGC(
const QString& uuid)
const;
276 [[nodiscard]] Q_INVOKABLE QByteArray
exportToJSON(
const QStringList& uuids)
const;
338 void onPositionUpdated();
341 void onDetectionStateChanged();
344 void onAutoFlightDetectionChanged();
349 void onReceivingPositionInfoChanged(
bool receiving);
353 void onTakeoffDetected(
const QString& departureICAO,
354 const QGeoCoordinate& departureCoordinate,
355 const QDateTime& startTime,
356 const QString& aircraftCallsign);
359 void onLandingDetected(
const QString& arrivalICAO,
360 const QGeoCoordinate& arrivalCoordinate,
361 const QDateTime& landingTime,
378 void quarantineFlightLogFile(
const QString& reason);
381 void resolveCoordinates(
Flight& flight);
384 void sortFlights(QList<Flight>&
flights);
387 static auto flightsToJsonDocument(
const QList<Flight>&
flights) -> QJsonDocument;
390 [[nodiscard]]
auto flightsForUuids(
const QStringList& uuids)
const -> QList<Flight>;
393 static auto parseDateTime(
const QString& date,
const QString& timeStr) -> QDateTime;
398 QUuid m_currentFlightUuid;
401 QString m_displayedTrackFile;
404 QGeoPath m_displayedTrackPath;
414 bool m_foregroundServiceRunning {
false};
423 const QString m_fileName {QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + u
"/flightlog.json"_s};
Abstract base class for automatic flight detection strategies.
DetectionState
Detection state for automatic takeoff/landing detection.
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.
~FlightLog() override=default
Standard destructor.
void detectionStateChanged()
Notifier signal.
FlightLog(QObject *parent=nullptr)
Standard constructor.
void saveError(const QString &message)
Emitted when saving the flight log file 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.
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.