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 | // see http://www.avinor.no/avinor/trafikk/50_Flydata for documentation |
23 | |
24 | #include <QApplication> |
25 | #include <QDesktopWidget> |
26 | #include <QtDeclarative/QDeclarativeView> |
27 | #include <QtDeclarative/QDeclarativeEngine> |
28 | #include <QtDeclarative/QDeclarativeContext> |
29 | #include <qplatformdefs.h> |
30 | |
31 | #include "settings.h" |
32 | #include "airportnames.h" |
33 | #include "flightstatuses.h" |
34 | #include "flighttimes.h" |
35 | #include "flightsmodel.h" |
36 | |
37 | #include "receiver.h" |
38 | |
39 | int main(int argc, char *argv[]) |
40 | { |
41 | QApplication application(argc, argv); |
42 | application.setApplicationName(QString(QTOSTRING(TARGET)).remove('"')); |
43 | application.setApplicationVersion(QString(QTOSTRING(VERSION)).remove('"')); |
44 | application.setOrganizationDomain("cutehacks.com" ); |
45 | application.setOrganizationName("Cutehacks" ); |
46 | |
47 | QDeclarativeView view; |
48 | RequestQueueThread::setManager(view.engine()->networkAccessManager()); |
49 | |
50 | Settings settings; |
51 | AirportNames airportNames; |
52 | FlightStatuses flightStatuses; |
53 | FlightTimes arrivalTimes(FlightTimes::Arrivals); |
54 | FlightTimes departureTimes(FlightTimes::Departures); |
55 | FlightsModel arrivalsModel(&settings, &airportNames, &flightStatuses, &arrivalTimes); |
56 | FlightsModel departuresModel(&settings, &airportNames, &flightStatuses, &departureTimes); |
57 | |
58 | QDeclarativeContext *context = view.engine()->rootContext(); |
59 | context->setContextProperty("application" , &application); |
60 | context->setContextProperty("settings" , &settings); |
61 | context->setContextProperty("airportNames" , &airportNames); |
62 | context->setContextProperty("flightStatuses" , &flightStatuses); |
63 | context->setContextProperty("arrivalsModel" , &arrivalsModel); |
64 | context->setContextProperty("departuresModel" , &departuresModel); |
65 | |
66 | view.setResizeMode(QDeclarativeView::SizeRootObjectToView); |
67 | view.setAttribute(Qt::WA_NoSystemBackground); |
68 | |
69 | |
70 | #if defined(MEEGO_EDITION_HARMATTAN) |
71 | context->setContextProperty("nhdMode" , QVariant(false)); |
72 | context->setContextProperty("showTime" , QVariant(false)); |
73 | view.setSource(QUrl("qrc:/qml/MeeGoWindow.qml" )); |
74 | view.setGeometry(QApplication::desktop()->screenGeometry()); |
75 | view.showFullScreen(); |
76 | #elif defined(Q_OS_SYMBIAN) |
77 | context->setContextProperty("nhdMode" , QVariant(true)); |
78 | context->setContextProperty("showTime" , QVariant(true)); |
79 | view.setSource(QUrl("qrc:/qml/Main.qml" )); |
80 | view.showFullScreen(); |
81 | #else |
82 | context->setContextProperty("nhdMode" , QVariant(false)); |
83 | context->setContextProperty("showTime" , QVariant(false)); |
84 | view.setSource(QUrl("qrc:/qml/Main.qml" )); |
85 | view.resize(480, 700); |
86 | view.show(); |
87 | #endif |
88 | |
89 | QObject::connect(&airportNames, SIGNAL(dataUpdated(Node*)), &flightStatuses, SLOT(start())); |
90 | QObject::connect(&flightStatuses, SIGNAL(dataUpdated(Node*)), &arrivalTimes, SLOT(start())); |
91 | QObject::connect(&flightStatuses, SIGNAL(dataUpdated(Node*)), &departureTimes, SLOT(start())); |
92 | airportNames.start(); // start loading data |
93 | |
94 | return application.exec(); |
95 | } |
96 | |