summaryrefslogtreecommitdiff
path: root/meecastweather/meecastweather.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-15 16:24:46 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-15 16:24:46 +0200
commitcf54773b561c324596b25739888b8ab5b4b45bd1 (patch)
tree40f210f39cbb296a51473fcaa6e5b1f61f3ab998 /meecastweather/meecastweather.cpp
parent2ecf718cc9d460ad192de196aac8d13e30a7ab4c (diff)
downloadsowatch-cf54773b561c324596b25739888b8ab5b4b45bd1.tar.gz
sowatch-cf54773b561c324596b25739888b8ab5b4b45bd1.zip
preparing meecastplugin
Diffstat (limited to 'meecastweather/meecastweather.cpp')
-rw-r--r--meecastweather/meecastweather.cpp47
1 files changed, 23 insertions, 24 deletions
diff --git a/meecastweather/meecastweather.cpp b/meecastweather/meecastweather.cpp
index c4daeb9..407e359 100644
--- a/meecastweather/meecastweather.cpp
+++ b/meecastweather/meecastweather.cpp
@@ -1,18 +1,17 @@
-#include "harmaccuweather.h"
+#include <QtCore/QDir>
+#include <QtCore/QDebug>
-using namespace sowatch;
+#include "meecastweather.h"
-#define ACCUWEATHER_FILE_PATH "/home/user/.config/AccuWeather, Inc./awxapp.conf"
+using namespace sowatch;
-HarmAccuWeather::HarmAccuWeather(QObject *parent) :
+MeeCastWeather::MeeCastWeather(QObject *parent) :
WeatherNotification(parent),
_watcher(new QFileSystemWatcher(this)),
_timer(new QTimer(this)),
_lastUpdate(QDateTime::fromTime_t(0))
{
- // This only works on Harmattan either way, so I guess
- // hardcoding the path is OK.
- _watcher->addPath(ACCUWEATHER_FILE_PATH);
+ _watcher->addPath(configFilePath());
connect(_watcher, SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString)));
_timer->setInterval(5000);
@@ -23,32 +22,32 @@ HarmAccuWeather::HarmAccuWeather(QObject *parent) :
update();
}
-QSettings* HarmAccuWeather::getAccuweatherData()
+QString MeeCastWeather::configFilePath()
{
- return new QSettings(ACCUWEATHER_FILE_PATH, QSettings::IniFormat);
+ return QDir::home().absoluteFilePath(".config/com.meecast.omweather/config.xml");
}
-Notification::Type HarmAccuWeather::type() const
+Notification::Type MeeCastWeather::type() const
{
return Notification::WeatherNotification;
}
-uint HarmAccuWeather::count() const
+uint MeeCastWeather::count() const
{
return 1;
}
-QDateTime HarmAccuWeather::dateTime() const
+QDateTime MeeCastWeather::dateTime() const
{
return _lastUpdate;
}
-QString HarmAccuWeather::title() const
+QString MeeCastWeather::title() const
{
return _lastLocation;
}
-QString HarmAccuWeather::body() const
+QString MeeCastWeather::body() const
{
switch (_lastWxCode) {
case 1:
@@ -131,7 +130,7 @@ QString HarmAccuWeather::body() const
}
}
-WeatherNotification::WeatherType HarmAccuWeather::forecast()
+WeatherNotification::WeatherType MeeCastWeather::forecast()
{
switch (_lastWxCode) {
case 1:
@@ -198,37 +197,36 @@ WeatherNotification::WeatherType HarmAccuWeather::forecast()
}
}
-int HarmAccuWeather::temperature()
+int MeeCastWeather::temperature()
{
return _lastTemp;
}
-WeatherNotification::Unit HarmAccuWeather::temperatureUnits()
+WeatherNotification::Unit MeeCastWeather::temperatureUnits()
{
return _metric ? Celsius : Fahrenheit;
}
-void HarmAccuWeather::activate()
+void MeeCastWeather::activate()
{
// Launch accuweather?
}
-void HarmAccuWeather::dismiss()
+void MeeCastWeather::dismiss()
{
// Do nothing
}
-void HarmAccuWeather::fileChanged(const QString &path)
+void MeeCastWeather::fileChanged(const QString &path)
{
Q_UNUSED(path);
- qDebug() << "accuweather config file changed";
+ qDebug() << "meecast config file changed: " << path;
_timer->start();
}
-void HarmAccuWeather::update()
+void MeeCastWeather::update()
{
- QSettings* s = getAccuweatherData();
-
+#if 0
qDebug() << "reading accuweather config file";
QDateTime lastUpdate = s->value("LastUpdate").toDateTime();
@@ -269,4 +267,5 @@ void HarmAccuWeather::update()
}
delete s;
+#endif
}