From: Luciano Montanaro Date: Sun, 8 May 2011 21:04:26 +0000 (+0200) Subject: Initial version X-Git-Tag: tags/0.3.4~55 X-Git-Url: http://git.maemo.org/git/?p=quandoparte;a=commitdiff_plain;h=14257f3b481d28bb989cd673c0287f92e98475c1 Initial version --- 14257f3b481d28bb989cd673c0287f92e98475c1 diff --git a/application/app.cpp b/application/app.cpp new file mode 100644 index 0000000..97ab0d9 --- /dev/null +++ b/application/app.cpp @@ -0,0 +1,127 @@ +/* + +Copyright (C) 2011 Luciano Montanaro + +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 +#include +#include +#include +#include +#include +#include +#include + +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("

%1

" + "

Copyright (c) 2010

" + "

Luciano Montanaro (mikelima@cirulla.net)

" + "

Licensed under the GNU Public License v2 or above

")).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); +} diff --git a/application/app.h b/application/app.h new file mode 100644 index 0000000..b37abca --- /dev/null +++ b/application/app.h @@ -0,0 +1,61 @@ +#ifndef APPLICATION_H +#define APPLICATION_H + +/* + +Copyright (C) 2011 Luciano Montanaro + +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 + +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 diff --git a/application/application.pro b/application/application.pro new file mode 100644 index 0000000..4356f16 --- /dev/null +++ b/application/application.pro @@ -0,0 +1,74 @@ +#------------------------------------------------- +# +# 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 +} diff --git a/application/debian/README b/application/debian/README new file mode 100644 index 0000000..5649311 --- /dev/null +++ b/application/debian/README @@ -0,0 +1,6 @@ +The Debian Package quandoparte +---------------------------- + +Comments regarding the Package + + -- Luciano Montanaro Sat, 20 Nov 2010 18:46:46 +0100 diff --git a/application/debian/changelog b/application/debian/changelog new file mode 100644 index 0000000..de379bc --- /dev/null +++ b/application/debian/changelog @@ -0,0 +1,5 @@ +quandoparte (0.0.1) unstable; urgency=low + + * Initial Release. + + -- Luciano Montanaro Sat, 20 Nov 2010 18:46:46 +0100 diff --git a/application/debian/compat b/application/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/application/debian/compat @@ -0,0 +1 @@ +7 diff --git a/application/debian/control b/application/debian/control new file mode 100644 index 0000000..36e400c --- /dev/null +++ b/application/debian/control @@ -0,0 +1,14 @@ +Source: quandoparte +Section: user/hidden +Priority: optional +Maintainer: Luciano Montanaro +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. diff --git a/application/debian/copyright b/application/debian/copyright new file mode 100644 index 0000000..a1f9597 --- /dev/null +++ b/application/debian/copyright @@ -0,0 +1,38 @@ +This package was debianized by Luciano Montanaro on +Sat, 20 Nov 2010 18:46:46 +0100. + +It was downloaded from + +Upstream Author(s): + + Luciano Montanaro + +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 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. diff --git a/application/debian/rules b/application/debian/rules new file mode 100755 index 0000000..457c60d --- /dev/null +++ b/application/debian/rules @@ -0,0 +1,91 @@ +#!/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 diff --git a/application/icons/48x48/quandoparte.png b/application/icons/48x48/quandoparte.png new file mode 100644 index 0000000..36d0484 Binary files /dev/null and b/application/icons/48x48/quandoparte.png differ diff --git a/application/icons/64x64/quandoparte.png b/application/icons/64x64/quandoparte.png new file mode 100644 index 0000000..6a1ff25 Binary files /dev/null and b/application/icons/64x64/quandoparte.png differ diff --git a/application/main.cpp b/application/main.cpp new file mode 100644 index 0000000..91f0aef --- /dev/null +++ b/application/main.cpp @@ -0,0 +1,35 @@ +/* + +Copyright (C) 2011 Luciano Montanaro + +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 + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + a.setApplicationName("QuandoParte"); + a.setOrganizationDomain("cirulla.net"); + + App theApp; + + return a.exec(); +} diff --git a/application/quandoparte.desktop b/application/quandoparte.desktop new file mode 100644 index 0000000..e35e23d --- /dev/null +++ b/application/quandoparte.desktop @@ -0,0 +1,11 @@ +[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 diff --git a/application/settingsdialog.cpp b/application/settingsdialog.cpp new file mode 100644 index 0000000..ff5e0a4 --- /dev/null +++ b/application/settingsdialog.cpp @@ -0,0 +1,46 @@ +/* + +Copyright (C) 2011 Luciano Montanaro + +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 +#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; +} diff --git a/application/settingsdialog.h b/application/settingsdialog.h new file mode 100644 index 0000000..6e7c37f --- /dev/null +++ b/application/settingsdialog.h @@ -0,0 +1,29 @@ +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include + +#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 diff --git a/application/settingsdialog.ui b/application/settingsdialog.ui new file mode 100644 index 0000000..6fad889 --- /dev/null +++ b/application/settingsdialog.ui @@ -0,0 +1,78 @@ + + + SettingsDialog + + + + 0 + 0 + 361 + 91 + + + + Dialog + + + + + + + + + + + Station: + + + + + + + + + Qt::Vertical + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + SettingsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + SettingsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/application/stationlistview.cpp b/application/stationlistview.cpp new file mode 100644 index 0000000..05b0924 --- /dev/null +++ b/application/stationlistview.cpp @@ -0,0 +1,90 @@ +/* + +Copyright (C) 2011 Luciano Montanaro + +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 +#include +#include + +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()); +} diff --git a/application/stationlistview.h b/application/stationlistview.h new file mode 100644 index 0000000..f8cd371 --- /dev/null +++ b/application/stationlistview.h @@ -0,0 +1,38 @@ +#ifndef STATIONLISTVIEW_H +#define STATIONLISTVIEW_H + +#include +#include + +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 diff --git a/application/stationlistview.ui b/application/stationlistview.ui new file mode 100644 index 0000000..79ed0a4 --- /dev/null +++ b/application/stationlistview.ui @@ -0,0 +1,92 @@ + + + StationListView + + + + 0 + 0 + 786 + 466 + + + + + + + + + + + + + + + + 0 + 0 + 786 + 25 + + + + + View + + + + + + + + + + + + + true + + + Near + + + Show near stations first + + + + + true + + + ABC + + + Sort stations by name + + + + + Settings + + + + + About + + + + + true + + + Recent + + + Show recently checked stations first + + + + + + + diff --git a/application/stationview.cpp b/application/stationview.cpp new file mode 100644 index 0000000..4a8e355 --- /dev/null +++ b/application/stationview.cpp @@ -0,0 +1,91 @@ +/* + +Copyright (C) 2011 Luciano Montanaro + +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 +#include +#include +#include +#include +#include + +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); +} diff --git a/application/stationview.h b/application/stationview.h new file mode 100644 index 0000000..9c1715e --- /dev/null +++ b/application/stationview.h @@ -0,0 +1,45 @@ +#ifndef STATIONVIEW_H +#define STATIONVIEW_H + +#include +#include + +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 diff --git a/quandoparte.pro b/quandoparte.pro new file mode 100644 index 0000000..80c03bc --- /dev/null +++ b/quandoparte.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs + +SUBDIRS = application \ + test diff --git a/test/test.pro b/test/test.pro new file mode 100644 index 0000000..2e02a2e --- /dev/null +++ b/test/test.pro @@ -0,0 +1,27 @@ +#------------------------------------------------- +# +# 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 +} diff --git a/test/tst_app.cpp b/test/tst_app.cpp new file mode 100644 index 0000000..7185c74 --- /dev/null +++ b/test/tst_app.cpp @@ -0,0 +1,66 @@ +/* + +Copyright (C) 2011 Luciano Montanaro + +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 +#include +#include + +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("data"); + QTest::newRow("0") << QString(); +} + +QTEST_MAIN(AppTest); + +#include "tst_app.moc"