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);
42 setAttribute(Qt::WA_Maemo5AutoOrientation);
45 viewSelectionGroup->addAction(ui->sortByNameAction);
46 viewSelectionGroup->addAction(ui->sortNearFirstAction);
47 viewSelectionGroup->addAction(ui->sortRecentFirstAction);
48 QStringList stationList;
49 stationList << "Genova Voltri"
52 << "Genova Sestri Ponente"
53 << "Genova Cornigliano"
54 << "Genova Sampierdarena"
55 << "Genova Via di Francia"
56 << "Genova Piazza Principe"
59 << "Genova Quarto dei Mille"
60 << "Genova Quinto al Mare"
62 stationListModel->setStringList(stationList);
63 ui->listView->setModel(stationListModel);
64 ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
65 ui->listView->setSelectionMode(QAbstractItemView::SingleSelection);
68 SIGNAL(activated(QModelIndex)), SLOT(showStation(QModelIndex)));
71 StationListView::~StationListView()
76 void StationListView::showSettings(void)
78 qDebug() << "Show Settings";
79 SettingsDialog *settingsDialog = new SettingsDialog(this);
80 if (settingsDialog->exec() == QDialog::Accepted) {
81 // TODO Use new settings
84 delete settingsDialog;
87 void StationListView::showStation(const QModelIndex &index)
89 qDebug() << "Show Station" << index.data();
90 emit stationSelected(index.data().toString());