HttpFetcher helper class for simple data fetch.
[yandex-traffic] / traffic.hpp
1 #ifndef __TRAFFIC_H__
2 #define __TRAFFIC_H__
3
4 #include <QtCore>
5 #include <QtNetwork>
6
7
8 #include "http_fetcher.hpp"
9
10 // Base data of traffic information
11 class TrafficInfo
12 {
13 private:
14     float _len1, _len2, _len;
15     QDateTime _ts;
16     QString _isotime;
17     QString _localtime;
18
19 public:
20     TrafficInfo ();
21 };
22
23
24 class ExtendedTrafficInfo : public TrafficInfo
25 {
26 public:
27     enum light_color {
28         Red,
29         Yellow,
30         Green
31     };
32
33 private:
34     float _level_raw;
35     quint8 _level;
36     light_color _color;
37     quint8 _tend;
38     QString _hint;
39
40 public:
41     ExtendedTrafficInfo ();
42 };
43
44
45 class Traffic : public QObject
46 {
47     Q_OBJECT
48
49 private:
50     QDateTime _ts;
51
52     QMap<QString, TrafficInfo> _info;
53     QMap<QString, ExtendedTrafficInfo> _ext_info;
54
55     HttpFetcher _fetcher;
56
57 private slots:
58     void fetchDone (const QByteArray& data);
59
60 signals:
61     void updated ();
62
63 public:
64     Traffic ();
65
66     void update ();
67 };
68
69
70 #endif // __TRAFFIC_H__