delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / workspace / plasma / dataengines / weather / ions / ion.h
blob535683975744f721e31a6a7ec51f9a09c7302b01
1 /*****************************************************************************
2 * Copyright (C) 2007-2008 by Shawn Starr <shawn.starr@rogers.com> *
3 * *
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. *
8 * *
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. *
13 * *
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 *****************************************************************************/
20 #ifndef _ION_H
21 #define _ION_H
23 #include <QtCore/QObject>
24 #include <KDE/KGenericFactory>
25 #include <plasma/dataengine.h>
27 #include "ion_export.h"
29 /**
30 * @author Shawn Starr
31 * This is the base class to be used to implement new ions for the WeatherEngine.
32 * The idea is that you can have multiple ions which provide weather information from different services to the engine from which an applet will request the data from.
34 * Basically an ion is a Plasma::DataEngine, which is queried by the WeatherEngine instead of some applet.
36 class ION_EXPORT IonInterface : public Plasma::DataEngine
38 Q_OBJECT
40 public:
42 enum ConditionIcons { ClearDay = 1, FewCloudsDay, PartlyCloudyDay, Overcast,
43 Rain, LightRain, Showers, ChanceShowersDay, Thunderstorm, Hail,
44 Snow, LightSnow, Flurries, FewCloudsNight, ChanceShowersNight,
45 PartlyCloudyNight, ClearNight, Mist, Haze, FreezingRain,
46 RainSnow, FreezingDrizzle, ChanceThunderstormDay, ChanceThunderstormNight,
47 ChanceSnowDay, ChanceSnowNight, NotAvailable
50 enum WindDirections { N, NNE, NE, ENE, E, SSE, SE, ESE, S, NNW, NW, WNW, W, SSW, SW, WSW, VR };
52 typedef QHash<QString, IonInterface*> IonDict; // Define Dict as a QHash for Ions
54 /**
55 * Constructor for the ion
56 * @param parent The parent object.
57 * @Param args The argument list.
59 explicit IonInterface(QObject *parent = 0, const QVariantList &args = QVariantList());
60 /**
61 * Destructor for the ion
63 virtual ~IonInterface() {}
65 /**
66 * Increment ion counter. This is used to check if the ion is being used.
68 void ref();
70 /**
71 * Decrement ion counter. Called when ion is destroyed/unloaded.
73 void deref();
75 /**
76 * Returns whether the ion is being used.
77 * @return true if the ion is being used, false otherwise
79 bool isUsed() const;
81 /**
82 * Returns weather icon filename to display in applet.
83 * @param conditionList a QList map pair of icons mapped to a enumeration of conditions.
84 * @param condition the current condition being reported.
85 * @return icon name
87 QString getWeatherIcon(const QMap<QString, ConditionIcons> &conditionList, const QString& condition);
89 /**
90 * Returns wind icon element to display in applet.
91 * @param windDirList a QList map pair of wind directions mapped to a enumeration of directions.
92 * @param windDirection the current wind direction.
93 * @return svg element for wind direction
95 QString getWindDirectionIcon(const QMap<QString, WindDirections> &windDirList, const QString& windDirection);
97 public Q_SLOTS:
99 /**
100 * Reimplemented from Plasma::DataEngine
101 * @param source the name of the datasource to be updated
103 bool updateSourceEvent(const QString& source);
105 protected:
107 * Call this method to flush waiting source requests that may be pending
108 * initialization
110 * @arg initialized whether or not the ion is currently ready to fetch data
112 void setInitialized(bool initialized);
115 * Reimplemented from Plasma::DataEngine
116 * @param source The datasource being requested
118 bool sourceRequestEvent(const QString &source);
121 * Reimplement to fetch the data from the ion.
122 * @arg source the name of the datasource.
123 * @return true if update was successful, false if failed
125 virtual bool updateIonSource(const QString &source) = 0;
127 friend class WeatherEngine;
129 private:
130 class Private;
131 Private* const d;
134 #endif