3 #include "messagetable.h"
8 #include <QRadioButton>
9 #include <QTableWidget>
12 #include <QButtonGroup>
13 #include <QHeaderView>
16 #include <QHBoxLayout>
17 #include <QVBoxLayout>
18 #include <QGridLayout>
19 #include <QSizePolicy>
20 #include <QInputDialog>
23 MessageTable *Ui::messageTable = 0;
27 destinationButtons(0),
29 usingFakeGps( false ),
30 messagesShown( false ),
31 fakeLocationLabel( "work" )
39 void Ui::setupUi( QMainWindow *mainWindow )
41 mainWindow->resize(800,480);
42 menu = mainWindow->menuBar()->addMenu("Settings");
44 QAction *setHomeAddressAction = new QAction("Set home address", this);
45 QAction *setWorkAddressAction = new QAction("Set work address", this);
46 toggleMessagesAction = new QAction("Show messages", this);
47 toggleFakeGpsAction = new QAction("Use fake GPS", this);
48 menu->addAction(setHomeAddressAction);
49 menu->addAction(setWorkAddressAction);
50 menu->addAction(toggleMessagesAction);
51 menu->addAction(toggleFakeGpsAction);
54 setHomeAddressAction, SIGNAL(triggered()),
55 this, SLOT(setHomeAddress())
58 setWorkAddressAction, SIGNAL(triggered()),
59 this, SLOT(setWorkAddress())
62 toggleMessagesAction, SIGNAL(triggered()),
63 this, SLOT(toggleMessages())
66 toggleFakeGpsAction, SIGNAL(triggered()),
67 this, SLOT(toggleFakeGps())
70 centralWidget = new QWidget( mainWindow );
71 mainWindow->setCentralWidget(centralWidget);
73 QRadioButton *homeButton = new QRadioButton();
74 homeButton->setObjectName( QString::fromUtf8("homeButton") );
75 homeButton->setText( "GPS->HOME" );
76 homeButton->setEnabled(false);
78 QRadioButton *workButton = new QRadioButton();
79 workButton->setObjectName( QString::fromUtf8("workButton") );
80 workButton->setText( "GPS->WORK" );
81 workButton->setEnabled(false);
83 destinationButtons = new QButtonGroup();
84 destinationButtons->addButton( homeButton, HomeButtonId );
85 destinationButtons->addButton( workButton, WorkButtonId );
86 destinationButtons->setExclusive( true );
88 routeStack = new QVBoxLayout();
89 for ( int i=0; i<Ytv::ShowFiveResults; ++i ) {
90 QRadioButton *button = new QRadioButton();
91 button->setObjectName( "routeButton"+i );
92 button->setEnabled( false );
94 routeStack->addWidget( button, i );
96 routeStack->addStretch();
98 QHBoxLayout *topLayout = new QHBoxLayout();
99 topLayout->addLayout( routeStack );
100 topLayout->addStretch();
102 buttonLayout = new QGridLayout();
103 buttonLayout->addWidget( homeButton, 0, 0 );
104 buttonLayout->addWidget( workButton, 0, 1 );
106 messageTable = new MessageTable();
107 messageTable->setObjectName( QString::fromUtf8("messageTable") );
108 messageTable->hide();
110 QVBoxLayout *mainLayout = new QVBoxLayout();
111 mainLayout->addLayout( topLayout );
112 mainLayout->addWidget( messageTable );
113 mainLayout->addLayout( buttonLayout );
115 centralWidget->setLayout( mainLayout );
118 void Ui::setHomeAddress()
120 setAddress( "home" );
123 void Ui::setWorkAddress()
125 setAddress( "work" );
128 void Ui::toggleMessages()
130 messagesShown = !messagesShown;
132 if ( messagesShown ) {
139 void Ui::hideMessages()
141 messageTable->hide();
142 toggleMessagesAction->setText( "Show messages" );
145 void Ui::showMessages()
147 messageTable->show();
148 toggleMessagesAction->setText( "Hide messages" );
151 void Ui::toggleFakeGps()
153 usingFakeGps = !usingFakeGps;
155 if ( usingFakeGps ) {
162 void Ui::useFakeGps()
164 emit fakeGpsPressed( fakeLocationLabel );
165 toggleFakeGpsAction->setText( "Use Live GPS" );
168 void Ui::useLiveGps()
170 emit liveGpsPressed();
171 toggleFakeGpsAction->setText( "Use Fake GPS" );
174 void Ui::setAddress( const QString &label )
176 Locations *locations=Locations::instance();
177 Location *location=locations->location( label );
180 QString address = QInputDialog::getText(
182 tr("Enter address for \""+QString(label).toLatin1()+"\""),
190 qDebug() << "new address" << address;
191 Locations *locations = Locations::instance();
192 Location *location = locations->location( label );
193 qDebug() << "location" << location;
195 location->resolveAddress( address );