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 m_routeDetailTable = new QTableWidget();
94 m_routeDetailTable->setColumnCount(6);
96 QHBoxLayout *topLayout = new QHBoxLayout();
97 topLayout->addLayout( m_routeStack );
98 topLayout->addWidget( m_routeDetailTable );
100 m_buttonLayout = new QGridLayout();
101 m_buttonLayout->addWidget( homeButton, 0, 0 );
102 m_buttonLayout->addWidget( workButton, 0, 1 );
104 m_mainLayout = new QVBoxLayout();
105 m_mainLayout->addLayout( topLayout );
106 m_mainLayout->addLayout( m_buttonLayout );
108 m_centralWidget->setLayout( m_mainLayout );
111 void Ui::setHomeAddress()
113 setAddress( "home" );
116 void Ui::setWorkAddress()
118 setAddress( "work" );
121 void Ui::toggleFakeGps()
123 m_usingFakeGps = !m_usingFakeGps;
125 if ( m_usingFakeGps ) {
132 void Ui::useFakeGps()
134 emit fakeGpsPressed( m_fakeLocationLabel );
135 m_toggleFakeGpsAction->setText( "Use Live GPS" );
138 void Ui::useLiveGps()
140 emit liveGpsPressed();
141 m_toggleFakeGpsAction->setText( "Use Fake GPS" );
144 void Ui::setAddress( const QString &label )
146 Locations *locations=Locations::instance();
147 Location *location=locations->location( label );
150 QString address = QInputDialog::getText(
152 tr("Enter address for \""+QString(label).toLatin1()+"\""),
160 qDebug() << "new address" << address;
161 Locations *locations = Locations::instance();
162 Location *location = locations->location( label );
163 qDebug() << "location" << location;
165 location->resolveAddress( address );
170 void Ui::setBusy( bool busy )
172 m_mainWindow->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, busy);