-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathion_gismeteo.h
133 lines (105 loc) · 4.5 KB
/
ion_gismeteo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/***************************************************************************
* Copyright (C) 2012 by Alexey Torkhov <[email protected]> *
* *
* Based on KDE weather ions by Shawn Starr *
* Copyright (C) 2007-2009 by Shawn Starr <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
***************************************************************************/
/* Ion for Gismeteo data */
#ifndef ION_GISMETEO_H
#define ION_GISMETEO_H
#include <QtXml/QXmlStreamReader>
#include <QDateTime>
#include <kdemacros.h>
#include <KIO/Job>
#include <Plasma/DataEngine>
#include <Plasma/Weather/Ion>
class WeatherData
{
public:
// Current observation information.
QString date;
QString condition;
QString conditionIcon;
QString temperature;
QString pressure;
QString windDirection;
QString windSpeed;
QString humidity;
QString waterTemperature;
struct Forecast
{
QString day;
QString icon;
QString temperatureHigh;
QString temperatureLow;
};
QList<Forecast> forecasts;
};
class KDE_EXPORT EnvGismeteoIon : public IonInterface
{
Q_OBJECT
public:
EnvGismeteoIon(QObject *parent, const QVariantList &args);
~EnvGismeteoIon();
bool updateIonSource(const QString& source); // Sync data source with Applet
void updateWeather(const QString& source);
void validate(const QString& source);
struct XMLMapInfo {
QString name;
QString link;
int id;
};
public Q_SLOTS:
virtual void reset();
protected:
void init(); // Setup the city location, fetching the correct URL name.
protected Q_SLOTS:
void slotDataArrived(KIO::Job *, const QByteArray &);
void slotJobFinished(KJob *);
void setup_slotDataArrived(KIO::Job *, const QByteArray &);
void setup_slotJobFinished(KJob *);
private:
/* Gismeteo Methods - Internal for Ion */
void deleteForecasts();
QMap<QString, ConditionIcons> setupConditionIconMappings(void) const;
QMap<QString, ConditionIcons> setupForecastIconMappings(void) const;
QMap<QString, QString> setupForecastConditionMappings(void) const;
QMap<QString, QString> setupDayMappings(void) const;
QMap<QString, WindDirections> setupWindIconMappings(void) const;
QMap<QString, ConditionIcons> const& conditionIcons(void) const;
QMap<QString, ConditionIcons> const& forecastIcons(void) const;
QMap<QString, QString> const& forecastConditions(void) const;
QMap<QString, QString> const& dayMap(void) const;
QMap<QString, WindDirections> const& windIcons(void) const;
// Load and parse the specific place(s)
void getWeather(const QString& code, const QString& source);
bool readHTMLData(const QString& source, const QByteArray& xml);
// Check if place specified is valid or not
void findPlace(const QString& place, const QString& source);
bool readSearchHTMLData(const QString& source, const QByteArray& xml);
// Weather information
QHash<QString, WeatherData> m_weatherData;
QHash<QString, QList<EnvGismeteoIon::XMLMapInfo> > m_places;
// Store KIO jobs
QHash<KJob *, QByteArray> m_jobXml;
QHash<KJob *, QString> m_jobList;
QHash<KJob *, QByteArray> m_searchJobXml;
QHash<KJob *, QString> m_searchJobList;
};
K_EXPORT_PLASMA_DATAENGINE(gismeteo, EnvGismeteoIon)
#endif