Changes: added GPS class and made app get from location from GPS
[ptas] / zouba / main.cpp
index 65190f9..182e723 100644 (file)
@@ -3,17 +3,13 @@
 #include "ui_zouba.h"
 #include "uicontroller.h"
 #include "location.h"
+#include "gpscontroller.h"
+
+#include "ytv.h"
 
 #include <QDebug>
 #include <QObject>
 
-namespace {
-  Location home( "2549183", "6672570" );
-  Location work( "2551042", "6672829" );
-  QString homeKey( "taivaanvuohentie%207%2Chelsinki" );
-  QString workKey( "it%E4merenkatu%2011%2Chelsinki" );
-}
-
 int main(int argc, char *argv[] )
 {
   QApplication app(argc, argv);
@@ -30,20 +26,28 @@ int main(int argc, char *argv[] )
       uiController, SLOT( displayRoute( RouteData ) )
       );
 
-  Location *from = new Location();
+  GpsController *gpsController = new GpsController();
   Location *to   = new Location();
 
   QObject::connect(
-      from, SIGNAL( becomeValid() ),
-      route, SLOT( setFromLocation() )
+      gpsController, SIGNAL( locationChanged( Location ) ),
+      route, SLOT( setFromLocation( Location ) )
       );
   QObject::connect(
       to, SIGNAL( becomeValid() ),
       route, SLOT( setToLocation() )
       );
 
-  from->resolveAddress( homeKey );
-  to->resolveAddress( workKey );
+  ui.homeaddress->setText( "GPS" );
+  ui.workaddress->setText( work );
+
+  gpsController->startGps();
+  to->resolveAddress( work );
+
+  QObject::connect(
+      uiController, SIGNAL( workAddressChanged( QString ) ),
+      to, SLOT( resolveAddress( QString ) )
+    );
 
   widget->show();
   return app.exec();