~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/dataengines/weather/ions/ion.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 * Copyright (C) 2007-2009 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
 *****************************************************************************/
 
19
 
 
20
#ifndef ION_H
 
21
#define ION_H
 
22
 
 
23
#include <QtCore/QObject>
 
24
#include <Plasma/DataEngine>
 
25
 
 
26
#include "ion_export.h"
 
27
 
 
28
/**
 
29
* @author Shawn Starr
 
30
* This is the base class to be used to implement new ions for the WeatherEngine.
 
31
* 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.
 
32
*
 
33
* Basically an ion is a Plasma::DataEngine, which is queried by the WeatherEngine instead of some applet.
 
34
*/
 
35
class ION_EXPORT IonInterface : public Plasma::DataEngine
 
36
{
 
37
    Q_OBJECT
 
38
 
 
39
public:
 
40
 
 
41
    enum ConditionIcons { ClearDay = 1, FewCloudsDay, PartlyCloudyDay, Overcast,
 
42
                          Rain, LightRain, Showers, ChanceShowersDay, Thunderstorm, Hail,
 
43
                          Snow, LightSnow, Flurries, FewCloudsNight, ChanceShowersNight,
 
44
                          PartlyCloudyNight, ClearNight, Mist, Haze, FreezingRain,
 
45
                          RainSnow, FreezingDrizzle, ChanceThunderstormDay, ChanceThunderstormNight,
 
46
                          ChanceSnowDay, ChanceSnowNight, NotAvailable
 
47
                        };
 
48
 
 
49
    enum WindDirections { N, NNE, NE, ENE, E, SSE, SE, ESE, S, NNW, NW, WNW, W, SSW, SW, WSW, VR };
 
50
 
 
51
    /**
 
52
     * Constructor for the ion
 
53
     * @param parent The parent object.
 
54
     * @Param args The argument list.
 
55
     */
 
56
    explicit IonInterface(QObject *parent = 0, const QVariantList &args = QVariantList());
 
57
    /**
 
58
     * Destructor for the ion
 
59
     */
 
60
    virtual ~IonInterface();
 
61
 
 
62
    /**
 
63
     * Returns weather icon filename to display in applet.
 
64
     * @param condition the current condition being reported.
 
65
     * @return icon name
 
66
     */
 
67
    QString getWeatherIcon(ConditionIcons condition) const;
 
68
 
 
69
    /**
 
70
     * Returns weather icon filename to display in applet.
 
71
     * @param conditionList a QList map pair of icons mapped to a enumeration of conditions.
 
72
     * @param condition the current condition being reported.
 
73
     * @return icon name
 
74
     */
 
75
    QString getWeatherIcon(const QMap<QString, ConditionIcons> &conditionList, const QString& condition) const;
 
76
 
 
77
    /**
 
78
     * Returns wind icon element to display in applet.
 
79
     * @param windDirList a QList map pair of wind directions mapped to a enumeration of directions.
 
80
     * @param windDirection the current wind direction.
 
81
     * @return svg element for wind direction
 
82
     */
 
83
    QString getWindDirectionIcon(const QMap<QString, WindDirections> &windDirList, const QString& windDirection) const;
 
84
 
 
85
public Q_SLOTS:
 
86
 
 
87
    /**
 
88
     * Reimplemented from Plasma::DataEngine
 
89
     * @param source the name of the datasource to be updated
 
90
     */
 
91
    bool updateSourceEvent(const QString& source);
 
92
 
 
93
    /**
 
94
     * Reimplement for ion to reload data if network status comes back up
 
95
     */
 
96
    virtual void reset() = 0;
 
97
 
 
98
Q_SIGNALS:
 
99
    void forceUpdate(IonInterface *ion, const QString &source);
 
100
 
 
101
protected:
 
102
 
 
103
    /**
 
104
     * Call this method to flush waiting source requests that may be pending
 
105
     * initialization
 
106
     *
 
107
     * @arg initialized whether or not the ion is currently ready to fetch data
 
108
     */
 
109
    void setInitialized(bool initialized);
 
110
 
 
111
    /**
 
112
     * Reimplemented from Plasma::DataEngine
 
113
     * @param source The datasource being requested
 
114
     */
 
115
    bool sourceRequestEvent(const QString &source);
 
116
 
 
117
    /**
 
118
     * Reimplement to fetch the data from the ion.
 
119
     * @arg source the name of the datasource.
 
120
     * @return true if update was successful, false if failed
 
121
     */
 
122
    virtual bool updateIonSource(const QString &source) = 0;
 
123
 
 
124
    friend class WeatherEngine;
 
125
 
 
126
private:
 
127
    class Private;
 
128
    Private* const d;
 
129
};
 
130
 
 
131
#endif
 
132