7 #include <QRadioButton>
8 #include <QTableWidget>
11 #include <QButtonGroup>
12 #include <QHeaderView>
15 #include <QHBoxLayout>
16 #include <QVBoxLayout>
17 #include <QGridLayout>
18 #include <QSizePolicy>
19 #include <QInputDialog>
24 m_destinationButtons(0),
26 m_usingFakeGps(false),
27 m_fakeLocationLabel("work")
35 void Ui::setupUi(QMainWindow *mainWindow)
37 m_mainWindow = mainWindow;
38 m_mainWindow->resize(800,480);
40 m_menu = mainWindow->menuBar()->addMenu("Settings");
42 QAction *setHomeAddressAction = new QAction("Set home address", this);
43 QAction *setWorkAddressAction = new QAction("Set work address", this);
44 m_toggleFakeGpsAction = new QAction("Use fake GPS", this);
45 m_menu->addAction(setHomeAddressAction);
46 m_menu->addAction(setWorkAddressAction);
47 m_menu->addAction(m_toggleFakeGpsAction);
50 setHomeAddressAction, SIGNAL(triggered()),
51 this, SLOT(setHomeAddress())
54 setWorkAddressAction, SIGNAL(triggered()),
55 this, SLOT(setWorkAddress())
58 m_toggleFakeGpsAction, SIGNAL(triggered()),
59 this, SLOT(toggleFakeGps())
62 m_centralWidget = new QWidget(m_mainWindow);
63 m_mainWindow->setCentralWidget(m_centralWidget);
65 QRadioButton *homeButton = new QRadioButton();
66 homeButton->setObjectName(QString::fromUtf8("homeButton"));
67 homeButton->setText("GPS->HOME");
68 homeButton->setEnabled(false);
70 QRadioButton *workButton = new QRadioButton();
71 workButton->setObjectName(QString::fromUtf8("workButton"));
72 workButton->setText("GPS->WORK");
73 workButton->setEnabled(false);
75 m_destinationButtons = new QButtonGroup();
76 m_destinationButtons->addButton(homeButton, HomeButtonId);
77 m_destinationButtons->addButton(workButton, WorkButtonId);
78 m_destinationButtons->setExclusive(true);
80 m_routeButtons = new QButtonGroup();
81 m_routeButtons->setExclusive(true);
82 m_routeStack = new QVBoxLayout();
83 for (int i=0; i<Ytv::ShowFiveResults; ++i) {
84 QRadioButton *button = new QRadioButton();
85 button->setObjectName("routeButton"+i);
86 button->setEnabled(false);
88 m_routeStack->addWidget(button, i);
89 m_routeButtons->addButton(button, i);
91 m_routeStack->addStretch();
93 QStringList headers(QStringList() << "How" << "Time" << "Dist" << "Dep" << "Arr");
94 m_routeDetailTable = new QTableWidget();
95 m_routeDetailTable->setColumnCount(headers.count());
96 m_routeDetailTable->setHorizontalHeaderLabels(headers);
97 m_routeDetailTable->resizeColumnsToContents();
98 m_routeDetailTable->setSelectionMode(QAbstractItemView::NoSelection);
100 QHBoxLayout *topLayout = new QHBoxLayout();
101 topLayout->addLayout(m_routeStack);
102 topLayout->addWidget(m_routeDetailTable);
104 m_buttonLayout = new QGridLayout();
105 m_buttonLayout->addWidget(homeButton, 0, 0);
106 m_buttonLayout->addWidget(workButton, 0, 1);
108 m_mainLayout = new QVBoxLayout();
109 m_mainLayout->addLayout(topLayout);
110 m_mainLayout->addLayout(m_buttonLayout);
112 m_centralWidget->setLayout(m_mainLayout);
115 void Ui::setHomeAddress()
120 void Ui::setWorkAddress()
125 void Ui::toggleFakeGps()
127 m_usingFakeGps = !m_usingFakeGps;
129 if (m_usingFakeGps) {
136 void Ui::useFakeGps()
138 emit fakeGpsPressed(m_fakeLocationLabel);
139 m_toggleFakeGpsAction->setText("Use Live GPS");
142 void Ui::useLiveGps()
144 emit liveGpsPressed();
145 m_toggleFakeGpsAction->setText("Use Fake GPS");
148 void Ui::setAddress(const QString &label)
151 Location *location=locations.location(label);
154 QString address = QInputDialog::getText(
156 tr("Enter address for \""+QString(label).toLatin1()+"\""),
164 qDebug() << "new address" << address;
166 Location *location = locations.location(label);
167 qDebug() << "location" << location;
169 location->resolveAddress(address);
174 void Ui::setBusy(bool busy)
176 m_mainWindow->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, busy);