1 | /* |
2 | * Copyright (C) 2012 Cutehacks AS. All rights reserved. |
3 | * info@cutehacks.com |
4 | * http://cutehacks.com |
5 | * |
6 | * This file is part of Fly. |
7 | * |
8 | * Fly is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
12 | * |
13 | * Fly is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with Fly. If not, see <http://www.gnu.org/licenses/>. |
20 | */ |
21 | |
22 | #ifndef FLIGHTSMODEL_H |
23 | #define FLIGHTSMODEL_H |
24 | |
25 | #include <QAbstractListModel> |
26 | #include <QStringList> |
27 | |
28 | #include "flighttimes.h" |
29 | |
30 | class Node; |
31 | class AirportNames; |
32 | class FlightStatuses; |
33 | class Settings; |
34 | |
35 | class FlightsModel : public QAbstractListModel |
36 | { |
37 | Q_OBJECT |
38 | Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged) |
39 | Q_PROPERTY(QString airportCode READ airportCode NOTIFY airportCodeChanged) |
40 | public: |
41 | FlightsModel(Settings *settings, |
42 | AirportNames *airports, |
43 | FlightStatuses *statuses, |
44 | FlightTimes *times, |
45 | QObject *parent = 0); |
46 | ~FlightsModel(); |
47 | |
48 | int rowCount(const QModelIndex &parent = QModelIndex()) const; |
49 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; |
50 | |
51 | bool isLoading() const; |
52 | QString airportCode() const; |
53 | |
54 | Q_SIGNALS: |
55 | void loadingChanged(); |
56 | void airportCodeChanged(); |
57 | |
58 | protected Q_SLOTS: |
59 | void reloadContents(); |
60 | void updateContents(Node *root); |
61 | |
62 | protected: |
63 | void appendFlightData(Node *flight); |
64 | |
65 | private: |
66 | Settings *m_settings; |
67 | AirportNames *m_airports; |
68 | FlightStatuses *m_statuses; |
69 | FlightTimes *m_times; |
70 | |
71 | struct FlightData { |
72 | int m_uniqueID; |
73 | QString m_airline; |
74 | QString m_flightID; |
75 | QString m_domesticOrInternational; |
76 | QDateTime m_scheduleTime; |
77 | QString m_arrivalOrDeparture; |
78 | QString m_airportCode; |
79 | QString m_airportName; |
80 | QStringList m_viaAirportCodes; |
81 | QStringList m_viaAirportNames; |
82 | QString m_routeAirportNames; |
83 | QString m_checkinArea; |
84 | QString m_gate; |
85 | QString m_statusCode; |
86 | QString m_statusText; |
87 | QDateTime m_statusTime; |
88 | QString m_beltNumber; |
89 | bool m_roundtrip; |
90 | QString m_scheduleText; |
91 | }; |
92 | QList<FlightData> m_flights; |
93 | }; |
94 | |
95 | #endif |
96 | |