summaryrefslogtreecommitdiff
path: root/meecastweather/meecastweather.h
blob: b51a1e43fa3dcca73a8ac7d32a91276c9572c035 (plain)
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
#ifndef MEECASTWEATHER_H
#define MEECASTWEATHER_H

#include <QtCore/QFileSystemWatcher>
#include <QtCore/QTimer>
#include <QtCore/QSettings>
#include <sowatch.h>

namespace sowatch
{

class MeeCastWeather : public WeatherNotification
{
    Q_OBJECT

public:
	explicit MeeCastWeather(QObject *parent = 0);

	const static QLatin1String configFilePath;

	Type type() const;
	uint count() const;
	QDateTime dateTime() const;
	QString title() const;
	QString body() const;

	WeatherType forecast() const;
	int temperature() const;
	Unit temperatureUnits() const;

	void activate();
	void dismiss();

private:
	int convertTemperatureToUserUnit(int temp, Unit unit);

private slots:
	void fileChanged(const QString& path);
	void parseConfigFile();
	void parseStationFile();
	void handleTimeout();

private:
	QFileSystemWatcher* _watcher;
	QTimer* _timer;

	QString _stationFilePath;

	bool _configFileChanged;
	bool _stationFileChanged;

	Unit _tempUnit;
	QString _location;

	QDateTime _lastUpdate;
	int _lastTemp;
	int _lastCode;
	QString _lastText;

};

}

#endif // MEECASTWEATHER_H