1 #include "uicontroller.h"
6 #include "messagetable.h"
9 #include <QTableWidgetItem>
10 #include <QPushButton>
12 #include <QButtonGroup>
14 UiController::UiController( Ui *ui ) :
17 Location *homeLocation = new Location();
18 Location *workLocation = new Location();
21 homeLocation, SIGNAL( becomeValid() ),
22 this, SLOT( setHomeButtonValid() )
25 workLocation, SIGNAL( becomeValid() ),
26 this, SLOT( setWorkButtonValid() )
29 homeLocation->resolveAddress( Ytv::Home );
30 workLocation->resolveAddress( Ytv::Work );
32 destination.append( homeLocation );
33 destination.append( workLocation );
36 ui->destinationButtons, SIGNAL( buttonClicked( int ) ),
37 this, SLOT( changeDestination( int ) )
42 UiController::~UiController()
46 void UiController::setHomeButtonValid()
48 setButtonValid( Ui::HomeButtonId );
51 void UiController::setWorkButtonValid()
53 setButtonValid( Ui::WorkButtonId );
56 void UiController::setButtonValid( int id )
58 ui->destinationButtons->button( id )->setEnabled(true);
61 void UiController::changeDestination( int id )
63 qDebug() << "Button "+QString::number(id)+" clicked";
65 bool destinationHasChanged = ( currentDestination != id );
66 if ( destinationHasChanged ) {
67 emit destinationChanged( *(destination[id]) );
70 // always want to emit this so that the gps position is update
71 // and the user gets new information
75 void UiController::displayRoute( const QList<RouteData> &routeData )
77 qDebug() << "displaying route";
79 ui->table->setRowCount( routeData.count() );
81 for ( int i=0; i<routeData.count(); i++ ) {
82 QTableWidgetItem *timeItem = new QTableWidgetItem( routeData.at(i).arrivalTime );
83 ui->table->setItem( i, 0, timeItem );
85 QTableWidgetItem *lineItem = new QTableWidgetItem( routeData.at(i).lineCode );
86 ui->table->setItem( i, 1, lineItem );
89 ui->table->resizeColumnsToContents();