1 /*****************************************************************************
2 * Copyright (C) 2007-2008 by Shawn Starr <shawn.starr@rogers.com> *
4 * This library is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Library General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2 of the License, or (at your option) any later version. *
9 * This library is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Library General Public License for more details. *
14 * You should have received a copy of the GNU Library General Public License *
15 * along with this library; see the file COPYING.LIB. If not, write to *
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301, USA. *
18 *****************************************************************************/
23 class IonInterface::Private
: public QObject
26 Private(IonInterface
*i
)
35 IonInterface::IonInterface(QObject
*parent
, const QVariantList
&args
)
36 : Plasma::DataEngine(parent
, args
),
39 // Initialize the loaded ion with a reference count of 0.
43 // Increment reference counter
44 void IonInterface::ref()
49 // Decrement reference counter
50 void IonInterface::deref()
55 // Check if Ion is used
56 bool IonInterface::isUsed() const
62 * If the ion is not initialized just set the initial data source up even if it's empty, we'll retry once the initialization is done
64 bool IonInterface::sourceRequestEvent(const QString
&source
)
66 kDebug() << "sourceRequested()";
68 return updateIonSource(source
);
70 setData(source
, Plasma::DataEngine::Data());
77 * Update the ion's datasource. Triggered when a Plasma::DataEngine::connectSource() timeout occurs.
79 bool IonInterface::updateSourceEvent(const QString
& source
)
81 kDebug() << "updateSource()";
83 return updateIonSource(source
);
90 * Set the ion to make sure it is ready to get real data.
92 void IonInterface::setInitialized(bool initialized
)
94 d
->initialized
= initialized
;
97 foreach(const QString
&source
, sources()) {
98 updateSourceEvent(source
);
104 * Return wind direction svg element to display in applet when given a wind direction.
106 QString
IonInterface::getWindDirectionIcon(const QMap
<QString
, WindDirections
> &windDirList
, const QString
& windDirection
)
108 switch (windDirList
[windDirection
.toLower()]) {
142 return "N/A"; // For now, we'll make a variable wind icon later on
145 // No icon available, use 'X'
150 * Return weather icon to display in an applet when given a condition.
152 QString
IonInterface::getWeatherIcon(const QMap
<QString
, ConditionIcons
> &conditionList
, const QString
& condition
)
154 switch (conditionList
[condition
.toLower()]) {
156 return "weather-clear";
158 return "weather-few-clouds";
159 case PartlyCloudyDay
:
160 return "weather-clouds";
162 return "weather-many-clouds";
164 return "weather-showers";
166 return "weather-showers-scattered";
168 return "weather-showers-scattered";
169 case ChanceShowersDay
:
170 return "weather-showers-scattered-day";
171 case ChanceShowersNight
:
172 return "weather-showers-scattered-night";
174 return "weather-snow-scattered-day";
175 case ChanceSnowNight
:
176 return "weather-snow-scattered-night";
178 return "weather-storm";
180 return "weather-hail";
182 return "weather-snow";
184 return "weather-snow-scattered";
186 return "weather-snow-scattered";
188 return "weather-snow-rain";
190 return "weather-few-clouds-night";
191 case PartlyCloudyNight
:
192 return "weather-clouds-night";
194 return "weather-clear-night";
196 return "weather-mist";
198 return "weather-mist";
200 return "weather-freezing-rain";
201 case FreezingDrizzle
:
202 return "weather-freezing-rain";
203 case ChanceThunderstormDay
:
204 return "weather-scattered-storms-day";
205 case ChanceThunderstormNight
:
206 return "weather-scattered-storms-night";
208 return "weather-none-available";
210 return "weather-none-available";