#include "weather.h" #include #include #include #define WEATHER_COUNT 12 Weather::Weather(int region, QObject *parent) : QObject(parent) { setObjectName("Weather"); pRegion = region; pWeather = new CMabiWeather(region); } Weather::~Weather() { qDebug() << "destroyed: " << objectName() << "(region:" << pRegion << ")"; delete pWeather; } int Weather::region() const { return pRegion; } qreal Weather::weather(uint timespan) const { return pWeather->getWeather(timespan); } Weather::WeatherType Weather::weatherType(qreal weather) const { switch(pWeather->getType(weather)) { case CMabiWeather::EWT_STORM: return Storm; case CMabiWeather::EWT_RAIN: return Rain; case CMabiWeather::EWT_CLOUD: return Cloud; case CMabiWeather::EWT_CLEAR: return Clear; } return Clear; } qreal Weather::rainAmount(qreal weather) const { return pWeather->getRainAmount(weather); } /* * ³¯¾¾ ŸÀÔÀ» ¼ýÀÚÇüÀ¸·Î º¯È¯. * @param type ³¯¾¾ ŸÀÔ. (CMabiWeather.h) * @return ³¯¾¾ÀÇ ¼ýÀÚ °ª. */ int Weather::weatherTypeToInt(WeatherType weatherType) { switch(weatherType) { case Storm: return 3; case Rain: return 2; case Cloud: return 1; case Clear: return 0; } return -1; } /* * ³¯¾¾ ŸÀÔÀ» È­¸é¿¡ º¸¿© ÁÙ ¹®ÀÚ¿­·Î ¹ÝȯÇÑ´Ù. * @param type ³¯¾¾ ŸÀÔ. * @return È­¸é¿¡ º¸¿© ÁÙ ³¯¾¾ ¹®ÀÚ¿­. */ QString Weather::weatherTypeToString(WeatherType weatherType) { switch(weatherType) { case Storm: return QString::fromWCharArray(L"õµÕ"); break; case Rain: return QString::fromWCharArray(L"ºñ¿È"); break; case Cloud: return QString::fromWCharArray(L"È帲"); break; case Clear: return QString::fromWCharArray(L"¸¼À½"); break; default: return "INF"; } } /* * ³¯¾¾¸¦ ºñ±³ÇÑ´Ù. (õµÕ > ºñ > ±¸¸§ > ¸¼À½) * @param a ºñ±³ ´ë»óÀÇ ¿ÞÂÊ. * @param b ºñ±³ ´ë»óÀÇ ¿À¸¥ÂÊ. * @return a¿Í bÀÇ Â÷ÀÌ. */ int Weather::compareWeatherType(WeatherType a, WeatherType b) { return weatherTypeToInt(a) - weatherTypeToInt(b); }