1 #include "uicontroller.h"
8 #include <QTableWidgetItem>
11 #include <QButtonGroup>
13 UiController::UiController( Ui *ui ) :
16 Location *homeLocation = new Location();
17 Location *workLocation = new Location();
20 homeLocation, SIGNAL( becomeValid() ),
21 this, SLOT( setHomeButtonValid() )
24 workLocation, SIGNAL( becomeValid() ),
25 this, SLOT( setWorkButtonValid() )
28 homeLocation->resolveAddress( home );
29 workLocation->resolveAddress( work );
31 destination.append( homeLocation );
32 destination.append( workLocation );
35 ui->destinationButtons, SIGNAL( buttonClicked( int ) ),
36 this, SLOT( changeDestination( int ) )
41 UiController::~UiController()
45 void UiController::setHomeButtonValid()
47 setButtonValid( Ui::HomeButtonId );
50 void UiController::setWorkButtonValid()
52 setButtonValid( Ui::WorkButtonId );
55 void UiController::setButtonValid( int id )
57 ui->destinationButtons->button( id )->setEnabled(true);
60 void UiController::changeDestination( int id )
62 bool destinationHasChanged = ( currentDestination != id );
63 if ( destinationHasChanged ) {
64 emit destinationChanged( *(destination[id]) );
67 // always want to emit this so that the gps position is update
68 // and the user gets new information
72 void UiController::displayRoute( const RouteData &routeData )
74 qDebug() << __PRETTY_FUNCTION__;
75 qDebug() << "routeData.arrivalTime" << routeData.arrivalTime;
76 qDebug() << "routeData.lineCode" << routeData.lineCode;
78 QTableWidgetItem *timeItem = new QTableWidgetItem( routeData.arrivalTime );
79 ui->table->setItem( 0, 0, timeItem );
81 QTableWidgetItem *lineItem = new QTableWidgetItem( routeData.lineCode );
82 ui->table->setItem( 0, 1, lineItem );