-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
95 lines (82 loc) · 3.65 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Copyright (C) 2012 Cutehacks AS. All rights reserved.
* http://cutehacks.com
*
* This file is part of Fly.
*
* Fly is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fly is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Fly. If not, see <http://www.gnu.org/licenses/>.
*/
// see http://www.avinor.no/avinor/trafikk/50_Flydata for documentation
#include <QApplication>
#include <QDesktopWidget>
#include <QtDeclarative/QDeclarativeView>
#include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/QDeclarativeContext>
#include <qplatformdefs.h>
#include "settings.h"
#include "airportnames.h"
#include "flightstatuses.h"
#include "flighttimes.h"
#include "flightsmodel.h"
#include "receiver.h"
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
application.setApplicationName(QString(QTOSTRING(TARGET)).remove('"'));
application.setApplicationVersion(QString(QTOSTRING(VERSION)).remove('"'));
application.setOrganizationDomain("cutehacks.com");
application.setOrganizationName("Cutehacks");
QDeclarativeView view;
RequestQueueThread::setManager(view.engine()->networkAccessManager());
Settings settings;
AirportNames airportNames;
FlightStatuses flightStatuses;
FlightTimes arrivalTimes(FlightTimes::Arrivals);
FlightTimes departureTimes(FlightTimes::Departures);
FlightsModel arrivalsModel(&settings, &airportNames, &flightStatuses, &arrivalTimes);
FlightsModel departuresModel(&settings, &airportNames, &flightStatuses, &departureTimes);
QDeclarativeContext *context = view.engine()->rootContext();
context->setContextProperty("application", &application);
context->setContextProperty("settings", &settings);
context->setContextProperty("airportNames", &airportNames);
context->setContextProperty("flightStatuses", &flightStatuses);
context->setContextProperty("arrivalsModel", &arrivalsModel);
context->setContextProperty("departuresModel", &departuresModel);
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
view.setAttribute(Qt::WA_NoSystemBackground);
#if defined(MEEGO_EDITION_HARMATTAN)
context->setContextProperty("nhdMode", QVariant(false));
context->setContextProperty("showTime", QVariant(false));
view.setSource(QUrl("qrc:/qml/MeeGoWindow.qml"));
view.setGeometry(QApplication::desktop()->screenGeometry());
view.showFullScreen();
#elif defined(Q_OS_SYMBIAN)
context->setContextProperty("nhdMode", QVariant(true));
context->setContextProperty("showTime", QVariant(true));
view.setSource(QUrl("qrc:/qml/Main.qml"));
view.showFullScreen();
#else
context->setContextProperty("nhdMode", QVariant(false));
context->setContextProperty("showTime", QVariant(false));
view.setSource(QUrl("qrc:/qml/Main.qml"));
view.resize(480, 700);
view.show();
#endif
QObject::connect(&airportNames, SIGNAL(dataUpdated(Node*)), &flightStatuses, SLOT(start()));
QObject::connect(&flightStatuses, SIGNAL(dataUpdated(Node*)), &arrivalTimes, SLOT(start()));
QObject::connect(&flightStatuses, SIGNAL(dataUpdated(Node*)), &departureTimes, SLOT(start()));
airportNames.start(); // start loading data
return application.exec();
}