X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=zouba%2Fuicontroller.cpp;h=891886aed332fc81f1d52fc56eea4ee4a72a250e;hb=d74ef6b41b59eef3192a30a77c552b9dcc400234;hp=9df97b2fca3f52b5ace795bbb0630f315de23931;hpb=d559f9332d2b5d523f0b47bef5b39c2639cb5de5;p=ptas diff --git a/zouba/uicontroller.cpp b/zouba/uicontroller.cpp index 9df97b2..891886a 100644 --- a/zouba/uicontroller.cpp +++ b/zouba/uicontroller.cpp @@ -1,32 +1,92 @@ #include "uicontroller.h" #include "route.h" #include "ui.h" +#include "ytv.h" +#include "location.h" +#include "messagetable.h" +#include "locations.h" #include #include #include #include +#include UiController::UiController( Ui *ui ) : ui(ui) { - connect( ui->trigger, SIGNAL( pressed() ), this, SIGNAL( homePressed() ) ); + Location *homeLocation = new Location( "home" ); + Location *workLocation = new Location( "work" ); + + Locations locations; + locations.addLocation( homeLocation ); + locations.addLocation( workLocation ); + + connect( + homeLocation, SIGNAL( becomeValid() ), + this, SLOT( setHomeButtonValid() ) + ); + connect( + workLocation, SIGNAL( becomeValid() ), + this, SLOT( setWorkButtonValid() ) + ); + + homeLocation->resolveAddress( Ytv::Home ); + workLocation->resolveAddress( Ytv::Work ); + + destination.append( homeLocation ); + destination.append( workLocation ); + + connect( + ui->destinationButtons, SIGNAL( buttonClicked( int ) ), + this, SLOT( changeDestination( int ) ) + ); } UiController::~UiController() { } -void UiController::displayRoute( const RouteData &routeData ) +void UiController::setHomeButtonValid() +{ + setButtonValid( Ui::HomeButtonId ); +} + +void UiController::setWorkButtonValid() +{ + setButtonValid( Ui::WorkButtonId ); +} + +void UiController::setButtonValid( int id ) +{ + ui->destinationButtons->button( id )->setEnabled(true); +} + +void UiController::changeDestination( int id ) +{ + qDebug() << "Button "+QString::number(id)+" clicked"; + + bool destinationHasChanged = ( currentDestination != id ); + if ( destinationHasChanged ) { + emit destinationChanged( destination[id] ); + } + + // always want to emit this so that the gps position is update + // and the user gets new information + emit buttonClicked(); +} + +void UiController::displayRoute( const QList &routeData ) { - qDebug() << __PRETTY_FUNCTION__; - qDebug() << "routeData.arrivalTime" << routeData.arrivalTime; - qDebug() << "routeData.lineCode" << routeData.lineCode; + qDebug() << "displaying route"; - QTableWidgetItem *timeItem = new QTableWidgetItem( routeData.arrivalTime ); - ui->table->setItem( 0, 0, timeItem ); + ui->routeTable->setRowCount( routeData.count() ); - QTableWidgetItem *lineItem = new QTableWidgetItem( routeData.lineCode ); - ui->table->setItem( 0, 1, lineItem ); + for ( int i=0; irouteTable->setItem( i, 0, timeItem ); + QTableWidgetItem *lineItem = new QTableWidgetItem( routeData.at(i).lineCode ); + ui->routeTable->setItem( i, 1, lineItem ); + } }