• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Plasma

ion_noaa.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Shawn Starr <shawn.starr@rogers.com>            *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU General Public License     *
00015  *   along with this program; if not, write to the                         *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
00018  ***************************************************************************/
00019 
00020 /* Ion for NOAA's National Weather Service XML data */
00021 
00022 #ifndef _ION_NOAA_H
00023 #define _ION_NOAA_H
00024 
00025 #include <QtXml/QXmlStreamReader>
00026 #include <QtCore/QStringList>
00027 #include <QDebug>
00028 #include <kurl.h>
00029 #include <kio/job.h>
00030 #include <kio/scheduler.h>
00031 #include <kdemacros.h>
00032 #include <plasma/dataengine.h>
00033 #include "ion.h"
00034 #include "formulas.h"
00035 
00036 class WeatherData
00037 {
00038 
00039 public:
00040     //QString countryName; // USA
00041     QString locationName;
00042     QString stationID;
00043     QString stateName;
00044 
00045     // Current observation information.
00046     QString observationTime;
00047     QString weather;
00048     QString temperature_F;
00049     QString temperature_C;
00050     QString humidity;
00051     QString windString;
00052     QString windDirection;
00053     QString windSpeed; // Float value
00054     QString windGust; // Float value
00055     QString pressure;
00056     QString dewpoint_F;
00057     QString dewpoint_C;
00058     QString heatindex_F;
00059     QString heatindex_C;
00060     QString windchill_F;
00061     QString windchill_C;
00062     QString visibility;
00063 };
00064 
00065 class KDE_EXPORT NOAAIon : public IonInterface
00066 {
00067     Q_OBJECT
00068 
00069 public:
00070     NOAAIon(QObject *parent, const QVariantList &args);
00071     ~NOAAIon();
00072     void init(void);  // Setup the city location, fetching the correct URL name.
00073     bool metricUnit(void);
00074     bool timezone(void);
00075     void setMeasureUnit(const QString& unit);
00076     void setTimezoneFormat(const QString& tz);
00077     bool updateIonSource(const QString& source); // Sync data source with Applet
00078     void updateWeather(const QString& source);
00079 
00080 protected slots:
00081     void setup_slotDataArrived(KIO::Job *, const QByteArray &);
00082     void setup_slotJobFinished(KJob *);
00083 
00084     void slotDataArrived(KIO::Job *, const QByteArray &);
00085     void slotJobFinished(KJob *);
00086 
00087 private:
00088     /* NOAA Methods - Internal for Ion */
00089 
00090     // Place information
00091     QString country(const QString& source);
00092     QString place(const QString& source);
00093     QString station(const QString& source);
00094 
00095     // Current Conditions Weather info
00096     QString observationTime(const QString& source);
00097     QString condition(const QString& source);
00098     QMap<QString, QString> temperature(const QString& source);
00099     QString dewpoint(const QString& source);
00100     QString humidity(const QString& source);
00101     QMap<QString, QString> visibility(const QString& source);
00102     QMap<QString, QString> pressure(const QString& source);
00103     QMap<QString, QString> wind(const QString& source);
00104 
00105     // Load and Parse the place XML listing
00106     void getXMLSetup(void);
00107     bool readXMLSetup(void);
00108 
00109     // Load and parse the specific place(s)
00110     void getXMLData(const QString& source);
00111     bool readXMLData(const QString& source, QXmlStreamReader& xml);
00112 
00113     // Check if place specified is valid or not
00114     QStringList validate(const QString& source) const;
00115 
00116     // Catchall for unknown XML tags
00117     void parseUnknownElement(QXmlStreamReader& xml);
00118 
00119     // Parse weather XML data
00120     WeatherData parseWeatherSite(WeatherData& data, QXmlStreamReader& xml);
00121     void parseStationID(void);
00122     void parseStationList(void);
00123 
00124 private:
00125     class Private;
00126     Private *const d;
00127 };
00128 
00129 K_EXPORT_PLASMA_ION(noaa, NOAAIon)
00130 
00131 #endif

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal