Simplify traffic info class.
[yandex-traffic] / mainwidget.cpp
index 33d3303..f42b87b 100644 (file)
@@ -1,5 +1,6 @@
 #include <QtGui>
 
+#include "globals.hpp"
 #include "mainwidget.hpp"
 #include "settingsDialog.hpp"
 #include "connection.hpp"
@@ -19,7 +20,7 @@ MainWidget::MainWidget ()
     setAttribute(Qt::WA_TranslucentBackground);
 #endif
     _light = new TrafficLight (this);
-    _label = new QLabel (this);
+    _label = new QLabel (tr ("No data"), this);
     _timer = new QTimer (this);
 
     _label->setAlignment (Qt::AlignHCenter | Qt::AlignVCenter);
@@ -68,11 +69,13 @@ void MainWidget::paintEvent(QPaintEvent *event)
 
 void MainWidget::trafficUpdated ()
 {
-    ExtendedTrafficInfo info = _traffic->lookup_ext (_settings->regionID ());
+    CityTrafficInfo info = _traffic->lookup_ext (_settings->regionID ());
 
     if (info.valid ()) {
         QString data;
         bool first = true;
+        Log::instance ()->add ("trafficUpdated, info valid");
+        info.dump ();
         _light->setColor (info.color ());
 
         if (_settings->check (Settings::C_ShowRank)) {
@@ -83,7 +86,7 @@ void MainWidget::trafficUpdated ()
         if (_settings->check (Settings::C_ShowTime)) {
             if (!first)
                 data.append (", ");
-            data.append (info.localtime ());
+            data.append (info.ts ().toString ("h:mm"));
             first = false;
         }
 
@@ -96,7 +99,8 @@ void MainWidget::trafficUpdated ()
         _label->setText (data);
     }
     else {
-        _light->setColor (ExtendedTrafficInfo::Unknown);
+        Log::instance ()->add ("trafficUpdated, but info not valid");
+        _light->setColor (CityTrafficInfo::Unknown);
         _label->setText (tr ("No data"));
     }
 }