flightawarequery.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef FLIGHTAWAREQUERY_H
  2. #define FLIGHTAWAREQUERY_H
  3. #include <QNetworkAccessManager>
  4. #include "src/network/flightawareflightdata.h"
  5. #include "src/classes/settings.h"
  6. /*!
  7. * \brief The FlightAwareQuery class handles API requests to FlightAware
  8. * \details The FlightAware API allows retreiving most of the details required to log a flight.
  9. * Given a date and a flight number, which can either be an icao or iata flight id, most
  10. * base data can be auto-populated with only little user input required to complete a given flight.
  11. *
  12. * When the Flight Data is ready to be read (i.e. network request finished and data parsed), readyToRead()
  13. * is emitted and the parsed data can be retreived by calling flightList(). A list is used because some flights
  14. * are multi-sector flights that share a common flight number.
  15. */
  16. class FlightAwareQuery : public QObject
  17. {
  18. Q_OBJECT
  19. QNetworkAccessManager *m_networkManager;
  20. QNetworkReply* m_networkReply;
  21. const static inline QString QUERY_BASE_URL = QStringLiteral("https://aeroapi.flightaware.com/aeroapi/flights/");
  22. const QByteArray getApiKey() const { return Settings::getFlightAwareApiKey(); }
  23. public:
  24. explicit FlightAwareQuery(QObject *parent = nullptr);
  25. QList<FlightAwareFlightData> getFlightData(const QString &flightId, const QDate &date);
  26. // signals:
  27. // void readyToRead();
  28. private slots:
  29. // void replyFinished();
  30. void timeOut();
  31. };
  32. #endif // FLIGHTAWAREQUERY_H