Added a toggle button, and fields to set home and work addresses.
[ptas] / zouba / main.cpp
1 #include "routedata.h"
2 #include "route.h"
3 #include "ui_zouba.h"
4 #include "uicontroller.h"
5 #include "location.h"
6
7 #include "ytv.h"
8
9 #include <QDebug>
10 #include <QObject>
11
12 int main(int argc, char *argv[] )
13 {
14   QApplication app(argc, argv);
15   QMainWindow *widget = new QMainWindow;
16   Ui::MainWindow ui;
17   ui.setupUi(widget);
18
19   UiController *uiController = new UiController( &ui );
20
21   Route *route = new Route();
22
23   QObject::connect(
24       route, SIGNAL( routeReady( RouteData ) ),
25       uiController, SLOT( displayRoute( RouteData ) )
26       );
27
28   Location *from = new Location();
29   Location *to   = new Location();
30
31   QObject::connect(
32       from, SIGNAL( becomeValid() ),
33       route, SLOT( setFromLocation() )
34       );
35   QObject::connect(
36       to, SIGNAL( becomeValid() ),
37       route, SLOT( setToLocation() )
38       );
39
40   ui.homeaddress->setText( home );
41   ui.workaddress->setText( work );
42
43   from->resolveAddress( home );
44   to->resolveAddress( work );
45
46   QObject::connect(
47       uiController, SIGNAL( homeAddressChanged( QString ) ),
48       from, SLOT( resolveAddress( QString ) )
49     );
50
51   QObject::connect(
52       uiController, SIGNAL( workAddressChanged( QString ) ),
53       to, SLOT( resolveAddress( QString ) )
54     );
55
56   /* toggle doesn't work yet because 'from' is connected to 'homeAddressChanged'
57   QObject::connect(
58       uiController, SIGNAL( directionChanged() ),
59       route, SLOT( toggleDirection() )
60     );
61     */
62
63   widget->show();
64   return app.exec();
65 }