summaryrefslogtreecommitdiffstats
path: root/weather
diff options
context:
space:
mode:
authorLuiz Agostini <luiz.agostini@openbossa.org>2009-10-31 18:16:45 -0300
committerLuiz Agostini <luiz.agostini@openbossa.org>2009-11-05 00:42:08 -0300
commit699ca328ed70776d6a8357de62784e3fff5447e6 (patch)
tree9184e72a1e628c36f3e7658755e704b869037749 /weather
parentf982f94721a4b6626a2ba243bc45513a77122e46 (diff)
Weather: Hung items are now using pixmaploader.
Signed-off-by: Luiz Agostini <luiz.agostini@openbossa.org>
Diffstat (limited to 'weather')
-rw-r--r--weather/bootmanager.cpp9
-rw-r--r--weather/forecasthungitem.cpp20
-rw-r--r--weather/forecasthungitem.h2
3 files changed, 27 insertions, 4 deletions
diff --git a/weather/bootmanager.cpp b/weather/bootmanager.cpp
index bc7a643..6b2d9ad 100644
--- a/weather/bootmanager.cpp
+++ b/weather/bootmanager.cpp
@@ -2,6 +2,7 @@
#include "settings.h"
#include "forecastprovider.h"
#include "pixmaploader.h"
+#include "forecasthungitem.h"
#include <QDebug>
@@ -19,7 +20,13 @@ void BootManager::run()
foreach (const QString & city, m_keys)
ForecastProvider::getForecast(city);
m_pendingResponses = m_keys.count();
- m_imagesLoaded = true;
+ PixmapLoader::connectToOnIdleSignal(this, SLOT(pixmapLoaderIsIdle()));
+ int count = ForecastHungItem::loadImages();
+
+
+ m_imagesLoaded = count == 0;
+ if (m_imagesLoaded)
+ PixmapLoader::disconnectReceiver(this);
}
void BootManager::forecastResponse(const ForecastData &forecast)
diff --git a/weather/forecasthungitem.cpp b/weather/forecasthungitem.cpp
index 9db2915..428b83c 100644
--- a/weather/forecasthungitem.cpp
+++ b/weather/forecasthungitem.cpp
@@ -31,6 +31,7 @@
#include "forecasthungitem.h"
#include "settings.h"
+#include "pixmaploader.h"
#include <QPropertyAnimation>
@@ -42,14 +43,16 @@ typedef struct
const qreal x;
const qreal y;
+ QString name() const { return prefix; }
+ QString lineName() const { return name() + LINE_NAME_SUFFIX; }
+
qreal scaledX() const { return Settings::scaleWidth(x); }
qreal scaledY() const { return Settings::scaleHeight(y); }
- QPixmap pic() const { return Settings::getScaledPic(name()); }
- QPixmap linePic() const { return Settings::getScaledPic(name() + LINE_NAME_SUFFIX); }
+ QPixmap pic() const { return PixmapLoader::getPic(name()); }
+ QPixmap linePic() const { return PixmapLoader::getPic(lineName()); }
private:
- QString name() const { return prefix; }
} HungObjectData;
@@ -90,6 +93,17 @@ ForecastHungItem::ForecastHungItem(ItemType type, QGraphicsItem *parent)
reset();
}
+int ForecastHungItem::loadImages()
+{
+ int result = 0;
+ for (int i = 0; i < ForecastHungItem::TypeCount; ++i) {
+ PixmapLoader::load(HungItemsData[i].name());
+ PixmapLoader::load(HungItemsData[i].lineName());
+ result += 2;
+ }
+ return result;
+}
+
qreal ForecastHungItem::lineLenght() const
{
return m_targetPicTop + HungItemsData[m_type].scaledY();
diff --git a/weather/forecasthungitem.h b/weather/forecasthungitem.h
index 1039a40..bb86552 100644
--- a/weather/forecasthungitem.h
+++ b/weather/forecasthungitem.h
@@ -60,6 +60,8 @@ public:
TypeCount
};
+ static int loadImages();
+
ForecastHungItem(ItemType type, QGraphicsItem *parent = 0);
QAbstractAnimation *getAnimation();