3 Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 #include "stationlistview.h"
23 #include "ui_stationlistview.h"
25 #include "settingsdialog.h"
26 #include "stationview.h"
28 #include <QActionGroup>
30 #include <QStringListModel>
32 StationListView::StationListView(QWidget *parent) :
34 ui(new Ui::StationListView),
35 viewSelectionGroup(new QActionGroup(0)),
36 stationListModel(new QStringListModel()),
41 setAttribute(Qt::WA_Maemo5StackedWindow);
44 viewSelectionGroup->addAction(ui->sortByNameAction);
45 viewSelectionGroup->addAction(ui->sortNearFirstAction);
46 viewSelectionGroup->addAction(ui->sortRecentFirstAction);
47 QStringList stationList;
48 stationList << "Genova Voltri"
51 << "Genova Sestri Ponente"
52 << "Genova Cornigliano"
53 << "Genova Sampierdarena"
54 << "Genova Via di Francia"
55 << "Genova Piazza Principe"
58 << "Genova Quarto dei Mille"
59 << "Genova Quinto al Mare"
61 stationListModel->setStringList(stationList);
62 ui->listView->setModel(stationListModel);
63 ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
64 ui->listView->setSelectionMode(QAbstractItemView::SingleSelection);
67 SIGNAL(activated(QModelIndex)), SLOT(showStation(QModelIndex)));
70 StationListView::~StationListView()
75 void StationListView::showSettings(void)
77 qDebug() << "Show Settings";
78 SettingsDialog *settingsDialog = new SettingsDialog(this);
79 if (settingsDialog->exec() == QDialog::Accepted) {
80 // TODO Use new settings
83 delete settingsDialog;
86 void StationListView::showStation(const QModelIndex &index)
88 qDebug() << "Show Station" << index.data();
89 emit stationSelected(index.data().toString());