blob: 09af5ba2951f3f37cf31ef56aad3e9401168e5c7 (
plain)
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
|
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: qt-info@nokia.com
**
** This software, including documentation, is protected by copyright
** controlled by Nokia Corporation. You may use this software in
** accordance with the terms and conditions contained in the Qt Phone
** Demo License Agreement.
**
****************************************************************************/
#include "bootmanager.h"
#include "settings.h"
#include "forecastprovider.h"
#include "pixmaploader.h"
#include "forecasthungitem.h"
#include "forecastrain.h"
#include "forecastsnow.h"
#include "forecaststars.h"
#include "cityinfodisplay.h"
#include "titlebar.h"
#include "citycarroussel.h"
#include "scrollbar.h"
#include "citylist.h"
#include "addcitytool.h"
#include <QDebug>
BootManager::BootManager(QObject *parent)
: QObject(parent)
, m_imagesLoaded(false)
{
}
void BootManager::run(const QStringList &locations)
{
m_keys = locations;
ForecastProvider::connectToResponseSignal(this, SLOT(forecastResponse(int, ForecastData)));
foreach (const QString & city, m_keys) {
m_requests.append(ForecastProvider::getForecast(city, true));
m_data.append(ForecastData());
}
PixmapLoader::connectToOnIdleSignal(this, SLOT(pixmapLoaderIsIdle()));
int count = ForecastHungItem::loadImages();
count += ForecastRain::loadImages();
count += ForecastSnow::loadImages();
count += ForecastStars::loadImages();
count += CityInfoDisplay::loadImages();
count += TitleBar::loadImages();
count += CityCarroussel::loadImages();
count += ScrollBar::loadImages();
count += CityList::loadImages();
count += AddCityTool::loadImages();
m_imagesLoaded = count == 0;
if (m_imagesLoaded)
PixmapLoader::disconnectReceiver(this);
}
void BootManager::forecastResponse(int reqId, const ForecastData &forecast)
{
if (m_requests.removeAll(reqId)) {
int idx = m_keys.indexOf(forecast.key());
if (idx >= 0)
m_data[idx] = forecast;
}
if (m_requests.isEmpty()) {
ForecastProvider::disconnectReceiver(this);
if (m_imagesLoaded)
emit ready();
}
}
void BootManager::pixmapLoaderIsIdle()
{
PixmapLoader::disconnectReceiver(this);
m_imagesLoaded = true;
if (m_requests.isEmpty())
emit ready();
}
|