Plasma
ion.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "ion.h"
00021 #include "ion.moc"
00022
00023 class IonInterface::Private : public QObject
00024 {
00025 public:
00026 Private(IonInterface *i)
00027 : ion(i),
00028 initialized(false) {}
00029
00030 int ref;
00031 IonInterface *ion;
00032 bool initialized;
00033 };
00034
00035 IonInterface::IonInterface(QObject *parent, const QVariantList &args)
00036 : Plasma::DataEngine(parent, args),
00037 d(new Private(this))
00038 {
00039
00040 d->ref = 0;
00041 }
00042
00043
00044 void IonInterface::ref()
00045 {
00046 ++d->ref;
00047 }
00048
00049
00050 void IonInterface::deref()
00051 {
00052 --d->ref;
00053 }
00054
00055
00056 bool IonInterface::isUsed() const
00057 {
00058 return d->ref != 0;
00059 }
00060
00064 bool IonInterface::sourceRequestEvent(const QString &source)
00065 {
00066 kDebug() << "sourceRequested()";
00067 if (d->initialized) {
00068 return updateIonSource(source);
00069 } else {
00070 setData(source, Plasma::DataEngine::Data());
00071 }
00072
00073 return true;
00074 }
00075
00079 bool IonInterface::updateSourceEvent(const QString& source)
00080 {
00081 kDebug() << "updateSource()";
00082 if (d->initialized) {
00083 return updateIonSource(source);
00084 }
00085
00086 return false;
00087 }
00088
00092 void IonInterface::setInitialized(bool initialized)
00093 {
00094 d->initialized = initialized;
00095
00096 if (d->initialized) {
00097 foreach(const QString &source, sources()) {
00098 updateSourceEvent(source);
00099 }
00100 }
00101 }
00102
00106 QString IonInterface::getWindDirectionIcon(const QMap<QString, WindDirections> &windDirList, const QString& windDirection)
00107 {
00108 switch (windDirList[windDirection.toLower()]) {
00109 case N:
00110 return "N";
00111 case NNE:
00112 return "NNE";
00113 case NE:
00114 return "NE";
00115 case ENE:
00116 return "ENE";
00117 case E:
00118 return "E";
00119 case SSE:
00120 return "SSE";
00121 case SE:
00122 return "SE";
00123 case ESE:
00124 return "ESE";
00125 case S:
00126 return "S";
00127 case NNW:
00128 return "NNW";
00129 case NW:
00130 return "NW";
00131 case WNW:
00132 return "WNW";
00133 case W:
00134 return "W";
00135 case SSW:
00136 return "SSW";
00137 case SW:
00138 return "SW";
00139 case WSW:
00140 return "WSW";
00141 case VR:
00142 return "N/A";
00143 }
00144
00145
00146 return "N/A";
00147 }
00148
00152 QString IonInterface::getWeatherIcon(const QMap<QString, ConditionIcons> &conditionList, const QString& condition)
00153 {
00154 switch (conditionList[condition.toLower()]) {
00155 case ClearDay:
00156 return "weather-clear";
00157 case FewCloudsDay:
00158 return "weather-few-clouds";
00159 case PartlyCloudyDay:
00160 return "weather-clouds";
00161 case Overcast:
00162 return "weather-many-clouds";
00163 case Rain:
00164 return "weather-showers";
00165 case LightRain:
00166 return "weather-showers-scattered";
00167 case Showers:
00168 return "weather-showers-scattered";
00169 case ChanceShowersDay:
00170 return "weather-showers-scattered-day";
00171 case ChanceShowersNight:
00172 return "weather-showers-scattered-night";
00173 case ChanceSnowDay:
00174 return "weather-snow-scattered-day";
00175 case ChanceSnowNight:
00176 return "weather-snow-scattered-night";
00177 case Thunderstorm:
00178 return "weather-storm";
00179 case Hail:
00180 return "weather-hail";
00181 case Snow:
00182 return "weather-snow";
00183 case LightSnow:
00184 return "weather-snow-scattered";
00185 case Flurries:
00186 return "weather-snow-scattered";
00187 case RainSnow:
00188 return "weather-snow-rain";
00189 case FewCloudsNight:
00190 return "weather-few-clouds-night";
00191 case PartlyCloudyNight:
00192 return "weather-clouds-night";
00193 case ClearNight:
00194 return "weather-clear-night";
00195 case Mist:
00196 return "weather-mist";
00197 case Haze:
00198 return "weather-mist";
00199 case FreezingRain:
00200 return "weather-freezing-rain";
00201 case FreezingDrizzle:
00202 return "weather-freezing-rain";
00203 case ChanceThunderstormDay:
00204 return "weather-scattered-storms-day";
00205 case ChanceThunderstormNight:
00206 return "weather-scattered-storms-night";
00207 case NotAvailable:
00208 return "weather-none-available";
00209 }
00210 return "weather-none-available";
00211 }