KWeather: improve icon loading and other fixes

- Fix pixelated icons (issue #19)
- Fix "network offline" state
- Add helper `bool weatherDataAvailable(TQString stationID)` DCOP function
- Fix compatibility with old DCOP function signatures
- Prevent double "Network is offline" strings in weather data.

This commit introduces some new and renamed DCOP calls. Old function signatures
are kept for compatibility, but are mraked as deprecated.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/22/head
Mavridis Philippe 1 year ago
parent 98f2adda02
commit bc71670331
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -29,6 +29,7 @@
#include <kdebug.h> #include <kdebug.h>
#include <tdeglobalsettings.h> #include <tdeglobalsettings.h>
#include <tdelocale.h> #include <tdelocale.h>
#include <kiconloader.h>
dockwidget::dockwidget(const TQString &location, TQWidget *parent, dockwidget::dockwidget(const TQString &location, TQWidget *parent,
const char *name) : TQWidget(parent,name), m_locationCode( location ), m_orientation(Qt::Horizontal ) const char *name) : TQWidget(parent,name), m_locationCode( location ), m_orientation(Qt::Horizontal )
@ -39,6 +40,7 @@ dockwidget::dockwidget(const TQString &location, TQWidget *parent,
connect(m_button, TQT_SIGNAL( clicked() ), TQT_SIGNAL( buttonClicked() )); connect(m_button, TQT_SIGNAL( clicked() ), TQT_SIGNAL( buttonClicked() ));
m_weatherService = new WeatherService_stub( "KWeatherService", "WeatherService" ); m_weatherService = new WeatherService_stub( "KWeatherService", "WeatherService" );
updateIcon();
} }
dockwidget::~dockwidget() dockwidget::~dockwidget()
@ -101,7 +103,7 @@ void dockwidget::showWeather()
m_weatherService->stationName( m_locationCode ) + " (" + m_weatherService->stationName( m_locationCode ) + " (" +
m_weatherService->stationCountry( m_locationCode ) + ")</nobr></center></h3>"; m_weatherService->stationCountry( m_locationCode ) + ")</nobr></center></h3>";
if ( m_weatherService->currentIconString( m_locationCode ) == "weather-none-available" ) // no data if ( !m_weatherService->weatherDataAvailable(m_locationCode) ) // no data
tip += "<center><nobr>" + i18n("The network is currently offline...") + "</nobr></center>"; tip += "<center><nobr>" + i18n("The network is currently offline...") + "</nobr></center>";
tip += TQString("<br><table>" tip += TQString("<br><table>"
@ -143,8 +145,7 @@ void dockwidget::showWeather()
tip += "</qt>"; tip += "</qt>";
// On null or empty location code, or if the station needs maintenance, this will return the dunno icon. updateIcon();
TQPixmap icon = m_weatherService->icon( m_locationCode );
TQToolTip::remove(this); TQToolTip::remove(this);
TQToolTip::add(this, tip); TQToolTip::add(this, tip);
@ -158,7 +159,6 @@ void dockwidget::showWeather()
m_lblWind->setText(wind); m_lblWind->setText(wind);
m_lblPres->setText(pressure); m_lblPres->setText(pressure);
m_button->setPixmap( icon );
} }
void dockwidget::initDock() void dockwidget::initDock()
@ -204,13 +204,13 @@ void dockwidget::resizeView( const TQSize &size )
kdDebug(12004) << "Changing to size " << size << endl; kdDebug(12004) << "Changing to size " << size << endl;
resize(size); resize(size);
if ( m_orientation ==Qt::Horizontal ) // Kicker in horizontal mode if ( m_orientation == TQt::Horizontal ) // Kicker in horizontal mode
{ {
int h = size.height(); int h = size.height();
if ( m_mode == ShowAll ) if ( m_mode == ShowAll )
{ {
if ( h <= 128 ) // left to right layout if ( h <= TDEIcon::SizeEnormous ) // left to right layout
{ {
static_cast<TQBoxLayout*>(layout())->setDirection(TQBoxLayout::LeftToRight); static_cast<TQBoxLayout*>(layout())->setDirection(TQBoxLayout::LeftToRight);
m_lblTemp->setAlignment(TQt::AlignAuto | TQt::AlignVCenter); m_lblTemp->setAlignment(TQt::AlignAuto | TQt::AlignVCenter);
@ -221,7 +221,7 @@ void dockwidget::resizeView( const TQSize &size )
{ {
static_cast<TQBoxLayout*>(layout())->setDirection(TQBoxLayout::TopToBottom); static_cast<TQBoxLayout*>(layout())->setDirection(TQBoxLayout::TopToBottom);
TQFontMetrics fm(m_font); TQFontMetrics fm(m_font);
h = 128 - (3 * fm.height()); // 3 lines of text below the button h = TDEIcon::SizeEnormous - (3 * fm.height()); // 3 lines of text below the button
m_lblTemp->setAlignment(TQt::AlignCenter); m_lblTemp->setAlignment(TQt::AlignCenter);
m_lblWind->setAlignment(TQt::AlignCenter); m_lblWind->setAlignment(TQt::AlignCenter);
m_lblPres->setAlignment(TQt::AlignCenter); m_lblPres->setAlignment(TQt::AlignCenter);
@ -239,14 +239,14 @@ void dockwidget::resizeView( const TQSize &size )
{ {
static_cast<TQBoxLayout*>(layout())->setDirection(TQBoxLayout::TopToBottom); static_cast<TQBoxLayout*>(layout())->setDirection(TQBoxLayout::TopToBottom);
TQFontMetrics fm(m_font); TQFontMetrics fm(m_font);
h = TQMIN(128, h) - fm.height(); h = TQMIN(TDEIcon::SizeEnormous, h) - fm.height();
m_lblTemp->setAlignment(TQt::AlignCenter); m_lblTemp->setAlignment(TQt::AlignCenter);
} }
m_button->setFixedSize(h, h); m_button->setFixedSize(h, h);
} }
else else
{ {
h = TQMIN(h, 128); h = TQMIN(h, TDEIcon::SizeEnormous);
m_button->setFixedSize(h, h); m_button->setFixedSize(h, h);
} }
} }
@ -257,7 +257,7 @@ void dockwidget::resizeView( const TQSize &size )
if ( m_mode == ShowAll ) if ( m_mode == ShowAll )
{ {
if ( w <= 128 ) // top to bottom if ( w <= TDEIcon::SizeEnormous ) // top to bottom
{ {
static_cast<TQBoxLayout*>(layout())->setDirection(TQBoxLayout::TopToBottom); static_cast<TQBoxLayout*>(layout())->setDirection(TQBoxLayout::TopToBottom);
m_lblTemp->setAlignment(TQt::AlignCenter); m_lblTemp->setAlignment(TQt::AlignCenter);
@ -279,7 +279,7 @@ void dockwidget::resizeView( const TQSize &size )
} }
else if ( m_mode == ShowTempOnly ) else if ( m_mode == ShowTempOnly )
{ {
if ( w <= 128 ) // top to bottom if ( w <= TDEIcon::SizeEnormous ) // top to bottom
{ {
static_cast<TQBoxLayout*>(layout())->setDirection(TQBoxLayout::TopToBottom); static_cast<TQBoxLayout*>(layout())->setDirection(TQBoxLayout::TopToBottom);
m_lblTemp->setAlignment(TQt::AlignCenter); m_lblTemp->setAlignment(TQt::AlignCenter);
@ -297,7 +297,7 @@ void dockwidget::resizeView( const TQSize &size )
} }
else else
{ {
w = TQMIN(w, 128); w = TQMIN(w, TDEIcon::SizeEnormous);
m_button->setFixedSize(w, w); m_button->setFixedSize(w, w);
} }
} }
@ -310,7 +310,7 @@ int dockwidget::widthForHeight(int h)
if ( m_mode == ShowAll ) if ( m_mode == ShowAll )
{ {
if ( h <= 128 ) // left to right layout if ( h <= TDEIcon::SizeEnormous ) // left to right layout
{ {
int pixelSize = h/3 - 3; int pixelSize = h/3 - 3;
pixelSize = TQMIN(pixelSize, fi.pixelSize()); // don't make it too large pixelSize = TQMIN(pixelSize, fi.pixelSize()); // don't make it too large
@ -330,7 +330,7 @@ int dockwidget::widthForHeight(int h)
} }
TQFontMetrics fm(m_font); TQFontMetrics fm(m_font);
// size of icon // size of icon
h = 128 - (3 * fm.height()); // 3 lines of text below the button h = TDEIcon::SizeEnormous - (3 * fm.height()); // 3 lines of text below the button
w = TQMAX(fm.width(m_lblWind->text()), fm.width(m_lblPres->text())) + 1; w = TQMAX(fm.width(m_lblWind->text()), fm.width(m_lblPres->text())) + 1;
w = TQMAX(h, w); // at least width of square icon w = TQMAX(h, w); // at least width of square icon
} }
@ -357,17 +357,18 @@ int dockwidget::widthForHeight(int h)
} }
TQFontMetrics fm(m_font); TQFontMetrics fm(m_font);
// size of icon // size of icon
h = TQMIN(128, h) - fm.height(); h = TQMIN(TDEIcon::SizeEnormous, h) - fm.height();
w = fm.width(m_lblTemp->text()) + 1; w = fm.width(m_lblTemp->text()) + 1;
w = TQMAX(h, w); // at least width of square icon w = TQMAX(h, w); // at least width of square icon
} }
} }
else else
{ {
w = TQMIN(128, h); // don't make it too large w = TQMIN(TDEIcon::SizeEnormous, h); // don't make it too large
} }
updateFont(); updateFont();
updateIcon();
return w + 4; return w + 4;
} }
@ -380,7 +381,7 @@ int dockwidget::heightForWidth( int w )
TQFontMetrics fmg(TDEGlobalSettings::generalFont()); TQFontMetrics fmg(TDEGlobalSettings::generalFont());
int maxWidth = fmg.width("888 km/h NNWW"); // a good approximation int maxWidth = fmg.width("888 km/h NNWW"); // a good approximation
if ( w <= 128 ) // top to bottom if ( w <= TDEIcon::SizeEnormous ) // top to bottom
{ {
if ( maxWidth <= w ) // enough space to use global font if ( maxWidth <= w ) // enough space to use global font
{ {
@ -415,7 +416,7 @@ int dockwidget::heightForWidth( int w )
TQFontMetrics fmg(TDEGlobalSettings::generalFont()); TQFontMetrics fmg(TDEGlobalSettings::generalFont());
int maxWidth = fmg.width("888.88 CC"); // a good approximation int maxWidth = fmg.width("888.88 CC"); // a good approximation
if ( w <= 128 ) // top to bottom if ( w <= TDEIcon::SizeEnormous ) // top to bottom
{ {
if ( maxWidth <= w ) // enough space to use global font if ( maxWidth <= w ) // enough space to use global font
{ {
@ -446,10 +447,11 @@ int dockwidget::heightForWidth( int w )
} }
else else
{ {
h = TQMIN(128, w); // don't make it too large h = TQMIN(TDEIcon::SizeEnormous, w); // don't make it too large
} }
updateFont(); updateFont();
updateIcon();
return h; return h;
} }
@ -462,4 +464,11 @@ void dockwidget::updateFont()
m_lblPres->setFont(m_font); m_lblPres->setFont(m_font);
} }
void dockwidget::updateIcon()
{
// On null or empty location code, or if the station needs maintenance, this will return the dunno icon.
TQPixmap icon = m_weatherService->icon( m_locationCode, m_button->height() );
m_button->setPixmap( icon );
}
#include "dockwidget.moc" #include "dockwidget.moc"

@ -56,6 +56,7 @@ signals: // Signals
private: private:
void initDock(); void initDock();
void updateFont(); void updateFont();
void updateIcon();
int m_mode; int m_mode;
TQString m_locationCode; TQString m_locationCode;
@ -65,7 +66,7 @@ private:
TQLabel *m_lblTemp; TQLabel *m_lblTemp;
TQLabel *m_lblWind; TQLabel *m_lblWind;
TQLabel *m_lblPres; TQLabel *m_lblPres;
Qt::Orientation m_orientation; TQt::Orientation m_orientation;
WeatherService_stub *m_weatherService; WeatherService_stub *m_weatherService;
}; };

