Simplify traffic info class.
[yandex-traffic] / tests / traffic / mainwindow.hpp
1 #ifndef __MAINWINDOW_H__
2 #define __MAINWINDOW_H__
3
4 #include <QtGui>
5 #include <traffic.hpp>
6
7
8 class MainWindow : public QPushButton
9 {
10     Q_OBJECT
11
12 private:
13     Traffic _traffic;
14
15 protected slots:
16     void fetchTraffic ()
17     {
18         printf ("Traffic update requested\n");
19         _traffic.update ();
20     }
21
22     void trafficUpdated ()
23     {
24         CityTrafficInfo info;
25
26         printf ("Traffic data updated:\n");
27         printf ("ts: %s\n", _traffic.ts ().toString ().toUtf8 ().data ());
28
29         info = _traffic.lookup_ext ("1");
30         printf ("Moscow: %d, %d, %s\n", info.level (), info.tend (), info.hint ().toUtf8 ().data ());
31     }
32
33 public:
34     MainWindow ()
35         : QPushButton ()
36     {
37         connect (this, SIGNAL (clicked ()), this, SLOT (fetchTraffic ()));
38         connect (&_traffic, SIGNAL (updated ()), this, SLOT (trafficUpdated ()));
39         setText ("Fetch traffic information");
40     }
41 };
42
43
44 #endif // __MAINWINDOW_H__