3 #include "messagetable.h"
7 #include <QRadioButton>
8 #include <QTableWidget>
11 #include <QButtonGroup>
12 #include <QHeaderView>
15 #include <QHBoxLayout>
16 #include <QVBoxLayout>
17 #include <QSizePolicy>
18 #include <QInputDialog>
21 MessageTable *Ui::messageTable = 0;
25 destinationButtons(0),
34 void Ui::setupUi( QMainWindow *mainWindow )
36 mainWindow->resize(800,480);
37 menu = mainWindow->menuBar()->addMenu("Settings");
39 QAction *setHomeAddressAction = new QAction("Set home address", this);
40 QAction *setWorkAddressAction = new QAction("Set work address", this);
41 hideMessagesAction = new QAction("Hide messages", this);
42 showMessagesAction = new QAction("Show messages", this);
43 menu->addAction(setHomeAddressAction);
44 menu->addAction(setWorkAddressAction);
45 menu->addAction(showMessagesAction);
48 setHomeAddressAction, SIGNAL(triggered()),
49 this, SLOT(setHomeAddress())
52 setWorkAddressAction, SIGNAL(triggered()),
53 this, SLOT(setWorkAddress())
56 hideMessagesAction, SIGNAL(triggered()),
57 this, SLOT(hideMessages())
60 showMessagesAction, SIGNAL(triggered()),
61 this, SLOT(showMessages())
64 centralWidget = new QWidget( mainWindow );
65 mainWindow->setCentralWidget(centralWidget);
67 QRadioButton *homeButton = new QRadioButton();
68 homeButton->setObjectName( QString::fromUtf8("homeButton") );
69 homeButton->setText( "GPS->HOME" );
70 homeButton->setEnabled(false);
71 homeButton->setFixedSize( QSize( ButtonWidth, ButtonHeight ) );
73 QRadioButton *workButton = new QRadioButton();
74 workButton->setObjectName( QString::fromUtf8("workButton") );
75 workButton->setText( "GPS->WORK" );
76 workButton->setEnabled(false);
78 destinationButtons = new QButtonGroup();
79 destinationButtons->addButton( homeButton, HomeButtonId );
80 destinationButtons->addButton( workButton, WorkButtonId );
81 destinationButtons->setExclusive( true );
83 buttonLayout = new QVBoxLayout();
84 buttonLayout->addWidget( homeButton );
85 buttonLayout->addWidget( workButton );
86 buttonLayout->addStretch();
88 routeTable = new QTableWidget( 1, 2 );
89 QStringList columnHeaders;
90 columnHeaders << "Time" << "Bus";
91 routeTable->setHorizontalHeaderLabels( columnHeaders );
92 routeTable->verticalHeader()->hide();
94 QHBoxLayout *topLayout = new QHBoxLayout();
95 topLayout->addLayout( buttonLayout );
96 topLayout->addWidget( routeTable );
98 messageTable = new MessageTable();
99 messageTable->setObjectName( QString::fromUtf8("messageTable") );
100 messageTable->hide();
102 QVBoxLayout *mainLayout = new QVBoxLayout();
103 mainLayout->addLayout( topLayout );
104 mainLayout->addWidget( messageTable );
106 centralWidget->setLayout( mainLayout );
109 void Ui::setHomeAddress()
111 setAddress( "home" );
114 void Ui::setWorkAddress()
116 setAddress( "work" );
119 void Ui::hideMessages()
121 messageTable->hide();
122 menu->removeAction( hideMessagesAction );
123 menu->addAction( showMessagesAction );
126 void Ui::showMessages()
128 messageTable->show();
129 menu->removeAction( showMessagesAction );
130 menu->addAction( hideMessagesAction );
133 void Ui::setAddress( const QString &label )
135 Locations *locations=Locations::instance();
136 Location *location=locations->location( label );
139 QString address = QInputDialog::getText(
141 tr("Enter address for \""+QString(label).toLatin1()+"\""),
148 qDebug() << "ok=" << ok;
151 qDebug() << "new address" << address;
152 Locations *locations = Locations::instance();
153 Location *location = locations->location( label );
154 qDebug() << "location" << location;
156 location->resolveAddress( address );