Changes: Changed the route table to a layout of buttons and tamed the layouts a bit.
[ptas] / zouba / src / ui.cpp
index 7660ee0..1b6784f 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "messagetable.h"
 #include "locations.h"
+#include "ytv.h"
 
 #include <QMainWindow>
 #include <QRadioButton>
@@ -14,6 +15,7 @@
 #include <QMenuBar>
 #include <QHBoxLayout>
 #include <QVBoxLayout>
+#include <QGridLayout>
 #include <QSizePolicy>
 #include <QInputDialog>
 #include <QDebug>
@@ -23,16 +25,11 @@ MessageTable *Ui::messageTable = 0;
 Ui::Ui() :
   centralWidget(0),
   destinationButtons(0),
-  routeTable(0),
+  routeStack(0),
   usingFakeGps( false ),
   messagesShown( false ),
-  fakeLocation()
+  fakeLocationLabel( "work" )
 {
-  Locations *locations = Locations::instance();
-  Location *workLocation = locations->location( "work" );
-  fakeLocation = new Location();
-  *fakeLocation = *workLocation;
-  fakeLocation->setLabel( "fakegps" );
 }
 
 Ui::~Ui()
@@ -77,7 +74,6 @@ void Ui::setupUi( QMainWindow *mainWindow )
   homeButton->setObjectName( QString::fromUtf8("homeButton") );
   homeButton->setText( "GPS->HOME" );
   homeButton->setEnabled(false);
-  homeButton->setFixedSize( QSize( ButtonWidth, ButtonHeight ) );
 
   QRadioButton *workButton = new QRadioButton();
   workButton->setObjectName( QString::fromUtf8("workButton") );
@@ -89,20 +85,23 @@ void Ui::setupUi( QMainWindow *mainWindow )
   destinationButtons->addButton( workButton, WorkButtonId );
   destinationButtons->setExclusive( true );
 
-  buttonLayout = new QVBoxLayout();
-  buttonLayout->addWidget( homeButton );
-  buttonLayout->addWidget( workButton );
-  buttonLayout->addStretch();
+  routeStack = new QVBoxLayout();
+  for ( int i=0; i<Ytv::ShowFiveResults; ++i ) {
+    QRadioButton *button = new QRadioButton();
+    button->setObjectName( "routeButton"+i );
+    button->setEnabled( false );
 
-  routeTable = new QTableWidget( 1, 2 );
-  QStringList columnHeaders;
-  columnHeaders << "Time" << "Bus";
-  routeTable->setHorizontalHeaderLabels( columnHeaders );
-  routeTable->verticalHeader()->hide();
+    routeStack->addWidget( button, i );
+  }
+  routeStack->addStretch();
 
   QHBoxLayout *topLayout = new QHBoxLayout();
-  topLayout->addLayout( buttonLayout );
-  topLayout->addWidget( routeTable );
+  topLayout->addLayout( routeStack );
+  topLayout->addStretch();
+
+  buttonLayout = new QGridLayout();
+  buttonLayout->addWidget( homeButton, 0, 0 );
+  buttonLayout->addWidget( workButton, 0, 1 );
 
   messageTable = new MessageTable();
   messageTable->setObjectName( QString::fromUtf8("messageTable") );
@@ -111,6 +110,7 @@ void Ui::setupUi( QMainWindow *mainWindow )
   QVBoxLayout *mainLayout = new QVBoxLayout();
   mainLayout->addLayout( topLayout );
   mainLayout->addWidget( messageTable );
+  mainLayout->addLayout( buttonLayout );
 
   centralWidget->setLayout( mainLayout );
 }
@@ -161,7 +161,7 @@ void Ui::toggleFakeGps()
 
 void Ui::useFakeGps()
 {
-  emit fakeGpsPressed( fakeLocation );
+  emit fakeGpsPressed( fakeLocationLabel );
   toggleFakeGpsAction->setText( "Use Live GPS" );
 }