--- /dev/null
+/*
+
+Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+*/
+
+#include "app.h"
+#include "stationview.h"
+#include "stationlistview.h"
+#include "settingsdialog.h"
+
+#include <QDebug>
+#include <QMessageBox>
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
+#include <QNetworkRequest>
+#include <QObject>
+#include <QSettings>
+#include <QUrl>
+
+App::App(QObject *parent) :
+ QObject(parent),
+ accessManager(new QNetworkAccessManager(this)),
+ stationView(new StationView(NULL)),
+ stationListView(new StationListView(stationView))
+{
+ connect(stationListView, SIGNAL(stationSelected(const QString &)),
+ SLOT(queryStation(const QString &)));
+ connect(stationView, SIGNAL(aboutTriggered()),
+ SLOT(showAboutDialog()));
+ connect(stationView, SIGNAL(stationListSelectTriggered()),
+ SLOT(showStationSelectView()));
+
+ readSettings();
+
+#if defined(Q_WS_S60)
+ stationView->showMaximized();
+#else
+ stationView->show();
+#endif
+
+ if (stationName.isEmpty()) {
+#if defined(Q_WS_S60)
+ stationListView->showMaximized();
+#else
+ stationListView->show();
+#endif
+ }
+}
+
+void App::downloadFinished(void)
+{
+ disconnect(stationQueryReply, SIGNAL(finished()),
+ this, SLOT(downloadFinished()));
+ stationView->updateView(stationQueryReply->readAll());
+ stationListView->hide();
+ stationQueryReply->deleteLater();
+ stationQueryReply = 0;
+}
+
+void App::queryStation(const QString &station)
+{
+ QNetworkRequest request;
+ request.setUrl(queryBaseUrl);
+ const QString queryString = "stazione=" + station;
+ const QByteArray query(queryString.toLocal8Bit());
+ stationQueryReply = accessManager->post(request, query);
+ connect(stationQueryReply, SIGNAL(finished()),
+ this, SLOT(downloadFinished()));
+}
+
+void App::showSettingsDialog()
+{
+}
+
+void App::showAboutDialog()
+{
+ qDebug() << "About Dialog called";
+ QString name = QApplication::instance()->applicationName();
+ QString aboutText = QString(
+ tr("<p>%1</p>"
+ "<p>Copyright (c) 2010</p>"
+ "<p>Luciano Montanaro (mikelima@cirulla.net)</p>"
+ "<p>Licensed under the GNU Public License v2 or above</p>")).arg(name);
+ QMessageBox::about(stationView, name, aboutText);
+}
+
+void App::showStationSelectView(void)
+{
+ stationListView->show();
+}
+
+void App::readSettings(void)
+{
+ QSettings settings;
+ queryBaseUrl = settings.value("QueryURL",
+ "http://mobile.viaggiatreno.it/viaggiatreno/mobile/stazione").toString();
+ stationView->setBaseUrl(queryBaseUrl);
+
+ stationName = settings.value("CurrentStation").toString();
+ showingArrivals = settings.value("ShowingArrivals", false).toBool();
+ checkingInterval = settings.value("CheckInterval", 2000).toInt();
+}
+
+void App::saveSettings(void)
+{
+ QSettings settings;
+ settings.setValue("QueryURL", queryBaseUrl);
+ settings.value("CurrentStation", stationName);
+ settings.value("ShowingArrivals", showingArrivals);
+ settings.value("CheckInterval", checkingInterval);
+}
--- /dev/null
+#ifndef APPLICATION_H
+#define APPLICATION_H
+
+/*
+
+Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+*/
+
+#include <QApplication>
+
+class QNetworkAccessManager;
+class QNetworkReply;
+
+class StationView;
+class StationListView;
+
+class App : public QObject
+{
+ Q_OBJECT
+public:
+ explicit App(QObject *parent = 0);
+
+signals:
+
+public slots:
+ void queryStation(const QString &station);
+ void downloadFinished(void);
+ void showAboutDialog(void);
+ void showSettingsDialog(void);
+ void showStationSelectView(void);
+public:
+ void saveSettings(void);
+ void readSettings(void);
+private:
+ QNetworkAccessManager *accessManager;
+ QNetworkReply *stationQueryReply;
+ StationView *stationView;
+ StationListView *stationListView;
+ QString queryBaseUrl;
+ QString stationName;
+ bool showingArrivals;
+ int checkingInterval;
+};
+
+#endif // APPLICATION_H
--- /dev/null
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-11-13T19:51:39
+#
+#-------------------------------------------------
+
+QT += webkit network xml maemo5
+
+TARGET = quandoparte
+TEMPLATE = app
+
+SOURCES += main.cpp \
+ settingsdialog.cpp \
+ stationview.cpp \
+ app.cpp \
+ stationlistview.cpp
+
+HEADERS += \
+ settingsdialog.h \
+ stationview.h \
+ app.h \
+ stationlistview.h
+
+FORMS += \
+ settingsdialog.ui \
+ stationlistview.ui
+
+CONFIG += webkit mobility
+MOBILITY = location bearer
+
+symbian {
+ TARGET.UID3 = 0xe30fb688
+ # TARGET.CAPABILITY +=
+ TARGET.EPOCSTACKSIZE = 0x14000
+ TARGET.EPOCHEAPSIZE = 0x020000 0x800000
+}
+
+OTHER_FILES += \
+ debian/changelog \
+ debian/compat \
+ debian/control \
+ debian/copyright \
+ debian/README \
+ debian/rules \
+ quandoparte.desktop \
+ icons/quandoparte.png
+
+unix:!symbian {
+ maemo5 {
+ target.path = /opt/usr/bin
+ } else {
+ target.path = /usr/local/bin
+ }
+ INSTALLS += target
+}
+
+unix:!symbian {
+ desktopfile.files = $${TARGET}.desktop
+ maemo5 {
+ desktopfile.path = /usr/share/applications/hildon
+ } else {
+ desktopfile.path = /usr/share/applications
+ }
+ INSTALLS += desktopfile
+}
+
+unix:!symbian {
+ icon48.files = icons/48x48/$${TARGET}.png
+ icon64.files = icons/64x64/$${TARGET}.png
+ icon48.path = /usr/share/icons/hicolor/48x48/apps
+ icon64.path = /usr/share/icons/hicolor/64x64/apps
+ INSTALLS += icon48
+ INSTALLS += icon64
+}
--- /dev/null
+The Debian Package quandoparte
+----------------------------
+
+Comments regarding the Package
+
+ -- Luciano Montanaro <mikelima@zaphod> Sat, 20 Nov 2010 18:46:46 +0100
--- /dev/null
+quandoparte (0.0.1) unstable; urgency=low
+
+ * Initial Release.
+
+ -- Luciano Montanaro <mikelima@zaphod> Sat, 20 Nov 2010 18:46:46 +0100
--- /dev/null
+Source: quandoparte
+Section: user/hidden
+Priority: optional
+Maintainer: Luciano Montanaro <mikelima@zaphod>
+Build-Depends: debhelper (>= 5), libqt4-dev
+Standards-Version: 3.7.3
+Homepage: www.cirulla.net/quandoparte
+
+Package: arriviepartenze
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Virtual Arrivals and Departures board for Italian trains
+ ArriviEPartenze uses the Trenitalia data to show arrivals and departures times
+ of the trains of a given station, with delay or suppression information.
--- /dev/null
+This package was debianized by Luciano Montanaro <mikelima@cirulla.net> on
+Sat, 20 Nov 2010 18:46:46 +0100.
+
+It was downloaded from <url://example.com>
+
+Upstream Author(s):
+
+ Luciano Montanaro <mikelima@cirulla.net>
+
+Copyright:
+
+ Copyright (C) 2011 Luciano Montanaro
+
+License:
+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this package; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL'.
+
+The Debian packaging is (C) 2010, 2011, Luciano Montanaro <mikelima@zaphod> and
+is licensed under the GPL, see above.
+
+
+# Please also look if there are files or directories which have a
+# different copyright/license attached and list them here.
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+
+
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+
+ touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ $(MAKE)
+ #docbook-to-man debian/arriviepartenze.sgml > arriviepartenze.1
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ $(MAKE) clean
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/arriviepartenze.
+ $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/arriviepartenze install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+# dh_install
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ # dh_strip
+ dh_compress
+ dh_fixperms
+# dh_perl
+# dh_makeshlibs
+ dh_installdeb
+ # dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+/*
+
+Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+*/
+
+#include "app.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ a.setApplicationName("QuandoParte");
+ a.setOrganizationDomain("cirulla.net");
+
+ App theApp;
+
+ return a.exec();
+}
--- /dev/null
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Type=Application
+Terminal=false
+Name=Quando Parte
+Exec=/opt/usr/bin/quandoparte
+Icon=quandoparte
+X-Window-Icon=
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable
--- /dev/null
+/*
+
+Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+*/
+
+#include "settingsdialog.h"
+#include "ui_settingsdialog.h"
+
+#ifdef Q_WS_MAEMO_5
+#include <QMaemo5ValueButton>
+#endif
+
+
+SettingsDialog::SettingsDialog(QWidget *parent) :
+ QDialog(parent),
+#ifdef Q_WS_MAEMO_5
+ updateIntervalButton(new QMaemo5ValueButton(this)),
+#endif
+ ui(new Ui::SettingsDialog)
+{
+ ui->setupUi(this);
+#ifdef Q_WS_MAEMO_5
+ ui->formLayout->addWidget(updateIntervalButton);
+#endif
+}
+
+SettingsDialog::~SettingsDialog()
+{
+ delete ui;
+}
--- /dev/null
+#ifndef SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+#include <QDialog>
+
+#ifdef Q_WS_MAEMO_5
+class QMaemo5ValueButton;
+#endif
+
+namespace Ui {
+ class SettingsDialog;
+}
+
+class SettingsDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit SettingsDialog(QWidget *parent = 0);
+ ~SettingsDialog();
+
+private:
+#ifdef Q_WS_MAEMO_5
+ QMaemo5ValueButton *updateIntervalButton;
+#endif
+ Ui::SettingsDialog *ui;
+};
+
+#endif // SETTINGSDIALOG_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SettingsDialog</class>
+ <widget class="QDialog" name="SettingsDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>361</width>
+ <height>91</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QFormLayout" name="formLayout">
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Station:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="1">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>SettingsDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>SettingsDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+/*
+
+Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+*/
+
+#include "stationlistview.h"
+#include "ui_stationlistview.h"
+
+#include "settingsdialog.h"
+#include "stationview.h"
+
+#include <QActionGroup>
+#include <QDebug>
+#include <QStringListModel>
+
+StationListView::StationListView(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::StationListView),
+ viewSelectionGroup(new QActionGroup(0)),
+ stationListModel(new QStringListModel()),
+ stationView(0)
+
+{
+#ifdef Q_WS_MAEMO_5
+ setAttribute(Qt::WA_Maemo5StackedWindow);
+#endif
+ ui->setupUi(this);
+ viewSelectionGroup->addAction(ui->sortByNameAction);
+ viewSelectionGroup->addAction(ui->sortNearFirstAction);
+ viewSelectionGroup->addAction(ui->sortRecentFirstAction);
+ QStringList stationList;
+ stationList << "Genova Voltri"
+ << "Genova Pra"
+ << "Genova Pegli"
+ << "Genova Sestri Ponente"
+ << "Genova Cornigliano"
+ << "Genova Sampierdarena"
+ << "Genova Via di Francia"
+ << "Genova Piazza Principe"
+ << "Genova Brignole"
+ << "Genova Sturla"
+ << "Genova Quarto dei Mille"
+ << "Genova Quinto al Mare"
+ << "Genova Nervi";
+ stationListModel->setStringList(stationList);
+ ui->listView->setModel(stationListModel);
+ ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ ui->listView->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ connect(ui->listView,
+ SIGNAL(activated(QModelIndex)), SLOT(showStation(QModelIndex)));
+}
+
+StationListView::~StationListView()
+{
+ delete ui;
+}
+
+void StationListView::showSettings(void)
+{
+ qDebug() << "Show Settings";
+ SettingsDialog *settingsDialog = new SettingsDialog(this);
+ if (settingsDialog->exec() == QDialog::Accepted) {
+ // TODO Use new settings
+ }
+
+ delete settingsDialog;
+}
+
+void StationListView::showStation(const QModelIndex &index)
+{
+ qDebug() << "Show Station" << index.data();
+ emit stationSelected(index.data().toString());
+}
--- /dev/null
+#ifndef STATIONLISTVIEW_H
+#define STATIONLISTVIEW_H
+
+#include <QMainWindow>
+#include <QModelIndex>
+
+namespace Ui {
+ class StationListView;
+}
+
+class QActionGroup;
+class QStringListModel;
+
+class StationView;
+
+class StationListView : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit StationListView(QWidget *parent = 0);
+ ~StationListView();
+
+signals:
+ void stationSelected(const QString &);
+
+private slots:
+ void showSettings(void);
+ void showStation(const QModelIndex &index);
+
+private:
+ Ui::StationListView *ui;
+ QActionGroup *viewSelectionGroup;
+ QStringListModel *stationListModel;
+ StationView *stationView;
+};
+
+#endif // STATIONLISTVIEW_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>StationListView</class>
+ <widget class="QMainWindow" name="StationListView">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>786</width>
+ <height>466</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string/>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QListView" name="listView"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>786</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuView">
+ <property name="title">
+ <string>View</string>
+ </property>
+ <addaction name="sortByNameAction"/>
+ <addaction name="sortNearFirstAction"/>
+ <addaction name="sortRecentFirstAction"/>
+ <addaction name="separator"/>
+ <addaction name="showSettingsAction"/>
+ <addaction name="showAboutAction"/>
+ </widget>
+ <addaction name="menuView"/>
+ </widget>
+ <action name="sortNearFirstAction">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Near</string>
+ </property>
+ <property name="toolTip">
+ <string>Show near stations first</string>
+ </property>
+ </action>
+ <action name="sortByNameAction">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>ABC</string>
+ </property>
+ <property name="toolTip">
+ <string>Sort stations by name</string>
+ </property>
+ </action>
+ <action name="showSettingsAction">
+ <property name="text">
+ <string>Settings</string>
+ </property>
+ </action>
+ <action name="showAboutAction">
+ <property name="text">
+ <string>About</string>
+ </property>
+ </action>
+ <action name="sortRecentFirstAction">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Recent</string>
+ </property>
+ <property name="toolTip">
+ <string>Show recently checked stations first</string>
+ </property>
+ </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+/*
+
+Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+*/
+
+#include "stationview.h"
+
+#include <QAction>
+#include <QActionGroup>
+#include <QDebug>
+#include <QMenu>
+#include <QMenuBar>
+#include <QWebView>
+
+StationView::StationView(QWidget *parent) :
+ QMainWindow(parent),
+ theStation(""),
+ showArrivalsAction(new QAction(tr("Arrivals"), this)),
+ showDeparturesAction(new QAction(tr("Departures"), this)),
+ showSettingsAction(new QAction(tr("Settings"), this)),
+ showStationListSelectAction(new QAction(tr("Change Station"), this)),
+ showAboutAction(new QAction(tr("About"), this)),
+ viewSelectionGroup(new QActionGroup(this)),
+ menuBar(new QMenuBar(this)),
+ menu(new QMenu(menuBar)),
+ view(new QWebView(this))
+{
+ showArrivalsAction->setCheckable(true);
+ showDeparturesAction->setCheckable(true);
+ showDeparturesAction->setChecked(true);
+ viewSelectionGroup->addAction(showArrivalsAction);
+ viewSelectionGroup->addAction(showDeparturesAction);
+ menu->addAction(showDeparturesAction);
+ menu->addAction(showArrivalsAction);
+ menu->addAction(showStationListSelectAction);
+ menu->addAction(showSettingsAction);
+ menu->addAction(showAboutAction);
+ menuBar->addAction(menu->menuAction());
+ setMenuBar(menuBar);
+ view->setTextSizeMultiplier(2.0);
+ connect(showAboutAction, SIGNAL(triggered()), this, SIGNAL(aboutTriggered()));
+ connect(showSettingsAction, SIGNAL(triggered()), this, SIGNAL(settingsTriggered()));
+ connect(showStationListSelectAction, SIGNAL(triggered()), this, SIGNAL(stationListSelectTriggered()));
+ setCentralWidget(view);
+#ifdef Q_WS_MAEMO_5
+ setAttribute(Qt::WA_Maemo5StackedWindow);
+#endif
+}
+
+void StationView::setStation(const QString &station)
+{
+ setWindowTitle(station);
+ theStation = station;
+}
+
+void StationView::changeView(void)
+{
+ qDebug() << "View Changed";
+ if (showArrivalsAction->isChecked()) {
+ qDebug() << "Showing Arrivals";
+ } else {
+ qDebug() << "Showing Departures";
+ }
+}
+
+void StationView::setBaseUrl(const QUrl &baseUrl)
+{
+ theBaseUrl = baseUrl;
+}
+
+void StationView::updateView(const QByteArray &page)
+{
+ qDebug() << page;
+ view->setContent(page, "text/html", theBaseUrl);
+}
--- /dev/null
+#ifndef STATIONVIEW_H
+#define STATIONVIEW_H
+
+#include <QMainWindow>
+#include <QUrl>
+
+class QAction;
+class QActionGroup;
+class QWebView;
+
+class StationView : public QMainWindow
+{
+ Q_OBJECT
+public:
+ explicit StationView(QWidget *parent = 0);
+
+ void setStation(const QString &station);
+ void setBaseUrl(const QUrl &theBaseUrl);
+
+signals:
+ void aboutTriggered(void);
+ void settingsTriggered(void);
+ void stationListSelectTriggered(void);
+
+public slots:
+ void updateView(const QByteArray &page);
+
+private slots:
+ void changeView(void);
+
+private:
+ QString theStation;
+ QUrl theBaseUrl;
+ QAction *showArrivalsAction;
+ QAction *showDeparturesAction;
+ QAction *showSettingsAction;
+ QAction *showStationListSelectAction;
+ QAction *showAboutAction;
+ QActionGroup *viewSelectionGroup;
+ QMenuBar *menuBar;
+ QMenu *menu;
+ QWebView *view;
+};
+
+#endif // STATIONVIEW_H
--- /dev/null
+TEMPLATE = subdirs
+
+SUBDIRS = application \
+ test
--- /dev/null
+#-------------------------------------------------
+#
+# Project created by QtCreator 2011-05-08T17:25:28
+#
+#-------------------------------------------------
+
+QT += network webkit xml testlib
+
+TARGET = tst_quandopartetest
+CONFIG += console
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+
+SOURCES += \
+ tst_app.cpp
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+unix:!symbian {
+ maemo5 {
+ target.path = /opt/usr/bin
+ } else {
+ target.path = /usr/local/bin
+ }
+ INSTALLS += target
+}
--- /dev/null
+/*
+
+Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+*/
+
+#include <QtCore/QString>
+#include <QtTest/QtTest>
+#include <QtCore/QCoreApplication>
+
+class AppTest : public QObject
+{
+ Q_OBJECT
+
+public:
+ AppTest();
+
+private Q_SLOTS:
+ void initTestCase();
+ void cleanupTestCase();
+ void testCase1();
+ void testCase1_data();
+};
+
+AppTest::AppTest()
+{
+}
+
+void AppTest::initTestCase()
+{
+}
+
+void AppTest::cleanupTestCase()
+{
+}
+
+void AppTest::testCase1()
+{
+ QFETCH(QString, data);
+ QVERIFY2(true, "Failure");
+}
+
+void AppTest::testCase1_data()
+{
+ QTest::addColumn<QString>("data");
+ QTest::newRow("0") << QString();
+}
+
+QTEST_MAIN(AppTest);
+
+#include "tst_app.moc"