diff options
Diffstat (limited to 'kweather/metar_parser.cpp')
-rw-r--r-- | kweather/metar_parser.cpp | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/kweather/metar_parser.cpp b/kweather/metar_parser.cpp index 7ec252d..9456095 100644 --- a/kweather/metar_parser.cpp +++ b/kweather/metar_parser.cpp @@ -58,6 +58,7 @@ void MetarParser::reset() { // Initialize the WeatherInfo structure weatherInfo.theWeather = TQString(); + weatherInfo.iconPath = TQString(); weatherInfo.clouds = 0; weatherInfo.windMPH = 0; weatherInfo.tempC = 0; @@ -258,7 +259,7 @@ bool MetarParser::parseCurrent(const TQString &s) if (sCode.contains("DZ")) { phenomena = i18n("Drizzle"); - weatherInfo.theWeather = iconName( WeatherIcon::LightRain, false ); + getIcon( WeatherIcon::LightRain, false ); } else if (sCode.contains("RA")) { @@ -273,32 +274,32 @@ bool MetarParser::parseCurrent(const TQString &s) else if (sCode.contains("SG")) { phenomena = i18n("Snow Grains"); - weatherInfo.theWeather = iconName( WeatherIcon::Snow, false, 4 ); + getIcon( WeatherIcon::Snow, false, 4 ); } else if (sCode.contains("IC")) { phenomena = i18n("Ice Crystals"); - weatherInfo.theWeather = iconName( WeatherIcon::Hail, false ); + getIcon( WeatherIcon::Hail, false ); } else if (sCode.contains("PE")) { phenomena = i18n("Ice Pellets"); - weatherInfo.theWeather = iconName( WeatherIcon::Hail, false ); + getIcon( WeatherIcon::Hail, false ); } else if (s.contains("GR")) { phenomena = i18n("Hail"); - weatherInfo.theWeather = iconName( WeatherIcon::Hail, false ); + getIcon( WeatherIcon::Hail, false ); } else if (sCode.contains("GS")) { phenomena = i18n("Small Hail Pellets"); - weatherInfo.theWeather = iconName( WeatherIcon::Hail, false ); + getIcon( WeatherIcon::Hail, false ); } else if (s.contains("UP")) { phenomena = i18n("Unknown Precipitation"); - weatherInfo.theWeather = iconName( WeatherIcon::Showers, isNight(weatherInfo.reportLocation), 1); + getIcon( WeatherIcon::Showers, isNight(weatherInfo.reportLocation), 1); } else if (sCode.contains("BR")) { @@ -727,17 +728,17 @@ void MetarParser::calcCurrentIcon() if (weatherInfo.theWeather.isEmpty()) { if (weatherInfo.clouds == 0) - weatherInfo.theWeather = iconName( WeatherIcon::Sunny, night ); + getIcon( WeatherIcon::Sunny, night ); else if (weatherInfo.clouds > 0 && weatherInfo.clouds <= 2) - weatherInfo.theWeather = iconName( WeatherIcon::Cloudy, night, 1 ); + getIcon( WeatherIcon::Cloudy, night, 1 ); else if ( weatherInfo.clouds > 2 && weatherInfo.clouds <= 4) - weatherInfo.theWeather = iconName( WeatherIcon::Cloudy, night, 2 ); + getIcon( WeatherIcon::Cloudy, night, 2 ); else if ( weatherInfo.clouds > 4 && weatherInfo.clouds <= 8) - weatherInfo.theWeather = iconName( WeatherIcon::Cloudy, night, 3 ); + getIcon( WeatherIcon::Cloudy, night, 3 ); else if ( weatherInfo.clouds > 8 && weatherInfo.clouds < 63) - weatherInfo.theWeather = iconName( WeatherIcon::Cloudy, night, 4 ); + getIcon( WeatherIcon::Cloudy, night, 4 ); else - weatherInfo.theWeather = iconName( WeatherIcon::Cloudy, night, 5 ); + getIcon( WeatherIcon::Cloudy, night, 5 ); } else if (weatherInfo.theWeather == "tstorm") { @@ -745,11 +746,11 @@ void MetarParser::calcCurrentIcon() weatherInfo.clouds = 30; if (weatherInfo.clouds >= 0 && weatherInfo.clouds <= 10) - weatherInfo.theWeather = iconName( WeatherIcon::Thunderstorm, night, 1 ); + getIcon( WeatherIcon::Thunderstorm, night, 1 ); else if ( weatherInfo.clouds > 10 && weatherInfo.clouds <= 20) - weatherInfo.theWeather = iconName( WeatherIcon::Thunderstorm, night, 2 ); + getIcon( WeatherIcon::Thunderstorm, night, 2 ); else - weatherInfo.theWeather = iconName( WeatherIcon::Thunderstorm, night, 3 ); + getIcon( WeatherIcon::Thunderstorm, night, 3 ); } else if (weatherInfo.theWeather == "shower") { @@ -757,11 +758,11 @@ void MetarParser::calcCurrentIcon() weatherInfo.clouds = 30; if (weatherInfo.clouds >= 0 && weatherInfo.clouds <= 10) - weatherInfo.theWeather = iconName( WeatherIcon::Showers, night, 1 ); + getIcon( WeatherIcon::Showers, night, 1 ); else if ( weatherInfo.clouds > 10 && weatherInfo.clouds <= 20) - weatherInfo.theWeather = iconName( WeatherIcon::Showers, night, 2 ); + getIcon( WeatherIcon::Showers, night, 2 ); else - weatherInfo.theWeather = iconName( WeatherIcon::Showers, night, 3 ); + getIcon( WeatherIcon::Showers, night, 3 ); } else if (weatherInfo.theWeather == "snow") { @@ -769,22 +770,22 @@ void MetarParser::calcCurrentIcon() weatherInfo.clouds = 30; if (weatherInfo.clouds >= 0 && weatherInfo.clouds <= 8) - weatherInfo.theWeather = iconName( WeatherIcon::Snow, night, 1 ); + getIcon( WeatherIcon::Snow, night, 1 ); else if ( weatherInfo.clouds > 8 && weatherInfo.clouds <= 16) - weatherInfo.theWeather = iconName( WeatherIcon::Snow, night, 2 ); + getIcon( WeatherIcon::Snow, night, 2 ); else if (weatherInfo.clouds > 16 && weatherInfo.clouds <= 24) - weatherInfo.theWeather = iconName( WeatherIcon::Snow, night, 3 ); + getIcon( WeatherIcon::Snow, night, 3 ); else - weatherInfo.theWeather = iconName( WeatherIcon::Snow, night, 5 ); + getIcon( WeatherIcon::Snow, night, 5 ); } else if ( weatherInfo.theWeather == "mist" || weatherInfo.theWeather == "fog" ) { if ( weatherInfo.clouds >= 63 ) - weatherInfo.theWeather = iconName( WeatherIcon::Cloudy, night, 5 ); + getIcon( WeatherIcon::Cloudy, night, 5 ); else if ( weatherInfo.theWeather == "mist" ) - weatherInfo.theWeather = iconName( WeatherIcon::Mist, night ); + getIcon( WeatherIcon::Mist, night ); else if ( weatherInfo.theWeather == "fog" ) - weatherInfo.theWeather = iconName( WeatherIcon::Fog, night ); + getIcon( WeatherIcon::Fog, night ); } kdDebug(12006) << "Clouds: " << weatherInfo.clouds << ", Icon: " @@ -860,23 +861,23 @@ bool MetarParser::isNight(const TQString &stationID) const } } -TQString MetarParser::iconName( int condition, bool night, int strength ) const +void MetarParser::getIcon( int condition, bool night, int strength ) { - TQString _iconName; if( strength != 0 ) { // Ranged WeatherIcon* wi = new WeatherIcon( condition, night, strength ); - _iconName = wi->name(); + weatherInfo.iconName = wi->name(); + weatherInfo.iconPath = wi->path(); delete wi; } else { // Simple WeatherIcon* wi = new WeatherIcon( condition, night ); - _iconName = wi->name(); + weatherInfo.iconName = wi->name(); + weatherInfo.iconPath = wi->path(); delete wi; } - return _iconName; } |