diff options
Diffstat (limited to 'kweather/weatherservice.cpp')
-rw-r--r-- | kweather/weatherservice.cpp | 89 |
1 files changed, 67 insertions, 22 deletions
diff --git a/kweather/weatherservice.cpp b/kweather/weatherservice.cpp index 60ad1b2..0496bd8 100644 --- a/kweather/weatherservice.cpp +++ b/kweather/weatherservice.cpp @@ -24,11 +24,13 @@ #include <tdeconfig.h> #include <tdeglobal.h> #include <tdelocale.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> +#include <kiconloader.h> #include "weatherlib.h" #include "weatherservice.h" #include "stationdatabase.h" +#include "weather_icon.h" #include "sun.h" WeatherService::WeatherService(TQObject *parent, const char *name) : TQObject (parent, name), DCOPObject("WeatherService") @@ -38,14 +40,14 @@ WeatherService::WeatherService(TQObject *parent, const char *name) : TQObject (p stationDB = new StationDatabase(); m_weatherLib = new WeatherLib(stationDB, this, "WeatherLib"); - connect(m_weatherLib, TQT_SIGNAL(fileUpdating( const TQString&)), - TQT_SLOT(updating( const TQString&))); - connect(m_weatherLib, TQT_SIGNAL(fileUpdate( const TQString&)), - TQT_SLOT(updated( const TQString&))); - connect(m_weatherLib, TQT_SIGNAL(stationRemoved(const TQString&)), - TQT_SLOT(slotStationRemoved(const TQString&))); + connect(m_weatherLib, TQ_SIGNAL(fileUpdating( const TQString&)), + TQ_SLOT(updating( const TQString&))); + connect(m_weatherLib, TQ_SIGNAL(fileUpdate( const TQString&)), + TQ_SLOT(updated( const TQString&))); + connect(m_weatherLib, TQ_SIGNAL(stationRemoved(const TQString&)), + TQ_SLOT(slotStationRemoved(const TQString&))); - TDEConfig *conf = kapp->config(); + TDEConfig *conf = tdeApp->config(); conf->setGroup("WEATHERSTATIONS"); TQStringList stations =conf->readListEntry("stations"); @@ -59,7 +61,7 @@ WeatherService::~WeatherService() kdDebug(12006) << "Going away... " << endl; // Don't need to call saveSettings() because WeatherService::exit // already does that. Plus it wouldn't work here anyway because - // we can't get the config after calling kapp->quit(); + // we can't get the config after calling tdeApp->quit(); delete stationDB; } @@ -71,13 +73,22 @@ void WeatherService::updated(const TQString &stationID) void WeatherService::updateAll() { - kdDebug(12006) << "Sending for all" << endl; + kdDebug(12006) << "Sending update for all" << endl; TQStringList stations = m_weatherLib->stations(); TQStringList::ConstIterator end(stations.end()); for ( TQStringList::ConstIterator it = stations.begin(); it != end; ++it ) { update(*it); - } + } +} +void WeatherService::forceUpdateAll() +{ + kdDebug(12006) << "Sending forceUpdate for all" << endl; + TQStringList stations = m_weatherLib->stations(); + TQStringList::ConstIterator end(stations.end()); + for ( TQStringList::ConstIterator it = stations.begin(); it != end; ++it ) { + forceUpdate(*it); + } } void WeatherService::updating(const TQString &stationID) @@ -128,17 +139,33 @@ TQString WeatherService::pressure(const TQString &stationID) return m_weatherLib->pressure(stationID); } +TQPixmap WeatherService::icon(const TQString &stationID, uint iconSize) +{ + return tdeApp->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) { - return icon( stationID ); + return icon(stationID, IconSize(TDEIcon::Panel)); } TQPixmap WeatherService::icon(const TQString &stationID) { - kdDebug(12006) << "Get the current weather icon.." << endl; - TQString icon = iconFileName(stationID); - TQPixmap theIcon = TQPixmap(icon); - return theIcon; + return icon(stationID, IconSize(TDEIcon::Panel)); } TQString WeatherService::currentIconString(const TQString &stationID) @@ -148,9 +175,19 @@ TQString WeatherService::currentIconString(const TQString &stationID) TQString WeatherService::iconFileName(const TQString &stationID) { - TQString icon = m_weatherLib->iconName(stationID); - icon = locate( "data", "kweather/" + icon + ".png" ); - return icon; + return iconPath(stationID, IconSize(TDEIcon::Panel)); +} +/*** (End) Deprecated: functions kept for compatibility reasons */ + +void WeatherService::useIconTheme(bool use) +{ + kdDebug(12006) << "Received signal to set useIconTheme to " << use << endl; + WeatherIconPrivate::instance()->useIconTheme(use); +} + +bool WeatherService::usingIconTheme() +{ + return WeatherIconPrivate::instance()->usingIconTheme(); } TQString WeatherService::date(const TQString &stationID) @@ -178,6 +215,11 @@ bool WeatherService::stationNeedsMaintenance(const TQString &stationID) return m_weatherLib->stationNeedsMaintenance(stationID); } +bool WeatherService::weatherDataAvailable(const TQString &stationID) +{ + return m_weatherLib->weatherDataAvailable(stationID); +} + void WeatherService::update(const TQString &stationID) { m_weatherLib->update(stationID); @@ -192,18 +234,22 @@ void WeatherService::removeStation(const TQString &stationID) { m_weatherLib->remove(stationID); saveSettings(); + emit stationRemoved(stationID); + kdDebug(12006) << "Station removed: " << stationID << endl; } void WeatherService::addStation(const TQString &stationID) { m_weatherLib->update(stationID); saveSettings(); + emit stationAdded(stationID); + kdDebug(12006) << "Station added: " << stationID << endl; } void WeatherService::exit() { saveSettings(); - kapp->quit(); + tdeApp->quit(); } TQStringList WeatherService::listStations() @@ -213,7 +259,7 @@ TQStringList WeatherService::listStations() void WeatherService::saveSettings() { - TDEConfig *conf = kapp->config(); + TDEConfig *conf = tdeApp->config(); conf->setGroup("WEATHERSTATIONS"); conf->writeEntry( "stations", m_weatherLib->stations()); conf->sync(); @@ -339,5 +385,4 @@ TQString WeatherService::civilTwilightEnd(const TQString &stationID) } - #include "weatherservice.moc" |