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 FLIGHTSTATUSES_H |
23 | #define FLIGHTSTATUSES_H |
24 | |
25 | #include "xmldatasource.h" |
26 | #include <QHash> |
27 | |
28 | class FlightStatuses : public XmlDataSource |
29 | { |
30 | Q_OBJECT |
31 | Q_PROPERTY(StatusCode statusCode READ statusCode WRITE setStatusCode NOTIFY statusCodeChanged) |
32 | Q_PROPERTY(QString statusCodeString READ statusCodeString WRITE setStatusCodeString NOTIFY statusCodeChanged) |
33 | public: |
34 | |
35 | enum StatusCode { |
36 | None, |
37 | NewInfo, // "N" |
38 | NewTime, // "E" |
39 | Departed, // "D" |
40 | Arrived, // "A" |
41 | Canceled // "C" |
42 | }; |
43 | |
44 | FlightStatuses(QObject *parent = 0); |
45 | ~FlightStatuses(); |
46 | |
47 | StatusCode statusCode() const; |
48 | void setStatusCode(StatusCode code); |
49 | |
50 | QString statusCodeString() const; |
51 | void setStatusCodeString(const QString &code); |
52 | |
53 | Q_SIGNALS: |
54 | void statusCodeChanged(); |
55 | |
56 | public Q_SLOTS: |
57 | QString statusTextEnglish(const QString &code) const; |
58 | QString statusTextNorwegian(const QString &code) const; |
59 | |
60 | protected Q_SLOTS: |
61 | void createMapping(Node *root); |
62 | |
63 | protected: |
64 | static QString toString(StatusCode code); |
65 | static StatusCode fromString(const QString &code); |
66 | |
67 | private: |
68 | StatusCode m_statusCode; |
69 | QHash<QString, QString> m_mappingEnglish; |
70 | QHash<QString, QString> m_mappingNorwegian; |
71 | }; |
72 | |
73 | #endif |
74 | |