• Skip to content
  • Skip to link menu
KDE 4.2 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-2008 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 <QDateTime>
00029 #include <kurl.h>
00030 #include <kio/job.h>
00031 #include <kio/scheduler.h>
00032 #include <kdemacros.h>
00033 #include <plasma/dataengine.h>
00034 #include "ion.h"
00035 #include "weatherutils.h"
00036 
00037 class WeatherData
00038 {
00039 
00040 public:
00041     //QString countryName; // USA
00042     QString locationName;
00043     QString stationID;
00044     QString stateName;
00045 
00046     // Current observation information.
00047     QString observationTime;
00048     QString iconPeriodHour;
00049     QString iconPeriodAP;
00050     QString weather;
00051 
00052     QString temperature_F;
00053     QString temperature_C;
00054     QString humidity;
00055     QString windString;
00056     QString windDirection;
00057     QString windSpeed; // Float value
00058     QString windGust; // Float value
00059     QString pressure;
00060     QString dewpoint_F;
00061     QString dewpoint_C;
00062     QString heatindex_F;
00063     QString heatindex_C;
00064     QString windchill_F;
00065     QString windchill_C;
00066     QString visibility;
00067 };
00068 
00069 class KDE_EXPORT NOAAIon : public IonInterface
00070 {
00071     Q_OBJECT
00072 
00073 public:
00074     NOAAIon(QObject *parent, const QVariantList &args);
00075     ~NOAAIon();
00076     void init(void);  // Setup the city location, fetching the correct URL name.
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     QMap<QString, ConditionIcons> setupConditionIconMappings(void);
00090     QMap<QString, ConditionIcons> const & conditionIcons(void);
00091     QMap<QString, WindDirections> setupWindIconMappings(void);
00092     QMap<QString, WindDirections> const& windIcons(void);
00093 
00094     // Place information
00095     QString country(const QString& source);
00096     QString place(const QString& source);
00097     QString station(const QString& source);
00098 
00099     // Current Conditions Weather info
00100     QString observationTime(const QString& source);
00101     //bool night(const QString& source);
00102     int periodHour(const QString& source);
00103     QString condition(const QString& source);
00104     QMap<QString, QString> temperature(const QString& source);
00105     QString dewpoint(const QString& source);
00106     QString humidity(const QString& source);
00107     QMap<QString, QString> visibility(const QString& source);
00108     QMap<QString, QString> pressure(const QString& source);
00109     QMap<QString, QString> wind(const QString& source);
00110 
00111     // Load and Parse the place XML listing
00112     void getXMLSetup(void);
00113     bool readXMLSetup(void);
00114 
00115     // Load and parse the specific place(s)
00116     void getXMLData(const QString& source);
00117     bool readXMLData(const QString& source, QXmlStreamReader& xml);
00118 
00119     // Check if place specified is valid or not
00120     QStringList validate(const QString& source) const;
00121 
00122     // Catchall for unknown XML tags
00123     void parseUnknownElement(QXmlStreamReader& xml);
00124 
00125     // Parse weather XML data
00126     WeatherData parseWeatherSite(WeatherData& data, QXmlStreamReader& xml);
00127     void parseStationID(void);
00128     void parseStationList(void);
00129 
00130 private:
00131     class Private;
00132     Private *const d;
00133 };
00134 
00135 K_EXPORT_PLASMA_DATAENGINE(noaa, NOAAIon)
00136 
00137 #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
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
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