@ -58,7 +58,6 @@ void MetarParser::reset()
{ {
// Initialize the WeatherInfo structure // Initialize the WeatherInfo structure
weatherInfo.theWeather = TQString(); weatherInfo.theWeather = TQString();
weatherInfo.iconPath = TQString();
weatherInfo.clouds = 0; weatherInfo.clouds = 0;
weatherInfo.windMPH = 0; weatherInfo.windMPH = 0;
weatherInfo.tempC = 0; weatherInfo.tempC = 0;
@ -78,6 +77,9 @@ void MetarParser::reset()
weatherInfo.qsHeatIndex = TQString(); weatherInfo.qsHeatIndex = TQString();
weatherInfo.qsWindDirection = TQString(); weatherInfo.qsWindDirection = TQString();
weatherInfo.stationNeedsMaintenance = false; weatherInfo.stationNeedsMaintenance = false;
weatherInfo.wiCondition = 0;
weatherInfo.wiStrength = 0;
weatherInfo.wiNight = false;
} }
struct WeatherInfo MetarParser::processData(const TQString &stationID, const TQString &metar) struct WeatherInfo MetarParser::processData(const TQString &stationID, const TQString &metar)
@ -259,7 +261,7 @@ bool MetarParser::parseCurrent(const TQString &s)
if (sCode.contains("DZ")) if (sCode.contains("DZ"))
{ {
phenomena = i18n("Drizzle"); phenomena = i18n("Drizzle");
saveIconNamePath( WeatherIcon::LightRain, false ); saveIconData( WeatherIcon::LightRain, false );
} }
else if (sCode.contains("RA")) else if (sCode.contains("RA"))
{ {
@ -274,32 +276,32 @@ bool MetarParser::parseCurrent(const TQString &s)
else if (sCode.contains("SG")) else if (sCode.contains("SG"))
{ {
phenomena = i18n("Snow Grains"); phenomena = i18n("Snow Grains");
saveIconNamePath( WeatherIcon::Snow, false, 4 ); saveIconData( WeatherIcon::Snow, false, 4 );
} }
else if (sCode.contains("IC")) else if (sCode.contains("IC"))
{ {
phenomena = i18n("Ice Crystals"); phenomena = i18n("Ice Crystals");
saveIconNamePath( WeatherIcon::Hail, false ); saveIconData( WeatherIcon::Hail, false );
} }
else if (sCode.contains("PE")) else if (sCode.contains("PE"))
{ {
phenomena = i18n("Ice Pellets"); phenomena = i18n("Ice Pellets");
saveIconNamePath( WeatherIcon::Hail, false ); saveIconData( WeatherIcon::Hail, false );
} }
else if (s.contains("GR")) else if (s.contains("GR"))
{ {
phenomena = i18n("Hail"); phenomena = i18n("Hail");
saveIconNamePath( WeatherIcon::Hail, false ); saveIconData( WeatherIcon::Hail, false );
} }
else if (sCode.contains("GS")) else if (sCode.contains("GS"))
{ {
phenomena = i18n("Small Hail Pellets"); phenomena = i18n("Small Hail Pellets");
saveIconNamePath( WeatherIcon::Hail, false ); saveIconData( WeatherIcon::Hail, false );
} }
else if (s.contains("UP")) else if (s.contains("UP"))
{ {
phenomena = i18n("Unknown Precipitation"); phenomena = i18n("Unknown Precipitation");
saveIconNamePath( WeatherIcon::Showers, isNight(weatherInfo.reportLocation), 1); saveIconData( WeatherIcon::Showers, isNight(weatherInfo.reportLocation), 1);
} }
else if (sCode.contains("BR")) else if (sCode.contains("BR"))
{ {
@ -728,17 +730,17 @@ void MetarParser::calcCurrentIcon()
if (weatherInfo.theWeather.isEmpty()) if (weatherInfo.theWeather.isEmpty())
{ {
if (weatherInfo.clouds == 0) if (weatherInfo.clouds == 0)
saveIconNamePath( WeatherIcon::Sunny, night ); saveIconData( WeatherIcon::Sunny, night );
else if (weatherInfo.clouds > 0 && weatherInfo.clouds <= 2) else if (weatherInfo.clouds > 0 && weatherInfo.clouds <= 2)
saveIconNamePath( WeatherIcon::Cloudy, night, 1 ); saveIconData( WeatherIcon::Cloudy, night, 1 );
else if ( weatherInfo.clouds > 2 && weatherInfo.clouds <= 4) else if ( weatherInfo.clouds > 2 && weatherInfo.clouds <= 4)
saveIconNamePath( WeatherIcon::Cloudy, night, 2 ); saveIconData( WeatherIcon::Cloudy, night, 2 );
else if ( weatherInfo.clouds > 4 && weatherInfo.clouds <= 8) else if ( weatherInfo.clouds > 4 && weatherInfo.clouds <= 8)
saveIconNamePath( WeatherIcon::Cloudy, night, 3 ); saveIconData( WeatherIcon::Cloudy, night, 3 );
else if ( weatherInfo.clouds > 8 && weatherInfo.clouds < 63) else if ( weatherInfo.clouds > 8 && weatherInfo.clouds < 63)
saveIconNamePath( WeatherIcon::Cloudy, night, 4 ); saveIconData( WeatherIcon::Cloudy, night, 4 );
else else
saveIconNamePath( WeatherIcon::Cloudy, night, 5 ); saveIconData( WeatherIcon::Cloudy, night, 5 );
} }
else if (weatherInfo.theWeather == "tstorm") else if (weatherInfo.theWeather == "tstorm")
{ {
@ -746,11 +748,11 @@ void MetarParser::calcCurrentIcon()
weatherInfo.clouds = 30; weatherInfo.clouds = 30;
if (weatherInfo.clouds >= 0 && weatherInfo.clouds <= 10) if (weatherInfo.clouds >= 0 && weatherInfo.clouds <= 10)
saveIconNamePath( WeatherIcon::Thunderstorm, night, 1 ); saveIconData( WeatherIcon::Thunderstorm, night, 1 );
else if ( weatherInfo.clouds > 10 && weatherInfo.clouds <= 20) else if ( weatherInfo.clouds > 10 && weatherInfo.clouds <= 20)
saveIconNamePath( WeatherIcon::Thunderstorm, night, 2 ); saveIconData( WeatherIcon::Thunderstorm, night, 2 );
else else
saveIconNamePath( WeatherIcon::Thunderstorm, night, 3 ); saveIconData( WeatherIcon::Thunderstorm, night, 3 );
} }
else if (weatherInfo.theWeather == "shower") else if (weatherInfo.theWeather == "shower")
{ {
@ -758,11 +760,11 @@ void MetarParser::calcCurrentIcon()
weatherInfo.clouds = 30; weatherInfo.clouds = 30;
if (weatherInfo.clouds >= 0 && weatherInfo.clouds <= 10) if (weatherInfo.clouds >= 0 && weatherInfo.clouds <= 10)
saveIconNamePath( WeatherIcon::Showers, night, 1 ); saveIconData( WeatherIcon::Showers, night, 1 );
else if ( weatherInfo.clouds > 10 && weatherInfo.clouds <= 20) else if ( weatherInfo.clouds > 10 && weatherInfo.clouds <= 20)
saveIconNamePath( WeatherIcon::Showers, night, 2 ); saveIconData( WeatherIcon::Showers, night, 2 );
else else
saveIconNamePath( WeatherIcon::Showers, night, 3 ); saveIconData( WeatherIcon::Showers, night, 3 );
} }
else if (weatherInfo.theWeather == "snow") else if (weatherInfo.theWeather == "snow")
{ {
@ -770,22 +772,22 @@ void MetarParser::calcCurrentIcon()
weatherInfo.clouds = 30; weatherInfo.clouds = 30;
if (weatherInfo.clouds >= 0 && weatherInfo.clouds <= 8) if (weatherInfo.clouds >= 0 && weatherInfo.clouds <= 8)
saveIconNamePath( WeatherIcon::Snow, night, 1 ); saveIconData( WeatherIcon::Snow, night, 1 );
else if ( weatherInfo.clouds > 8 && weatherInfo.clouds <= 16) else if ( weatherInfo.clouds > 8 && weatherInfo.clouds <= 16)
saveIconNamePath( WeatherIcon::Snow, night, 2 ); saveIconData( WeatherIcon::Snow, night, 2 );
else if (weatherInfo.clouds > 16 && weatherInfo.clouds <= 24) else if (weatherInfo.clouds > 16 && weatherInfo.clouds <= 24)
saveIconNamePath( WeatherIcon::Snow, night, 3 ); saveIconData( WeatherIcon::Snow, night, 3 );
else else
saveIconNamePath( WeatherIcon::Snow, night, 5 ); saveIconData( WeatherIcon::Snow, night, 5 );
} }
else if ( weatherInfo.theWeather == "mist" || weatherInfo.theWeather == "fog" ) else if ( weatherInfo.theWeather == "mist" || weatherInfo.theWeather == "fog" )
{ {
if ( weatherInfo.clouds >= 63 ) if ( weatherInfo.clouds >= 63 )
saveIconNamePath( WeatherIcon::Cloudy, night, 5 ); saveIconData( WeatherIcon::Cloudy, night, 5 );
else if ( weatherInfo.theWeather == "mist" ) else if ( weatherInfo.theWeather == "mist" )
saveIconNamePath( WeatherIcon::Mist, night ); saveIconData( WeatherIcon::Mist, night );
else if ( weatherInfo.theWeather == "fog" ) else if ( weatherInfo.theWeather == "fog" )
saveIconNamePath( WeatherIcon::Fog, night ); saveIconData( WeatherIcon::Fog, night );
} }
kdDebug(12006) << "Clouds: " << weatherInfo.clouds << ", Icon: " kdDebug(12006) << "Clouds: " << weatherInfo.clouds << ", Icon: "
@ -861,23 +863,10 @@ bool MetarParser::isNight(const TQString &stationID) const
} }
} }
void MetarParser::saveIconNamePath( int condition, bool night, int strength ) void MetarParser::saveIconData( int condition, bool night, int strength )
{ {
if( strength != 0 ) weatherInfo.wiCondition = condition;
{ weatherInfo.wiStrength = strength;
// Ranged weatherInfo.wiNight = night;
WeatherIcon* wi = new WeatherIcon( condition, night, strength );
weatherInfo.iconName = wi->name();
weatherInfo.iconPath = wi->path();
delete wi;
}
else
{
// Simple
WeatherIcon* wi = new WeatherIcon( condition, night );
weatherInfo.iconName = wi->name();
weatherInfo.iconPath = wi->path();
delete wi;
}
} }

@ -32,8 +32,6 @@ struct WeatherInfo
{ {
/** The current weather state outside */ /** The current weather state outside */
TQString theWeather; TQString theWeather;
TQString iconName;
TQString iconPath;
int clouds; int clouds;
float windMPH; float windMPH;
float tempC; float tempC;
@ -54,6 +52,11 @@ struct WeatherInfo
TQString qsWindDirection; TQString qsWindDirection;
TQString reportLocation; TQString reportLocation;
bool stationNeedsMaintenance; bool stationNeedsMaintenance;
/* For WeatherIcon */
int wiCondition;
int wiStrength;
bool wiNight;
}; };
@ -94,7 +97,7 @@ class MetarParser
void calcCurrentIcon(); void calcCurrentIcon();
void calcWindChill(); void calcWindChill();
bool isNight(const TQString &stationID) const; bool isNight(const TQString &stationID) const;
void saveIconNamePath( int condition, bool night, int strength = 0 ); void saveIconData( int condition, bool night, int strength = 0 );
/* /*
* Reset the internal WeatherInfo struct of the class so that * Reset the internal WeatherInfo struct of the class so that

@ -22,6 +22,7 @@
#include <tdehtml_part.h> #include <tdehtml_part.h>
#include <tdehtmlview.h> #include <tdehtmlview.h>
#include <tdeglobalsettings.h> #include <tdeglobalsettings.h>
#include <kiconloader.h>
#include <tqvbox.h> #include <tqvbox.h>
#include <tqpixmap.h> #include <tqpixmap.h>
@ -46,7 +47,7 @@ reportView::reportView(const TQString &reportLocation)
m_weatherService = new WeatherService_stub( "KWeatherService", "WeatherService" ); m_weatherService = new WeatherService_stub( "KWeatherService", "WeatherService" );
TQPixmap icon = m_weatherService->icon( m_locationCode ); TQPixmap icon = m_weatherService->icon( m_locationCode, IconSize(TDEIcon::Panel) );
setIcon( icon ); setIcon( icon );
render(); render();
@ -89,7 +90,7 @@ void reportView::render(){
TQString sunRiseTime = m_weatherService->sunRiseTime(m_locationCode ); TQString sunRiseTime = m_weatherService->sunRiseTime(m_locationCode );
TQString sunSetTime = m_weatherService->sunSetTime(m_locationCode ); TQString sunSetTime = m_weatherService->sunSetTime(m_locationCode );
TQString date = m_weatherService->date(m_locationCode ); TQString date = m_weatherService->date(m_locationCode );
TQString icon = m_weatherService->iconFileName(m_locationCode ); TQString icon = m_weatherService->iconPath(m_locationCode, IconSize(TDEIcon::Panel));
TQStringList cover = m_weatherService->cover(m_locationCode ); TQStringList cover = m_weatherService->cover(m_locationCode );
TQStringList weather = m_weatherService->weather(m_locationCode ); TQStringList weather = m_weatherService->weather(m_locationCode );

@ -30,6 +30,7 @@
#include <tdelocale.h> #include <tdelocale.h>
#include <kpushbutton.h> #include <kpushbutton.h>
#include <kstandarddirs.h> #include <kstandarddirs.h>
#include <kiconloader.h>
#include "stationsconfigwidget.h" #include "stationsconfigwidget.h"
#include "weatherservice_stub.h" #include "weatherservice_stub.h"
@ -129,10 +130,7 @@ void StationsConfigWidget::scanStations()
mSelectedStations->clear(); mSelectedStations->clear();
for ( uint i = 0; i < list.count(); ++i ) { for ( uint i = 0; i < list.count(); ++i ) {
TQPixmap pm = mService->icon( list[ i ] ); TQPixmap pm = mService->icon( list[ i ], TDEIcon::SizeSmall );
TQImage img = pm.convertToImage();
img = img.smoothScale( 22, 22 );
pm.convertFromImage( img );
TQString uid = list[ i ]; TQString uid = list[ i ];
if (mStationMap[ uid ].isEmpty()) if (mStationMap[ uid ].isEmpty())

@ -36,59 +36,67 @@ bool WeatherIconPrivate::usingIconTheme()
return m_useIconTheme; return m_useIconTheme;
} }
TQPair<TQString,TQString> WeatherIconPrivate::findIcon( TQStringList fallback ) /** Returns the name of the best matching icon, either from the icon theme or the KWeather icons */
struct WeatherSingleIconData WeatherIconPrivate::findIcon(TQStringList fallback, uint size)
{ {
struct WeatherSingleIconData iconData;
kdDebug(12006) << "[findIcon] Use icon theme? " << m_useIconTheme << endl; kdDebug(12006) << "[findIcon] Use icon theme? " << m_useIconTheme << endl;
if( m_useIconTheme ) if (m_useIconTheme)
{ {
// Check in theme // Check in theme
for ( TQStringList::Iterator icon = fallback.begin(); icon != fallback.end(); ++icon ) for (TQStringList::Iterator icon = fallback.begin(); icon != fallback.end(); ++icon)
{ {
kdDebug(12006) << "[findIcon] Searching for `" << *icon << "` in theme" << endl; kdDebug(12006) << "[findIcon] Searching for `" << *icon << "` in theme" << endl;
TQString iPath = iconPath(*icon, true); TQString iPath = iconPath(*icon, size, true);
if( !( iPath.isNull() ) ) if (!iPath.isNull())
{ {
kdDebug(12006) << "[findIcon] Found `" << *icon << "` in theme: " << iPath << endl; kdDebug(12006) << "[findIcon] Found `" << *icon << "` in theme: " << iPath << endl;
return qMakePair(*icon, iPath); iconData = { *icon, iPath, true, size };
return iconData;
} }
} }
} }
// Check in kweather fallback // Check in kweather fallback
for ( TQStringList::Iterator icon = fallback.begin(); icon != fallback.end(); ++icon ) for (TQStringList::Iterator icon = fallback.begin(); icon != fallback.end(); ++icon)
{ {
kdDebug(12006) << "[findIcon] Searching for `" << *icon << "` in kweather icons" << endl; kdDebug(12006) << "[findIcon] Searching for `" << *icon << "` in kweather icons" << endl;
TQString iPath = iconPath(*icon, false); TQString iPath = iconPath(*icon, size, false);
if( !( iPath.isNull() ) ) if (!iPath.isEmpty())
{ {
kdDebug(12006) << "[findIcon] Found `" << *icon << "` in kweather icons: " << iPath << endl; kdDebug(12006) << "[findIcon] Found `" << *icon << "` in kweather icons: " << iPath << endl;
return qMakePair(*icon, iPath); iconData = { *icon, iPath, false, size };
return iconData;
} }
} }
return qMakePair(WeatherIcon::unknown(), iconPath(WeatherIcon::unknown()));
return WeatherIcon::unknown(size);
} }
TQString WeatherIconPrivate::iconPath( TQString icon, bool inTheme ) TQString WeatherIconPrivate::iconPath( TQString icon, uint size, bool inTheme )
{ {
if( inTheme ) TQString path = TQString::null;
{ if (inTheme) {
return iconLoader->iconPath(icon, TDEIcon::Desktop, true); path = iconLoader->iconPath(icon, size, true);
if (path.isEmpty()) {
// maybe there is a scalable icon?
path = iconLoader->iconPath(icon, 0, true);
} }
else
{
return locate( "data", "kweather/" + icon + ".png" );
} }
else {
path = locate( "data", "kweather/" + icon + ".png" );
}
return path;
} }
TQString WeatherIconPrivate::iconPath( TQString icon ) TQString WeatherIconPrivate::iconPath( TQString icon, uint size )
{ {
return iconPath(icon, m_useIconTheme); return iconPath(icon, size, m_useIconTheme);
} }
WeatherIcon::WeatherIcon( int condition, bool night ) WeatherIcon::WeatherIcon( int condition, bool night )
{ {
TQStringList fallback;
switch( condition ) switch( condition )
{ {
case Sunny: case Sunny:
@ -98,7 +106,6 @@ WeatherIcon::WeatherIcon( int condition, bool night )
fallback << "weather-clear-night"; //xdg, kweather fallback << "weather-clear-night"; //xdg, kweather
} }
fallback << "weather-clear"; // xdg, kweather fallback << "weather-clear"; // xdg, kweather
break; break;
} }
@ -109,7 +116,6 @@ WeatherIcon::WeatherIcon( int condition, bool night )
fallback << "weather-fog-night"; // themes, kweather fallback << "weather-fog-night"; // themes, kweather
} }
fallback << "weather-fog"; // xdg, kweather fallback << "weather-fog"; // xdg, kweather
break; break;
} }
@ -126,14 +132,12 @@ WeatherIcon::WeatherIcon( int condition, bool night )
fallback << "weather-fog-night"; // themes, kweather fallback << "weather-fog-night"; // themes, kweather
} }
fallback << "weather-fog"; // xdg, kweather fallback << "weather-fog"; // xdg, kweather
break; break;
} }
case Overcast: case Overcast:
{ {
fallback << "weather-overcast"; // xdg, kweather fallback << "weather-overcast"; // xdg, kweather
break; break;
} }
@ -142,14 +146,12 @@ WeatherIcon::WeatherIcon( int condition, bool night )
fallback << "weather-hail"; // themes fallback << "weather-hail"; // themes
fallback << "weather-freezing-rain"; // themes, kweather fallback << "weather-freezing-rain"; // themes, kweather
fallback << "weather-snow"; // xdg, kweather fallback << "weather-snow"; // xdg, kweather
break; break;
} }
case LightRain: case LightRain:
{ {
fallback << "weather-showers-scattered"; // xdg, kweather fallback << "weather-showers-scattered"; // xdg, kweather
break; break;
} }
@ -157,21 +159,13 @@ WeatherIcon::WeatherIcon( int condition, bool night )
{ {
fallback << "weather-snow-rain"; // themes, kweather fallback << "weather-snow-rain"; // themes, kweather
fallback << "weather-snow"; // xdg, kweather fallback << "weather-snow"; // xdg, kweather
break; break;
} }
} }
TQPair<TQString,TQString> foundIcon = WeatherIconPrivate::instance()->findIcon(fallback);
iconName = foundIcon.first;
iconPath = foundIcon.second;
return;
} }
WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength ) WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
{ {
TQStringList fallback;
switch ( condition ) switch ( condition )
{ {
case Cloudy: case Cloudy:
@ -185,7 +179,6 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
fallback << "weather-few-clouds-night"; // xdg, kweather fallback << "weather-few-clouds-night"; // xdg, kweather
} }
fallback << "weather-few-clouds"; // xdg, kweather fallback << "weather-few-clouds"; // xdg, kweather
break; break;
} }
@ -202,7 +195,6 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
fallback << "weather-few-clouds-night"; // xdg, kweather fallback << "weather-few-clouds-night"; // xdg, kweather
} }
fallback << "weather-few-clouds"; // xdg, kweather fallback << "weather-few-clouds"; // xdg, kweather
break; break;
} }
@ -218,7 +210,6 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
fallback << "weather-few-clouds-night"; // xdg, kweather fallback << "weather-few-clouds-night"; // xdg, kweather
} }
fallback << "weather-few-clouds"; // xdg, kweather fallback << "weather-few-clouds"; // xdg, kweather
break; break;
} }
@ -229,30 +220,23 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
fallback << "weather-ample-clouds-night"; // kweather fallback << "weather-ample-clouds-night"; // kweather
} }
fallback << "weather-ample-clouds"; // kweather fallback << "weather-ample-clouds"; // kweather
fallback << "weather-many-clouds"; // themes, kweather fallback << "weather-many-clouds"; // themes, kweather
fallback << "weather-overcast"; // xdg, kweather fallback << "weather-overcast"; // xdg, kweather
break; break;
} }
case 5: { case 5: {
fallback << "weather-many-clouds"; // themes, kweather fallback << "weather-many-clouds"; // themes, kweather
fallback << "weather-overcast"; // xdg, kweather fallback << "weather-overcast"; // xdg, kweather
break; break;
} }
default: { default: {
fallback << "weather-clouds"; // themes, kweather fallback << "weather-clouds"; // themes, kweather
fallback << "weather-few-clouds"; // xdg, kweather fallback << "weather-few-clouds"; // xdg, kweather
break; break;
} }
} }
break; break;
} }
@ -270,9 +254,7 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
{ {
fallback << "weather-showers-scattered-day"; // themes, kweather fallback << "weather-showers-scattered-day"; // themes, kweather
} }
fallback << "weather-showers-scattered"; // xdg, kweather fallback << "weather-showers-scattered"; // xdg, kweather
break; break;
} }
@ -286,9 +268,7 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
{ {
fallback << "weather-showers-day"; // themes, kweather fallback << "weather-showers-day"; // themes, kweather
} }
fallback << "weather-showers"; // xdg, kweather fallback << "weather-showers"; // xdg, kweather
break; break;
} }
@ -296,7 +276,6 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
default: default:
{ {
fallback << "weather-showers"; // xdg, kweather fallback << "weather-showers"; // xdg, kweather
break; break;
} }
} }
@ -320,9 +299,7 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
} }
fallback << "weather-snow-scattered"; // xdg, kweather fallback << "weather-snow-scattered"; // xdg, kweather
fallback << "weather-snow"; // workaround for some themes fallback << "weather-snow"; // workaround for some themes
break; break;
} }
case 2: case 2:
@ -348,9 +325,7 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
} }
fallback << "weather-snow-scattered"; // xdg, kweather fallback << "weather-snow-scattered"; // xdg, kweather
fallback << "weather-snow"; // workaround for some themes fallback << "weather-snow"; // workaround for some themes
break; break;
} }
@ -364,21 +339,15 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
{ {
fallback << "weather-snow-ample-day"; // kweather fallback << "weather-snow-ample-day"; // kweather
} }
fallback << "weather-snow-ample"; // kweather fallback << "weather-snow-ample"; // kweather
fallback << "weather-snow"; // xdg, kweather fallback << "weather-snow"; // xdg, kweather
break; break;
} }
case 4: case 4:
{ {
fallback << "weather-snow-scattered"; // xdg, kweather fallback << "weather-snow-scattered"; // xdg, kweather
fallback << "weather-snow"; // workaround for some themes fallback << "weather-snow"; // workaround for some themes
break; break;
} }
@ -386,7 +355,6 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
default: default:
{ {
fallback << "weather-snow"; // xdg, kweather fallback << "weather-snow"; // xdg, kweather
break; break;
} }
} }
@ -408,7 +376,6 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
fallback << "weather-storm-day"; // themes, kweather fallback << "weather-storm-day"; // themes, kweather
} }
fallback << "weather-storm"; // xdg, kweather fallback << "weather-storm"; // xdg, kweather
break; break;
} }
@ -433,28 +400,44 @@ WeatherIcon::WeatherIcon( int condition, bool night, unsigned int strength )
fallback << "weather-storm-day"; // themes, kweather fallback << "weather-storm-day"; // themes, kweather
} }
fallback << "weather-storm"; // xdg, kweather fallback << "weather-storm"; // xdg, kweather
break; break;
} }
case 3: case 3:
default: default:
{ {
fallback << "weather-storm"; // xdg, kweather fallback << "weather-storm"; // xdg, kweather
break; break;
} }
} }
break; break;
} }
}
TQPair<TQString,TQString> foundIcon = WeatherIconPrivate::instance()->findIcon(fallback); // Unknown weather conditions
iconName = foundIcon.first; WeatherIcon::WeatherIcon() {
iconPath = foundIcon.second; fallback << "weather-none-available";
return;
} }
WeatherIcon::~WeatherIcon() WeatherIcon::~WeatherIcon()
{ {
iconName = TQString::null; }
struct WeatherSingleIconData WeatherIcon::iconData(uint size) {
return WeatherIconPrivate::instance()->findIcon(fallback, size);
}
struct WeatherSingleIconData WeatherIcon::unknown(uint size) {
WeatherIcon *unknown = new WeatherIcon();
struct WeatherSingleIconData unknownData = unknown->iconData(size);
delete unknown;
return unknownData;
}
// convenience functions
TQString WeatherIcon::name(uint size) {
return iconData(size).name;
}
TQString WeatherIcon::path(uint size) {
return iconData(size).path;
} }

@ -1,4 +1,11 @@
class TDEIconLoader; #include <kiconloader.h>
struct WeatherSingleIconData {
TQString name;
TQString path;
bool inTheme;
uint size;
};
class WeatherIconPrivate { class WeatherIconPrivate {
friend class WeatherIcon; friend class WeatherIcon;
@ -9,18 +16,18 @@ class WeatherIconPrivate {
static WeatherIconPrivate* instance(); static WeatherIconPrivate* instance();
void useIconTheme( bool use ); void useIconTheme(bool use);
bool usingIconTheme(); bool usingIconTheme();
TQString iconPath( TQString icon, bool inTheme ); TQString iconPath(TQString icon, uint size, bool inTheme);
TQString iconPath( TQString icon ); TQString iconPath(TQString icon, uint size);
private: private:
static WeatherIconPrivate* s_instance; static WeatherIconPrivate* s_instance;
TDEIconLoader* iconLoader; TDEIconLoader* iconLoader;
bool m_useIconTheme; bool m_useIconTheme;
TQPair<TQString,TQString> findIcon( TQStringList fallback ); struct WeatherSingleIconData findIcon(TQStringList fallback, uint size);
}; };
class WeatherIcon { class WeatherIcon {
@ -30,13 +37,15 @@ class WeatherIcon {
WeatherIcon( int condition /* SimpleCondition */, bool night ); WeatherIcon( int condition /* SimpleCondition */, bool night );
WeatherIcon( int condition /* RangedCondition */, bool night, unsigned int strength ); WeatherIcon( int condition /* RangedCondition */, bool night, unsigned int strength );
WeatherIcon(); /* Unknown conditions */
~WeatherIcon(); ~WeatherIcon();
static TQString unknown() { return "weather-none-available"; }; static struct WeatherSingleIconData unknown(uint size); // for convenience
TQString name() { return iconName; }
TQString path() { return iconPath; } struct WeatherSingleIconData iconData(uint size);
TQString name(uint size);
TQString path(uint size);
private: private:
TQString iconName; TQStringList fallback;
TQString iconPath;
}; };

@ -185,8 +185,12 @@ void WeatherLib::slotCopyDone(TDEIO::Job* job)
kdDebug( 12006 ) << "Offline now..." << endl; kdDebug( 12006 ) << "Offline now..." << endl;
d->clear(); d->clear();
d->wi.theWeather = "dunno"; d->wi.theWeather = "dunno";
d->wi.qsCurrentList.append(i18n("The network is currently offline..."));
TQString offlineStr = i18n("The network is currently offline...");
if (!d->wi.qsCurrentList.contains(offlineStr)) {
d->wi.qsCurrentList.append(offlineStr);
d->wi.qsCurrentList.append(i18n("Please update later.")); d->wi.qsCurrentList.append(i18n("Please update later."));
}
emit fileUpdate(d->wi.reportLocation); emit fileUpdate(d->wi.reportLocation);
} }
else else
@ -277,51 +281,68 @@ TQString WeatherLib::windChill(const TQString &stationID){
return d->wi.qsWindChill; return d->wi.qsWindChill;
} }
TQString WeatherLib::iconName(const TQString &stationID){ TQString WeatherLib::iconName(const TQString &stationID, uint iconSize) {
TQString result = TQString::null;
TQString result; if (!stationID.isEmpty()) {
WeatherIcon *wi = weatherIcon(stationID);
// isEmpty is true for null or 0 length strings result = wi->name(iconSize);
if ( !stationID.isEmpty() ) delete wi;
{
Data *d = findData(stationID);
result = d->wi.iconName;
} }
if( result == TQString::null ) if (result.isEmpty())
result = WeatherIcon::unknown(); result = WeatherIcon::unknown(iconSize).name;
return result; return result;
} }
TQString WeatherLib::iconPath(const TQString &stationID){ TQString WeatherLib::iconName(const TQString &stationID) {
return iconName(stationID, IconSize(TDEIcon::Panel));
}
TQString result; TQString WeatherLib::iconPath(const TQString &stationID, uint iconSize) {
TQString result = TQString::null;
if (!stationID.isEmpty()) {
WeatherIcon *wi = weatherIcon(stationID);
result = wi->path(iconSize);
delete wi;
}
// isEmpty is true for null or 0 length strings if (result.isEmpty())
if ( !stationID.isEmpty() ) result = WeatherIcon::unknown(iconSize).path;
{
return result;
}
/** Returns a WeatherIcon object for the current weather conditions */
WeatherIcon* WeatherLib::weatherIcon(const TQString &stationID) {
Data *d = findData(stationID); Data *d = findData(stationID);
result = d->wi.iconPath; if (d->wi.theWeather == "dunno")
{
return new WeatherIcon();
} }
if( result == TQString::null ) int condition = d->wi.wiCondition;
result = WeatherIconPrivate::instance()->iconPath(WeatherIcon::unknown()); int strength = d->wi.wiStrength;
bool night = d->wi.wiNight;
return result; WeatherIcon* wi;
if (d->wi.wiStrength != 0) // Ranged condition
wi = new WeatherIcon(condition, night, strength);
else // Simple condition
wi = new WeatherIcon(condition, night);
return wi;
} }
TQString WeatherLib::date(const TQString &stationID){ TQString WeatherLib::date(const TQString &stationID){
Data *d = findData(stationID); Data *d = findData(stationID);
if (d->wi.qsDate.isValid()) {
if ( ! d->wi.qsDate.isValid() )
return "";
else
{
TQDateTime gmtDateTime(d->wi.qsDate, d->wi.qsTime); TQDateTime gmtDateTime(d->wi.qsDate, d->wi.qsTime);
TQDateTime localDateTime = gmtDateTime.addSecs(KRFCDate::localUTCOffset() * 60); TQDateTime localDateTime = gmtDateTime.addSecs(KRFCDate::localUTCOffset() * 60);
return TDEGlobal::locale()->formatDateTime(localDateTime, false, false); return TDEGlobal::locale()->formatDateTime(localDateTime, false, false);
} }
return TQString::null;
} }
/** Returns the current cover */ /** Returns the current cover */
@ -348,6 +369,12 @@ bool WeatherLib::stationNeedsMaintenance(const TQString &stationID)
return d->wi.stationNeedsMaintenance; return d->wi.stationNeedsMaintenance;
} }
bool WeatherLib::weatherDataAvailable(const TQString &stationID)
{
Data *d = findData(stationID);
return !(d->wi.theWeather == "dunno");
}
void WeatherLib::update(const TQString &stationID) void WeatherLib::update(const TQString &stationID)
{ {
// Only grab new data if its more than 50 minutes old // Only grab new data if its more than 50 minutes old

@ -28,12 +28,12 @@ namespace TDEIO
} }
class StationDatabase; class StationDatabase;
class WeatherIcon;
class WeatherLib : public TQObject class WeatherLib : public TQObject
{ {
Q_OBJECT Q_OBJECT
public: public:
class Data; class Data;
@ -48,12 +48,14 @@ class WeatherLib : public TQObject
TQString wind(const TQString &stationID); TQString wind(const TQString &stationID);
TQString pressure(const TQString &stationID); TQString pressure(const TQString &stationID);
TQString iconName(const TQString &stationID); TQString iconName(const TQString &stationID);
TQString iconPath(const TQString &stationID); TQString iconName(const TQString &stationID, uint iconSize);
TQString iconPath(const TQString &stationID, uint iconSize);
TQString date(const TQString &stationID); TQString date(const TQString &stationID);
TQStringList weather(const TQString &stationID); TQStringList weather(const TQString &stationID);
TQString visibility(const TQString &stationID); TQString visibility(const TQString &stationID);
TQStringList cover(const TQString &stationID); TQStringList cover(const TQString &stationID);
bool stationNeedsMaintenance(const TQString &stationID); bool stationNeedsMaintenance(const TQString &stationID);
bool weatherDataAvailable(const TQString &stationID);
TQStringList stations(); TQStringList stations();
bool isNight(const TQString &stationID) const; bool isNight(const TQString &stationID) const;
@ -72,6 +74,7 @@ class WeatherLib : public TQObject
private: private:
Data* findData(const TQString &stationID); Data* findData(const TQString &stationID);
WeatherIcon* weatherIcon(const TQString &stationID);
void clearData(Data *d); void clearData(Data *d);
void getData(Data *d, bool force = false); void getData(Data *d, bool force = false);
void processData(const TQString &metar, Data *d); void processData(const TQString &metar, Data *d);

@ -139,18 +139,33 @@ TQString WeatherService::pressure(const TQString &stationID)
return m_weatherLib->pressure(stationID); return m_weatherLib->pressure(stationID);
} }
TQPixmap WeatherService::icon(const TQString &stationID, uint iconSize)
{
return kapp->iconLoader()->loadIcon(
iconPath(stationID, iconSize),
TDEIcon::Panel, iconSize
);
}
TQString WeatherService::iconName(const TQString &stationID, uint iconSize)
{
return m_weatherLib->iconName(stationID, iconSize);
}
TQString WeatherService::iconPath(const TQString &stationID, uint iconSize)
{
return m_weatherLib->iconPath(stationID, iconSize);
}
/*** (Begin) Deprecated: functions kept for compatibility reasons */
TQPixmap WeatherService::currentIcon(const TQString &stationID) TQPixmap WeatherService::currentIcon(const TQString &stationID)
{ {
return icon( stationID ); return icon(stationID, IconSize(TDEIcon::Panel));
} }
TQPixmap WeatherService::icon(const TQString &stationID) TQPixmap WeatherService::icon(const TQString &stationID)
{ {
kdDebug(12006) << "Get the current weather icon.." << endl; return icon(stationID, IconSize(TDEIcon::Panel));
return kapp->iconLoader()->loadIcon(
iconFileName(stationID),
TDEIcon::Desktop
);
} }
TQString WeatherService::currentIconString(const TQString &stationID) TQString WeatherService::currentIconString(const TQString &stationID)
@ -160,8 +175,9 @@ TQString WeatherService::currentIconString(const TQString &stationID)
TQString WeatherService::iconFileName(const TQString &stationID) TQString WeatherService::iconFileName(const TQString &stationID)
{ {
return m_weatherLib->iconPath(stationID); return iconPath(stationID, IconSize(TDEIcon::Panel));
} }
/*** (End) Deprecated: functions kept for compatibility reasons */
void WeatherService::useIconTheme(bool use) void WeatherService::useIconTheme(bool use)
{ {
@ -199,6 +215,11 @@ bool WeatherService::stationNeedsMaintenance(const TQString &stationID)
return m_weatherLib->stationNeedsMaintenance(stationID); return m_weatherLib->stationNeedsMaintenance(stationID);
} }
bool WeatherService::weatherDataAvailable(const TQString &stationID)
{
return m_weatherLib->weatherDataAvailable(stationID);
}
void WeatherService::update(const TQString &stationID) void WeatherService::update(const TQString &stationID)
{ {
m_weatherLib->update(stationID); m_weatherLib->update(stationID);

@ -61,15 +61,21 @@ class WeatherService : public TQObject, public DCOPObject
TQString windChill(const TQString &stationID); TQString windChill(const TQString &stationID);
TQString wind(const TQString &stationID); TQString wind(const TQString &stationID);
TQString pressure(const TQString &stationID); TQString pressure(const TQString &stationID);
TQPixmap currentIcon(const TQString &stationID); TQPixmap icon(const TQString &stationID, uint iconSize);
TQPixmap icon(const TQString &stationID); TQString iconName(const TQString &stationID, uint iconSize);
TQString currentIconString(const TQString &stationID); TQString iconPath(const TQString &stationID, uint iconSize);
TQString iconFileName(const TQString &stationID);
TQString date(const TQString &stationID); TQString date(const TQString &stationID);
TQString visibility(const TQString &stationID); TQString visibility(const TQString &stationID);
TQStringList cover(const TQString &stationID); TQStringList cover(const TQString &stationID);
TQStringList weather(const TQString &stationID); TQStringList weather(const TQString &stationID);
bool stationNeedsMaintenance(const TQString &stationID); bool stationNeedsMaintenance(const TQString &stationID);
bool weatherDataAvailable(const TQString &stationID);
/* compatibility */
TQPixmap currentIcon(const TQString &stationID) KDE_DEPRECATED;
TQPixmap icon(const TQString &stationID) KDE_DEPRECATED;
TQString currentIconString(const TQString &stationID) KDE_DEPRECATED;
TQString iconFileName(const TQString &stationID) KDE_DEPRECATED;
TQString stationName(const TQString &stationID); TQString stationName(const TQString &stationID);
TQString stationCountry(const TQString &stationID); TQString stationCountry(const TQString &stationID);

Loading…
Cancel
Save