From 3406287d71dac0a117ba8714f2d85bb67fbbec45 Mon Sep 17 00:00:00 2001 From: Max Waterman Date: Sat, 17 Sep 2011 20:45:22 +0300 Subject: [PATCH] Incorporated changes from bus project. --- include/QGeoPositionInfo | 1 - include/QGeoPositionInfoSource | 1 - include/qgeocoordinate.h | 123 --- include/qgeopositioninfo.h | 120 --- include/qgeopositioninfosource.h | 105 -- include/qmobilityglobal.h | 188 ---- qtc_packaging/debian_fremantle/README | 6 + qtc_packaging/debian_fremantle/changelog | 5 + qtc_packaging/debian_fremantle/compat | 1 + qtc_packaging/debian_fremantle/control | 14 + qtc_packaging/debian_fremantle/copyright | 40 + qtc_packaging/debian_fremantle/rules | 91 ++ src/gpscontroller.cpp | 68 +- src/gpscontroller.h | 24 +- src/gpscontroller_p.cpp | 73 +- src/gpscontroller_p.h | 11 +- src/location.cpp | 344 ++---- src/location.h | 108 +- src/location_p.cpp | 134 ++- src/location_p.h | 43 +- src/locations.cpp | 122 +-- src/locations.h | 22 +- src/main.cpp | 76 +- src/route.cpp | 139 +-- src/route.h | 36 +- src/route_p.cpp | 202 +--- src/route_p.h | 38 +- src/routedata.h | 135 +-- src/ui.cpp | 234 ++-- src/ui.h | 72 +- src/uicontroller.cpp | 316 +++--- src/uicontroller.h | 41 +- src/xmlparser.cpp | 293 +++++ src/xmlparser.h | 40 + src/ytv.h | 54 +- tests/routeParserTest/main.cpp | 55 + tests/routeParserTest/routeParserTest.pro | 12 + tests/routeParserTest/routeResponse-2-pretty.xml | 258 +++++ tests/routeParserTest/routeResponse-2.xml | 1 + tests/routeParserTest/routeResponse-pretty.xml | 1159 ++++++++++++++++++++ tests/routeParserTest/routeResponse.xml | 1 + tests/testSummary | 310 ------ tests/tests.pri | 2 - tests/tests.pro | 9 - tests/ut_gpscontroller/ut_gpscontroller.cpp | 222 ---- tests/ut_gpscontroller/ut_gpscontroller.h | 35 - tests/ut_gpscontroller/ut_gpscontroller.pro | 44 - tests/ut_location/ut_location.cpp | 80 -- tests/ut_location/ut_location.h | 29 - tests/ut_location/ut_location.pro | 38 - tests/ut_route/ut_route.cpp | 158 --- tests/ut_route/ut_route.h | 31 - tests/ut_route/ut_route.pro | 40 - tests/ut_route/ut_sampleinput.h | 1238 ---------------------- 54 files changed, 2949 insertions(+), 4093 deletions(-) delete mode 100644 include/QGeoPositionInfo delete mode 100644 include/QGeoPositionInfoSource delete mode 100644 include/qgeocoordinate.h delete mode 100644 include/qgeopositioninfo.h delete mode 100644 include/qgeopositioninfosource.h delete mode 100644 include/qmobilityglobal.h create mode 100644 qtc_packaging/debian_fremantle/README create mode 100644 qtc_packaging/debian_fremantle/changelog create mode 100644 qtc_packaging/debian_fremantle/compat create mode 100644 qtc_packaging/debian_fremantle/control create mode 100644 qtc_packaging/debian_fremantle/copyright create mode 100755 qtc_packaging/debian_fremantle/rules create mode 100644 src/xmlparser.cpp create mode 100644 src/xmlparser.h create mode 100644 tests/routeParserTest/main.cpp create mode 100644 tests/routeParserTest/routeParserTest.pro create mode 100644 tests/routeParserTest/routeResponse-2-pretty.xml create mode 100644 tests/routeParserTest/routeResponse-2.xml create mode 100644 tests/routeParserTest/routeResponse-pretty.xml create mode 120000 tests/routeParserTest/routeResponse.xml delete mode 100755 tests/testSummary delete mode 100644 tests/tests.pri delete mode 100644 tests/tests.pro delete mode 100644 tests/ut_gpscontroller/ut_gpscontroller.cpp delete mode 100644 tests/ut_gpscontroller/ut_gpscontroller.h delete mode 100644 tests/ut_gpscontroller/ut_gpscontroller.pro delete mode 100644 tests/ut_location/ut_location.cpp delete mode 100644 tests/ut_location/ut_location.h delete mode 100644 tests/ut_location/ut_location.pro delete mode 100644 tests/ut_route/ut_route.cpp delete mode 100644 tests/ut_route/ut_route.h delete mode 100644 tests/ut_route/ut_route.pro delete mode 100644 tests/ut_route/ut_sampleinput.h diff --git a/include/QGeoPositionInfo b/include/QGeoPositionInfo deleted file mode 100644 index d6feec9..0000000 --- a/include/QGeoPositionInfo +++ /dev/null @@ -1 +0,0 @@ -#include "qgeopositioninfo.h" diff --git a/include/QGeoPositionInfoSource b/include/QGeoPositionInfoSource deleted file mode 100644 index b7cc338..0000000 --- a/include/QGeoPositionInfoSource +++ /dev/null @@ -1 +0,0 @@ -#include "qgeopositioninfosource.h" diff --git a/include/qgeocoordinate.h b/include/qgeocoordinate.h deleted file mode 100644 index 9a4902a..0000000 --- a/include/qgeocoordinate.h +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Mobility Components. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QGEOCOORDINATE_H -#define QGEOCOORDINATE_H - -#include "qmobilityglobal.h" - -#include - -QT_BEGIN_NAMESPACE -class QDebug; -class QDataStream; -QT_END_NAMESPACE - -QT_BEGIN_HEADER - -QTM_BEGIN_NAMESPACE - -class QGeoCoordinatePrivate; -class Q_LOCATION_EXPORT QGeoCoordinate -{ -public: - enum CoordinateType { - InvalidCoordinate, - Coordinate2D, - Coordinate3D - }; - - enum CoordinateFormat { - Degrees, - DegreesWithHemisphere, - DegreesMinutes, - DegreesMinutesWithHemisphere, - DegreesMinutesSeconds, - DegreesMinutesSecondsWithHemisphere - }; - - QGeoCoordinate(); - QGeoCoordinate(double latitude, double longitude); - QGeoCoordinate(double latitude, double longitude, double altitude); - QGeoCoordinate(const QGeoCoordinate &other); - ~QGeoCoordinate(); - - QGeoCoordinate &operator=(const QGeoCoordinate &other); - - bool operator==(const QGeoCoordinate &other) const; - inline bool operator!=(const QGeoCoordinate &other) const { - return !operator==(other); - } - - bool isValid() const; - CoordinateType type() const; - - void setLatitude(double latitude); - double latitude() const; - - void setLongitude(double longitude); - double longitude() const; - - void setAltitude(double altitude); - double altitude() const; - - qreal distanceTo(const QGeoCoordinate &other) const; - qreal azimuthTo(const QGeoCoordinate &other) const; - - QString toString(CoordinateFormat format = DegreesMinutesSecondsWithHemisphere) const; - -private: - QGeoCoordinatePrivate *d; -}; - -#ifndef QT_NO_DEBUG_STREAM -Q_LOCATION_EXPORT QDebug operator<<(QDebug, const QGeoCoordinate &); -#endif - -#ifndef QT_NO_DATASTREAM -Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoCoordinate &coordinate); -Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoCoordinate &coordinate); -#endif - -QTM_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/include/qgeopositioninfo.h b/include/qgeopositioninfo.h deleted file mode 100644 index 0d6bee9..0000000 --- a/include/qgeopositioninfo.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Mobility Components. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QGEOPOSITIONINFO_H -#define QGEOPOSITIONINFO_H - -#include "qmobilityglobal.h" -#include "qgeocoordinate.h" - -#include - -QT_BEGIN_NAMESPACE -class QDebug; -class QDataStream; -QT_END_NAMESPACE - -QT_BEGIN_HEADER - -QTM_BEGIN_NAMESPACE - -class QGeoPositionInfoPrivate; -class Q_LOCATION_EXPORT QGeoPositionInfo -{ -public: - enum Attribute { - Direction, - GroundSpeed, - VerticalSpeed, - MagneticVariation, - HorizontalAccuracy, - VerticalAccuracy - }; - - QGeoPositionInfo(); - QGeoPositionInfo(const QGeoCoordinate &coordinate, const QDateTime &updateTime); - QGeoPositionInfo(const QGeoPositionInfo &other); - ~QGeoPositionInfo(); - - QGeoPositionInfo &operator=(const QGeoPositionInfo &other); - - bool operator==(const QGeoPositionInfo &other) const; - inline bool operator!=(const QGeoPositionInfo &other) const { - return !operator==(other); - } - - bool isValid() const; - - void setDateTime(const QDateTime &dateTime); - QDateTime dateTime() const; - - void setCoordinate(const QGeoCoordinate &coordinate); - QGeoCoordinate coordinate() const; - - void setAttribute(Attribute attribute, qreal value); - qreal attribute(Attribute attribute) const; - void removeAttribute(Attribute attribute); - bool hasAttribute(Attribute attribute) const; - -private: -#ifndef QT_NO_DEBUG_STREAM - friend Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoPositionInfo &update); -#endif -#ifndef QT_NO_DATASTREAM - friend Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &update); - friend Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &update); -#endif - QGeoPositionInfoPrivate *d; -}; - -#ifndef QT_NO_DEBUG_STREAM -Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoPositionInfo &update); -#endif - -#ifndef QT_NO_DATASTREAM -Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &update); -Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &update); -#endif - -QTM_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/include/qgeopositioninfosource.h b/include/qgeopositioninfosource.h deleted file mode 100644 index 359302d..0000000 --- a/include/qgeopositioninfosource.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Mobility Components. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QGEOPOSITIONINFOSOURCE_H -#define QGEOPOSITIONINFOSOURCE_H - -#include "qmobilityglobal.h" -#include "qgeopositioninfo.h" - -#include - -QT_BEGIN_HEADER - -QTM_BEGIN_NAMESPACE - -class QGeoPositionInfoSourcePrivate; -class Q_LOCATION_EXPORT QGeoPositionInfoSource : public QObject -{ - Q_OBJECT - Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval) - Q_PROPERTY(int minimumUpdateInterval READ minimumUpdateInterval) - -public: - enum PositioningMethod { - SatellitePositioningMethods = 0x000000ff, - NonSatellitePositioningMethods = 0xffffff00, - AllPositioningMethods = 0xffffffff - }; - Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod) - - explicit QGeoPositionInfoSource(QObject *parent); - virtual ~QGeoPositionInfoSource(); - - virtual void setUpdateInterval(int msec); - int updateInterval() const; - - virtual void setPreferredPositioningMethods(PositioningMethods methods); - PositioningMethods preferredPositioningMethods() const; - - virtual QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const = 0; - - virtual PositioningMethods supportedPositioningMethods() const = 0; - virtual int minimumUpdateInterval() const = 0; - - static QGeoPositionInfoSource *createDefaultSource(QObject *parent); - -public Q_SLOTS: - virtual void startUpdates() = 0; - virtual void stopUpdates() = 0; - - virtual void requestUpdate(int timeout = 0) = 0; - -Q_SIGNALS: - void positionUpdated(const QGeoPositionInfo &update); - void updateTimeout(); - -private: - Q_DISABLE_COPY(QGeoPositionInfoSource) - QGeoPositionInfoSourcePrivate *d; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoPositionInfoSource::PositioningMethods) - -QTM_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/include/qmobilityglobal.h b/include/qmobilityglobal.h deleted file mode 100644 index ac9895d..0000000 --- a/include/qmobilityglobal.h +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Mobility Components. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QMOBILITYGLOBAL_H -#define QMOBILITYGLOBAL_H - - -#define QTM_VERSION_STR "1.0.0" -/* - QTM_VERSION is (major << 16) + (minor << 8) + patch. -*/ -#define QTM_VERSION 0x010000 -/* - can be used like #if (QTM_VERSION >= QTM_VERSION_CHECK(1, 0, 0)) -*/ -#define QTM_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) - -#define QTM_PACKAGEDATE_STR "YYYY-MM-DD" - -#define QTM_PACKAGE_TAG "" - -#if defined(QTM_BUILD_UNITTESTS) -# include -# if !defined(QT_BUILD_INTERNAL) -# define QT_BUILD_INTERNAL -# endif -#endif -#include - -#if defined(SYMBIAN_DATABASEMANAGER_SERVER) -# define Q_SERVICEFW_EXPORT -#else -# if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) -# if defined(QT_NODLL) -# undef QT_MAKEDLL -# undef QT_DLL -# elif defined(QT_MAKEDLL) -# if defined(QT_DLL) -# undef QT_DLL -# endif -# if defined(QT_BUILD_BEARER_LIB) -# define Q_BEARER_EXPORT Q_DECL_EXPORT -# else -# define Q_BEARER_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_CFW_LIB) -# define Q_PUBLISHSUBSCRIBE_EXPORT Q_DECL_EXPORT -# else -# define Q_PUBLISHSUBSCRIBE_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_CONTACTS_LIB) -# define Q_CONTACTS_EXPORT Q_DECL_EXPORT -# else -# define Q_CONTACTS_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_VERSIT_LIB) -# define Q_VERSIT_EXPORT Q_DECL_EXPORT -# else -# define Q_VERSIT_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_LOCATION_LIB) -# define Q_LOCATION_EXPORT Q_DECL_EXPORT -# else -# define Q_LOCATION_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_MESSAGING_LIB) -# define Q_MESSAGING_EXPORT Q_DECL_EXPORT -# else -# define Q_MESSAGING_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_MEDIA_LIB) -# define Q_MEDIA_EXPORT Q_DECL_EXPORT -# else -# define Q_MEDIA_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_SFW_LIB) -# define Q_SERVICEFW_EXPORT Q_DECL_EXPORT -# else -# define Q_SERVICEFW_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_SYSINFO_LIB) -# define Q_SYSINFO_EXPORT Q_DECL_EXPORT -# else -# define Q_SYSINFO_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_SENSORS_LIB) -# define Q_SENSORS_EXPORT Q_DECL_EXPORT -# else -# define Q_SENSORS_EXPORT Q_DECL_IMPORT -# endif -# elif defined(QT_DLL) /* use a Qt DLL library */ -# define Q_BEARER_EXPORT Q_DECL_IMPORT -# define Q_PUBLISHSUBSCRIBE_EXPORT Q_DECL_IMPORT -# define Q_CONTACTS_EXPORT Q_DECL_IMPORT -# define Q_VERSIT_EXPORT Q_DECL_IMPORT -# define Q_LOCATION_EXPORT Q_DECL_IMPORT -# define Q_MEDIA_EXPORT Q_DECL_IMPORT -# define Q_MESSAGING_EXPORT Q_DECL_IMPORT -# define Q_SERVICEFW_EXPORT Q_DECL_IMPORT -# define Q_SYSINFO_EXPORT Q_DECL_IMPORT -# define Q_SENSORS_EXPORT Q_DECL_IMPORT -# endif -# else -# endif -# if !defined(Q_SERVICEFW_EXPORT) -# if defined(QT_SHARED) -# define Q_BEARER_EXPORT Q_DECL_EXPORT -# define Q_PUBLISHSUBSCRIBE_EXPORT Q_DECL_EXPORT -# define Q_CONTACTS_EXPORT Q_DECL_EXPORT -# define Q_VERSIT_EXPORT Q_DECL_EXPORT -# define Q_LOCATION_EXPORT Q_DECL_EXPORT -# define Q_MEDIA_EXPORT Q_DECL_EXPORT -# define Q_MESSAGING_EXPORT Q_DECL_EXPORT -# define Q_SERVICEFW_EXPORT Q_DECL_EXPORT -# define Q_SYSINFO_EXPORT Q_DECL_EXPORT -# define Q_SENSORS_EXPORT Q_DECL_EXPORT -# else -# define Q_BEARER_EXPORT -# define Q_PUBLISHSUBSCRIBE_EXPORT -# define Q_CONTACTS_EXPORT -# define Q_VERSIT_EXPORT -# define Q_LOCATION_EXPORT -# define Q_MEDIA_EXPORT -# define Q_MESSAGING_EXPORT -# define Q_SERVICEFW_EXPORT -# define Q_SYSINFO_EXPORT -# define Q_SENSORS_EXPORT -# endif -# endif -#endif - -// The namespace is hardcoded as moc has issues resolving -// macros which would be a prerequisite for a dynmamic namespace -#define QTM_NAMESPACE QtMobility - -#ifdef QTM_NAMESPACE -# define QTM_PREPEND_NAMESPACE(name) ::QTM_NAMESPACE::name -# define QTM_BEGIN_NAMESPACE namespace QTM_NAMESPACE { -# define QTM_END_NAMESPACE } -# define QTM_USE_NAMESPACE using namespace QTM_NAMESPACE; -#else -# define QTM_PREPEND_NAMESPACE(name) ::name -# define QTM_BEGIN_NAMESPACE -# define QTM_END_NAMESPACE -# define QTM_USE_NAMESPACE -#endif - -//in case Qt is in namespace -QT_USE_NAMESPACE - -#endif // QMOBILITYGLOBAL_H diff --git a/qtc_packaging/debian_fremantle/README b/qtc_packaging/debian_fremantle/README new file mode 100644 index 0000000..cacd44f --- /dev/null +++ b/qtc_packaging/debian_fremantle/README @@ -0,0 +1,6 @@ +The Debian Package zouba +---------------------------- + +Comments regarding the Package + + -- Max Waterman Tue, 31 May 2011 20:40:03 +0300 diff --git a/qtc_packaging/debian_fremantle/changelog b/qtc_packaging/debian_fremantle/changelog new file mode 100644 index 0000000..9be5aa0 --- /dev/null +++ b/qtc_packaging/debian_fremantle/changelog @@ -0,0 +1,5 @@ +zouba (0.0.1) unstable; urgency=low + + * Initial Release. + + -- Max Waterman Tue, 31 May 2011 20:40:03 +0300 diff --git a/qtc_packaging/debian_fremantle/compat b/qtc_packaging/debian_fremantle/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/qtc_packaging/debian_fremantle/compat @@ -0,0 +1 @@ +7 diff --git a/qtc_packaging/debian_fremantle/control b/qtc_packaging/debian_fremantle/control new file mode 100644 index 0000000..997f2e1 --- /dev/null +++ b/qtc_packaging/debian_fremantle/control @@ -0,0 +1,14 @@ +Source: zouba +Section: user/hidden +Priority: optional +Maintainer: Max Waterman +Build-Depends: debhelper (>= 5), libqt4-dev +Standards-Version: 3.7.3 +Homepage: + +Package: zouba +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: + +XB-Maemo-Display-Name: zouba diff --git a/qtc_packaging/debian_fremantle/copyright b/qtc_packaging/debian_fremantle/copyright new file mode 100644 index 0000000..c1d5cc0 --- /dev/null +++ b/qtc_packaging/debian_fremantle/copyright @@ -0,0 +1,40 @@ +This package was debianized by Max Waterman on +Tue, 31 May 2011 20:40:03 +0300. + +It was downloaded from + +Upstream Author(s): + + + + +Copyright: + + + + +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) 2011, Max Waterman 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/qtc_packaging/debian_fremantle/rules b/qtc_packaging/debian_fremantle/rules new file mode 100755 index 0000000..9bdd1c3 --- /dev/null +++ b/qtc_packaging/debian_fremantle/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 + # qmake PREFIX=/usr# Uncomment this line for use without Qt Creator + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + # $(MAKE) # Uncomment this line for use without Qt Creator + #docbook-to-man debian/zouba.sgml > zouba.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/zouba. + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/zouba 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 # Uncomment this line for use without Qt Creator + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/src/gpscontroller.cpp b/src/gpscontroller.cpp index d924564..9fad558 100644 --- a/src/gpscontroller.cpp +++ b/src/gpscontroller.cpp @@ -7,59 +7,63 @@ #include GpsController::GpsController() : - q( new GpsControllerPrivate() ) + q(new GpsControllerPrivate()) { - q->init(); - q->startGps(); + q->init(); + q->startGps(); + + connect(q, SIGNAL(locationChanged(Location*)), SIGNAL(locationChanged(Location*))); } -GpsController::GpsController( GpsControllerPrivate *gpsControllerPrivate ) : - q( gpsControllerPrivate ) +GpsController::GpsController(GpsControllerPrivate *gpsControllerPrivate) : + q(gpsControllerPrivate) { - q->init(); - q->startGps(); + q->init(); + q->startGps(); + + connect(q, SIGNAL(locationChanged(Location*)), SIGNAL(locationChanged(Location*))); } GpsController::~GpsController() { - delete q; + delete q; } void GpsController::getGps() { - Location *location; - Location *previousLocation = q->mostRecentlyReportedLocation(); + qDebug() << Q_FUNC_INFO; + Location *location; - if ( q->useFakeLocation() ) { - location = q->fakeLocation(); - } else { - location = q->liveLocation(); - } + if (q->useFakeLocation()) { + location = q->fakeLocation(); + } else { + location = q->liveLocation(); + } - if ( location != previousLocation ) { - emit locationChanged( location ); - } + if (location->isValid()) { + emit locationChanged(location); + } } void GpsController::useLiveGps() { - q->setUseFakeLocation( false ); - q->startGps(); - emit locationChanged( q->liveLocation() ); + q->setUseFakeLocation(false); + q->startGps(); + emit locationChanged(q->liveLocation()); } -void GpsController::useFakeGps( const QString &fakeLocationLabel ) +void GpsController::useFakeGps(const QString &fakeLocationLabel) { - qDebug() << "using fake gps (" << fakeLocationLabel << ")"; + qDebug() << "using fake gps (" << fakeLocationLabel << ")"; - q->setFakeLocationLabel( fakeLocationLabel ); - Location *fakeLocation = q->fakeLocation(); + q->setFakeLocationLabel(fakeLocationLabel); + Location *fakeLocation = q->fakeLocation(); - if ( fakeLocation == 0 ) { - qDebug() << "invalid fake location label; cannot use fake location"; - } else { - q->stopGps(); - q->setUseFakeLocation( true ); - emit locationChanged( fakeLocation ); - } + if (fakeLocation == 0) { + qDebug() << "invalid fake location label; cannot use fake location"; + } else { + q->stopGps(); + q->setUseFakeLocation(true); + emit locationChanged(fakeLocation); + } } diff --git a/src/gpscontroller.h b/src/gpscontroller.h index 438b3f8..30d4b26 100644 --- a/src/gpscontroller.h +++ b/src/gpscontroller.h @@ -13,23 +13,23 @@ QTM_USE_NAMESPACE class GpsController : public QObject { - Q_OBJECT + Q_OBJECT -public: - GpsController(); - GpsController( GpsControllerPrivate *gpsControllerPrivate ); + public: + GpsController(); + GpsController(GpsControllerPrivate *gpsControllerPrivate); - ~GpsController(); + ~GpsController(); -public Q_SLOTS: - void getGps(); - void useFakeGps( const QString &fakeLocationLabel ); - void useLiveGps(); + public Q_SLOTS: + void getGps(); + void useFakeGps(const QString &fakeLocationLabel); + void useLiveGps(); -Q_SIGNALS: - void locationChanged( Location *newLocation ); + Q_SIGNALS: + void locationChanged(Location *newLocation); -private: + private: GpsControllerPrivate *q; }; diff --git a/src/gpscontroller_p.cpp b/src/gpscontroller_p.cpp index 41086b0..bdea8e3 100644 --- a/src/gpscontroller_p.cpp +++ b/src/gpscontroller_p.cpp @@ -11,90 +11,97 @@ QTM_USE_NAMESPACE GpsControllerPrivate::GpsControllerPrivate() : - m_gps(0), - m_liveLocation( new Location( "livegps" ) ), - m_fakeLocationLabel(), - m_useFakeLocation(false) + m_gps(0), + m_liveLocation(new Location("livegps")), + m_fakeLocationLabel(), + m_useFakeLocation(false) { } GpsControllerPrivate::~GpsControllerPrivate() { - delete m_gps; - m_gps = 0; - delete m_liveLocation; - m_liveLocation = 0; + delete m_gps; + m_gps = 0; + delete m_liveLocation; + m_liveLocation = 0; } void GpsControllerPrivate::init() { - m_gps = QGeoPositionInfoSource::createDefaultSource(this); - connect( - m_gps, SIGNAL( positionUpdated( QGeoPositionInfo ) ), - this, SLOT( updateLocation( QGeoPositionInfo ) ) - ); + m_gps = QGeoPositionInfoSource::createDefaultSource(this); + connect( + m_gps, SIGNAL(positionUpdated(QGeoPositionInfo)), + this, SLOT(updateLocation(QGeoPositionInfo)) + ); } void GpsControllerPrivate::startGps() { - m_gps->startUpdates(); + m_gps->startUpdates(); } void GpsControllerPrivate::stopGps() { - m_gps->stopUpdates(); + m_gps->stopUpdates(); } QGeoPositionInfoSource *GpsControllerPrivate::gps() { - return m_gps; + return m_gps; } -void GpsControllerPrivate::setGps( QGeoPositionInfoSource *gps ) +void GpsControllerPrivate::setGps(QGeoPositionInfoSource *gps) { - m_gps = gps; + m_gps = gps; } Location *GpsControllerPrivate::liveLocation() { - m_mostRecentlyReportedLocation = m_liveLocation; - return m_liveLocation; + m_mostRecentlyReportedLocation = m_liveLocation; + return m_liveLocation; } Location *GpsControllerPrivate::fakeLocation() { - Locations locations; - Location *location = locations.location( fakeLocationLabel() ); - m_mostRecentlyReportedLocation = location; - return location; + Locations locations; + Location *location = locations.location(fakeLocationLabel()); + m_mostRecentlyReportedLocation = location; + return location; } QString GpsControllerPrivate::fakeLocationLabel() { - return m_fakeLocationLabel; + return m_fakeLocationLabel; } -void GpsControllerPrivate::setFakeLocationLabel( const QString &label ) +void GpsControllerPrivate::setFakeLocationLabel(const QString &label) { - m_fakeLocationLabel = label; + m_fakeLocationLabel = label; } bool GpsControllerPrivate::useFakeLocation() { - return m_useFakeLocation; + return m_useFakeLocation; } -void GpsControllerPrivate::setUseFakeLocation( bool useFake ) +void GpsControllerPrivate::setUseFakeLocation(bool useFake) { - m_useFakeLocation = useFake; + m_useFakeLocation = useFake; } -void GpsControllerPrivate::updateLocation( QGeoPositionInfo positionInfo ) +void GpsControllerPrivate::updateLocation(QGeoPositionInfo positionInfo) { - m_liveLocation->setLocation( positionInfo ); + qDebug() << Q_FUNC_INFO; + bool wasInvalid = !m_liveLocation->isValid(); + qDebug() << "wasInvalid/" << wasInvalid; + + m_liveLocation->setLocation(positionInfo); + if (wasInvalid) { + emit locationChanged(m_liveLocation); + } } Location *GpsControllerPrivate::mostRecentlyReportedLocation() { - return m_mostRecentlyReportedLocation; + return m_mostRecentlyReportedLocation; } diff --git a/src/gpscontroller_p.h b/src/gpscontroller_p.h index a101ffe..679913c 100644 --- a/src/gpscontroller_p.h +++ b/src/gpscontroller_p.h @@ -20,9 +20,9 @@ public: virtual void startGps(); virtual void stopGps(); - virtual void setGps( QGeoPositionInfoSource *gps ); - virtual void setFakeLocationLabel( const QString &label ); - virtual void setUseFakeLocation( bool useFake ); + virtual void setGps(QGeoPositionInfoSource *gps); + virtual void setFakeLocationLabel(const QString &label); + virtual void setUseFakeLocation(bool useFake); virtual QGeoPositionInfoSource *gps(); virtual Location *liveLocation(); @@ -31,8 +31,11 @@ public: virtual QString fakeLocationLabel(); virtual bool useFakeLocation(); +Q_SIGNALS: + void locationChanged(Location *newlocation); + private Q_SLOTS: - virtual void updateLocation( QGeoPositionInfo positionInfo ); + virtual void updateLocation(QGeoPositionInfo positionInfo); private: QGeoPositionInfoSource *m_gps; diff --git a/src/location.cpp b/src/location.cpp index c54f65c..3578d72 100644 --- a/src/location.cpp +++ b/src/location.cpp @@ -16,313 +16,163 @@ #include #include -#include - -const double Location::KkjZoneInfo[6][2] = { - {18.0, 500000.0}, - {21.0, 1500000.0}, - {24.0, 2500000.0}, - {27.0, 3500000.0}, - {30.0, 4500000.0}, - {33.0, 5500000.0} -}; - QTM_USE_NAMESPACE -Location::Location( const QString &x, const QString &y, const QString &label ) : - q( new LocationPrivate( x, y, label ) ), - manager( new QNetworkAccessManager(this) ) +Location::Location(const QString &x, const QString &y, const QString &label) : + q(new LocationPrivate(x, y, label)), + manager(new QNetworkAccessManager(this)) { - connect( - manager, SIGNAL( finished(QNetworkReply*) ), - this, SLOT( replyFinished(QNetworkReply*) ) - ); + connect( + manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(replyFinished(QNetworkReply*)) + ); } -Location::Location( const QGeoPositionInfo &positionInfo, const QString &label ) : - q( new LocationPrivate( label ) ), - manager(0) +Location::Location(const QGeoPositionInfo &positionInfo, const QString &label) : + q(new LocationPrivate(label)), + manager(0) { - setLocation( positionInfo ); + setLocation(positionInfo); } -void Location::setLocation( const QGeoPositionInfo &positionInfo ) +void Location::setLocation(const QGeoPositionInfo &positionInfo) { - qreal latitude = positionInfo.coordinate().latitude(); - qreal longitude = positionInfo.coordinate().longitude(); + double latitude = positionInfo.coordinate().latitude(); + double longitude = positionInfo.coordinate().longitude(); - KKJ outX(0); - KKJ outY(0); + qDebug() << "GPS Location/" << longitude << latitude; - WGS84lola_to_KKJxy( longitude, latitude, &outX, &outY); - - q->setX( outX ); - q->setY( outY ); - q->setValid( true ); + q->setLongitude(longitude); + q->setlatitude(latitude); + q->setValid(true); } -Location::Location( const Location &from ) : - QObject(0), - q( new LocationPrivate( from.label() ) ), - manager(0) +Location::Location(const Location &from) : + QObject(0), + q(new LocationPrivate(from.label())), + manager(0) { - q->setAddress( from.address() ); - q->setX( from.x() ); - q->setY( from.y() ); - q->setValid( from.isValid() ); - if ( from.manager != 0 ) { - manager = new QNetworkAccessManager(this); - connect( manager, SIGNAL( finished(QNetworkReply*) ), this, SLOT( replyFinished(QNetworkReply*) ) ); - } + q->setAddress(from.address()); + q->setLongitude(from.longitude()); + q->setlatitude(from.latitude()); + q->setValid(from.isValid()); + if (from.manager != 0) { + manager = new QNetworkAccessManager(this); + connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); + } } -Location::Location( const QString &label ) : - q( new LocationPrivate( label ) ), - manager( new QNetworkAccessManager(this) ) +Location::Location(const QString &label) : + q(new LocationPrivate(label)), + manager(new QNetworkAccessManager(this)) { - connect( manager, SIGNAL( finished(QNetworkReply*) ), this, SLOT( replyFinished(QNetworkReply*) ) ); + connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); } Location::~Location() { - delete q; - q=0; - delete manager; - manager=0; -} - -Location &Location::operator=( const Location &from ) -{ - q = new LocationPrivate( from.label() ); - q->setAddress( from.address() ); - q->setX( from.x() ); - q->setY( from.y() ); - q->setValid( from.isValid() ); - - if ( from.manager != 0 ) { - manager = new QNetworkAccessManager(this); - connect( manager, SIGNAL( finished(QNetworkReply*) ), this, SLOT( replyFinished(QNetworkReply*) ) ); - } else { - manager = 0; - } - - return *this; -} - -void Location::resolveAddress( const QString &address ) -{ - qDebug() << "resolving address (" << address << ")"; - - q->setAddress( address ); - q->setValid( false ); - - QUrl fullUrl( Ytv::Url ); - - fullUrl.addEncodedQueryItem( "key", address.toAscii().toPercentEncoding() ); - fullUrl.addQueryItem( "user", Ytv::Username ); - fullUrl.addQueryItem( "pass", Ytv::Password ); - - manager->get( QNetworkRequest( fullUrl ) ); - qDebug() << "waiting for reply from Ytv"; - emit( busy( true ) ); + delete q; + q=0; + delete manager; + manager=0; } -void Location::replyFinished( QNetworkReply * reply ) +Location &Location::operator=(const Location &from) { - qDebug() << "address resolved"; - q->parseReply( reply->readAll() ); + q = new LocationPrivate(from.label()); + q->setAddress(from.address()); + q->setLongitude(from.longitude()); + q->setlatitude(from.latitude()); + q->setValid(from.isValid()); - if ( isValid() ) { - qDebug() << label() << "becomeValid"; - emit( becomeValid() ); - } else { - qDebug() << label() << "not valid"; - emit( becomeInValid() ); - } + if (from.manager != 0) { + manager = new QNetworkAccessManager(this); + connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); + } else { + manager = 0; + } - emit( busy( false ) ); + return *this; } -QString Location::x() const +void Location::resolveAddress(const QString &address) { - return q->x(); -} + qDebug() << "resolving address (" << address << ")"; -QString Location::y() const -{ - return q->y(); -} + q->setAddress(address); + q->setValid(false); -void Location::setLabel( const QString &label ) const -{ - q->setLabel( label ); -} + QUrl fullUrl(Ytv::Url); + QByteArray encodedAddress = QUrl::toPercentEncoding(address); + qDebug() << "encodedAddress/" << encodedAddress; -QString Location::label() const -{ - return q->label(); -} + fullUrl.addQueryItem("user", Ytv::Username); + fullUrl.addQueryItem("pass", Ytv::Password); + fullUrl.addEncodedQueryItem("key", encodedAddress); + fullUrl.addQueryItem("request", Ytv::Geocode); + fullUrl.addQueryItem("format", Ytv::Xml); + fullUrl.addQueryItem("language", Ytv::English); + fullUrl.addQueryItem("epsg_out", Ytv::WGS84); -void Location::setAddress( const QString &address ) const -{ - qDebug() << "setting address to" << address; - q->setAddress( address ); + qDebug() << "resolveAddress/" << address << "/" << fullUrl; + manager->get(QNetworkRequest(fullUrl)); + qDebug() << "waiting for reply from Ytv"; + emit busy(true); } -QString Location::address() const +void Location::replyFinished(QNetworkReply * reply) { - return q->address(); -} + qDebug() << "address resolved"; + q->parseReply(reply->readAll()); -bool Location::isValid() const -{ - return q->isValid(); -} + if (isValid()) { + qDebug() << label() << "becomeValid"; + emit becomeValid(); + } else { + qDebug() << label() << "not valid"; + emit becomeInValid(); + } -// Degrees to radians -double Location::radians(double deg) -{ - return deg * M_PI / 180.0; + emit(busy(false)); } -// Radians to degrees -double Location::degrees(double rad) +QString Location::longitude() const { - return rad * 180.0 / M_PI; + return q->longitude(); } -// Function: KKJ_Zone_I -int Location::KKJ_Zone_I(KKJ easting) +QString Location::latitude() const { - int zoneNumber = floor(easting / 1000000.0); - if (zoneNumber < 0 || zoneNumber > 5) { - zoneNumber = -1; - } - - return zoneNumber; + return q->latitude(); } -// Function: KKJ_Zone_Lo -int Location::KKJ_Zone_Lo(double kkjlo) +void Location::setLabel(const QString &label) const { - // determine the zonenumber from KKJ easting - // takes KKJ zone which has center meridian - // longitude nearest (in math value) to - // the given KKJ longitude - int zoneNumber = 5; - while (zoneNumber >= 0) { - if (fabs(kkjlo - KkjZoneInfo[zoneNumber][0]) <= 1.5) { - break; - } - zoneNumber--; - } - - return zoneNumber; + q->setLabel(label); } - -// Function: KKJlalo_to_WGS84lalo -void Location::KKJlola_to_WGS84lola(double kkjlo, double kkjla, double *outLongitude, double *outLatitude) +void Location::setValid(bool valid) const { - double dLa = radians(0.124867E+01 + -0.269982E+00 * kkjla + 0.191330E+00 * kkjlo + 0.356119E-02 * kkjla * kkjla + -0.122312E-02 * kkjla * kkjlo + -0.335514E-03 * kkjlo * kkjlo) / 3600.0; - double dLo = radians(-0.286111E+02 + 0.114183E+01 * kkjla + -0.581428E+00 * kkjlo + -0.152421E-01 * kkjla * kkjla + 0.118177E-01 * kkjla * kkjlo + 0.826646E-03 * kkjlo * kkjlo) / 3600.0; - - *outLatitude = degrees(radians(kkjla) + dLa); - *outLongitude = degrees(radians(kkjlo) + dLo); + q->setValid(valid); } - -// Function: WGS84lalo_to_KKJlalo -void Location::WGS84lola_to_KKJlola(double longitude, double latitude, double *outLongitude, double *outLatitude) +QString Location::label() const { - double dLa = radians(-0.124766E+01 + 0.269941E+00 * latitude + -0.191342E+00 * longitude + -0.356086E-02 * latitude * latitude + 0.122353E-02 * latitude * longitude + 0.335456E-03 * longitude * longitude) / 3600.0; - double dLo = radians(0.286008E+02 + -0.114139E+01 * latitude + 0.581329E+00 * longitude + 0.152376E-01 * latitude * latitude + -0.118166E-01 * latitude * longitude + -0.826201E-03 * longitude * longitude) / 3600.0; - - *outLatitude = degrees(radians(latitude) + dLa); - *outLongitude = degrees(radians(longitude) + dLo); + return q->label(); } - -// Function: KKJlalo_to_KKJxy -void Location::KKJlola_to_KKJxy(double lon, double lat, int zoneNumber, KKJ *outX, KKJ *outY) +void Location::setAddress(const QString &address) const { - // Hayford ellipsoid - double a = 6378388.0; - double f = 1.0 / 297.0; - double b = (1.0 - f) * a; - double bb = b * b; - double c = (a / b) * a; - double ee = (a * a - bb) / bb; - double n = (a - b) / (a + b); - double nn = n * n; - - double Lo = radians(lon) - radians(KkjZoneInfo[zoneNumber][0]); - double cosLa = cos(radians(lat)); - double NN = ee * cosLa * cosLa; - double LaF = atan(tan(radians(lat)) / cos(Lo * sqrt(1.0 + NN))); - double cosLaF = cos(LaF); - double t = (tan(Lo) * cosLaF) / sqrt(1.0 + ee * cosLaF * cosLaF); - double A = a / (1.0 + n); - double A1 = A * (1.0 + nn / 4.0 + nn * nn / 64.0); - double A2 = A * 1.5 * n * (1.0 - nn / 8.0); - double A3 = A * 0.9375 * nn * (1.0 - nn / 4.0); - double A4 = A * 35.0 / 48.0 * nn * n; - - *outY = A1 * LaF - A2 * sin(2.0 * LaF) + A3 * sin(4.0 * LaF) - A4 * sin(6.0 * LaF); - *outX = c * log(t + sqrt(1.0 + t * t)) + 500000.0 + zoneNumber * 1000000.0; + qDebug() << "setting address to" << address; + q->setAddress(address); } -// Function: KKJxy_to_KKJlalo -void Location::KKJxy_to_KKJlola(KKJ x, KKJ y, double *outLongitude, double *outLatitude) -{ - // Scan iteratively the target area, until find matching - // KKJ coordinate value. Area is defined with Hayford Ellipsoid. - int zoneNumber = KKJ_Zone_I(x); - double minLo = radians(18.5); - double maxLo = radians(32.0); - double minLa = radians(59.0); - double maxLa = radians(70.5); - - int i = 1; - KKJ tmpX, tmpY; - - while (i < 35) { - double deltaLo = maxLo - minLo; - double deltaLa = maxLa - minLa; - *outLongitude = degrees(minLo + 0.5 * deltaLo); - *outLatitude = degrees(minLa + 0.5 * deltaLa); - KKJlola_to_KKJxy(*outLongitude, *outLatitude, zoneNumber, &tmpX, &tmpY); - if (tmpY < y) { - minLa = minLa + 0.45 * deltaLa; - } else { - maxLa = minLa + 0.55 * deltaLa; - } - - if (tmpX < x) { - minLo = minLo + 0.45 * deltaLo; - } else { - maxLo = minLo + 0.55 * deltaLo; - } - - i++; - } -} - -void Location::WGS84lola_to_KKJxy(double longitude, double latitude, KKJ *outX, KKJ *outY) +QString Location::address() const { - double kkjlo, kkjla; - - WGS84lola_to_KKJlola(longitude, latitude, &kkjlo, &kkjla); - int zoneNumber = KKJ_Zone_Lo(kkjlo); - KKJlola_to_KKJxy(kkjlo, kkjla, zoneNumber, outX, outY); + return q->address(); } -void Location::KKJxy_to_WGS84lola(KKJ x, KKJ y, double *outLongitude, double *outLatitude) +bool Location::isValid() const { - double kkjlo, kkjla; - - KKJxy_to_KKJlola(x, y, &kkjlo, &kkjla); - KKJlola_to_WGS84lola(kkjlo, kkjla, outLongitude, outLatitude); - + return q->isValid(); } - diff --git a/src/location.h b/src/location.h index dfb5d00..402b20e 100644 --- a/src/location.h +++ b/src/location.h @@ -14,95 +14,53 @@ QTM_USE_NAMESPACE class Location : public QObject { -Q_OBJECT + Q_OBJECT -public: - Location( const QString &x, const QString &y, const QString &label=QString() ); - Location( const QGeoPositionInfo &positionInfo, const QString &label=QString() ); - Location( const Location &from ); - Location &operator=( const Location &from ); - Location( const QString &label=QString() ); + Q_PROPERTY(QString longitude READ longitude()) + Q_PROPERTY(QString latitude READ latitude()) + Q_PROPERTY(QString address READ address() WRITE setAddress()) + Q_PROPERTY(QString label READ label() WRITE setLabel()) + Q_PROPERTY(bool valid READ isValid() WRITE setValid()) - ~Location(); + public: + Location(const QString &longitude, const QString &latitude, const QString &label=QString()); + Location(const QGeoPositionInfo &positionInfo, const QString &label=QString()); + Location(const Location &from); + Location &operator=(const Location &from); + Location(const QString &label=QString()); - QString x() const; + ~Location(); - QString y() const; + QString longitude() const; - void setLocation( const QGeoPositionInfo &positionInfo ); + QString latitude() const; - void setAddress( const QString &address ) const; - QString address() const; + void setLocation(const QGeoPositionInfo &positionInfo); - void setLabel( const QString &label ) const; - QString label() const; + void setAddress(const QString &address) const; + QString address() const; - bool isValid() const; + void setLabel(const QString &label) const; + QString label() const; -public Q_SLOTS: - void resolveAddress( const QString &address ); + void setValid(bool valid) const; + bool isValid() const; -Q_SIGNALS: - void becomeValid(); - void becomeInValid(); - void busy( bool busy ); + public Q_SLOTS: + void resolveAddress(const QString &address); -private Q_SLOTS: - void replyFinished( QNetworkReply * reply ); + Q_SIGNALS: + void becomeValid(); + void becomeInValid(); + void busy(bool busy); -private: + private Q_SLOTS: + void replyFinished(QNetworkReply * reply); - LocationPrivate *q; - QNetworkAccessManager *manager; - - typedef uint KKJ; - - /** - * Transformes WGS84 longitude/latitude coordinates to KKJ x/y coordinates. - * @param longitude the input longitude in degrees - * @param latitude the input latitude in degrees - * @param outX the result x (easting) - * @param outY the result y (northing) - */ - void WGS84lola_to_KKJxy(double longitude, double latitude, KKJ *outX, KKJ *outY); - - /** - * Transformes KKJ x/y coordinates to WGS84 longitude/latitude coordinates. - * @param x the input x (easting) - * @param y the input y (northing) - * @param outLongitude the result longitude in degrees - * @param outLatitude the result latitude in degrees - */ - void KKJxy_to_WGS84lola(KKJ x, KKJ y, double *outLongitude, double *outLatitude); - - // Degrees to radians - double radians(double deg); - - // Radians to degrees - double degrees(double rad); - - // Constants - // Longitude0 and Center meridian of KKJ bands - static const double KkjZoneInfo[][2]; - - // Function: KKJ_Zone_I - int KKJ_Zone_I(KKJ easting); - - // Function: KKJ_Zone_Lo - int KKJ_Zone_Lo(double kkjlo); - - // Function: KKJlalo_to_WGS84lalo - void KKJlola_to_WGS84lola(double kkjlo, double kkjla, double *outLongitude, double *outLatitude); - - // Function: WGS84lalo_to_KKJlalo - void WGS84lola_to_KKJlola(double longitude, double latitude, double *outLongitude, double *outLatitude); - - // Function: KKJlalo_to_KKJxy - void KKJlola_to_KKJxy(double lon, double lat, int zoneNumber, KKJ *outX, KKJ *outY); - - // Function: KKJxy_to_KKJlalo - void KKJxy_to_KKJlola(KKJ x, KKJ y, double *outLongitude, double *outLatitude); + private: + LocationPrivate *q; + QNetworkAccessManager *manager; }; #endif // LOCATION_H diff --git a/src/location_p.cpp b/src/location_p.cpp index fe9d555..e5b4287 100644 --- a/src/location_p.cpp +++ b/src/location_p.cpp @@ -1,140 +1,124 @@ #include #include "location_p.h" +#include "xmlparser.h" + #include #include #include #include -LocationPrivate::LocationPrivate( const QString &x, const QString &y, const QString &label ) : - m_label(label), - m_address(), - m_x(x), - m_y(y), - m_valid(true) +LocationPrivate::LocationPrivate(const QString &longitude, const QString &latitude, const QString &label) : + m_label(label), + m_address(), + m_longitude(longitude), + m_latitude(latitude), + m_valid(true) { } -LocationPrivate::LocationPrivate( const QString &label ) : - m_label(label), - m_address(), - m_x(0), - m_y(0), - m_valid(false) +LocationPrivate::LocationPrivate(const QString &label) : + m_label(label), + m_address(), + m_longitude(QString()), + m_latitude(QString()), + m_valid(false) { } LocationPrivate::~LocationPrivate() { - m_label="deleted"; - m_address=""; - m_x=""; - m_y=""; - m_valid=false; + m_label="deleted"; + m_address=""; + m_longitude=""; + m_latitude=""; + m_valid=false; } -void LocationPrivate::parseReply( const QByteArray &reply ) +void LocationPrivate::parseReply(const QByteArray &reply) { - qDebug() << "parsing"; - QXmlStreamReader xml( reply ); - bool responseHasError = false; - - while ( !xml.atEnd() ) { - xml.readNext(); + qDebug() << "parsing/" << reply; - if ( xml.isStartElement() ) { - QString xmlName( xml.name().toString() ); + XmlParser parser; + QPair parsedReply = parser.parseGeocode(reply); - if ( xmlName == "LOC" ) { - QXmlStreamAttributes attributes( xml.attributes() ); - QStringRef xAttribute( attributes.value("x") ); - QStringRef yAttribute( attributes.value("y") ); - QString newX( xAttribute.toString() ); - QString newY( yAttribute.toString() ); + m_longitude = parsedReply.first; + m_latitude = parsedReply.second; - m_x = newX; - m_y = newY; - } + qDebug() << "DONE parsing"; - if ( xmlName == "ERROR" ) { - responseHasError = true; - } - - } - } - - if ( xml.hasError() || responseHasError ) { - QMaemo5InformationBox::information( 0, "address resolution error - please check address" ); - qDebug() << "xml error"; - m_valid = false; - } else { - qDebug() << "(" << m_x << "," << m_y << ")"; - if ( m_x.isEmpty() || m_y.isEmpty() ) { - qDebug() << "is NOT valid"; - m_valid = false; + if (parser.error()) { + QMaemo5InformationBox::information(0, "address resolution error - please check address"); + m_valid = false; } else { - qDebug() << "is now valid"; - m_valid = true; + qDebug() << "(" << m_longitude << "," << m_latitude << ")"; + if (m_longitude.isEmpty() || m_latitude.isEmpty()) { + qDebug() << "is NOT valid"; + m_valid = false; + } else { + qDebug() << "is now valid"; + m_valid = true; + } } - } } -void LocationPrivate::setLabel( const QString &label) +void LocationPrivate::setLabel(const QString &label) { - m_label = label; + m_label = label; } QString LocationPrivate::label() const { - return m_label; + return m_label; } -void LocationPrivate::setAddress( const QString &address) +void LocationPrivate::setAddress(const QString &address) { - m_address = address; + m_address = address; } QString LocationPrivate::address() const { - return m_address; + return m_address; } -void LocationPrivate::setX( uint x ) +void LocationPrivate::setLongitude(double longitude) { - m_x = QString( "%1" ).arg( x ); + m_longitude = QString("%1").arg(longitude); } -void LocationPrivate::setX( const QString &x ) +void LocationPrivate::setLongitude(const QString &longitude) { - m_x = x; + m_longitude = longitude; } -QString LocationPrivate::x() const +QString LocationPrivate::longitude() const { - return m_x; + return m_longitude; } -void LocationPrivate::setY( uint y ) +void LocationPrivate::setlatitude(double latitude) { - m_y = QString( "%1" ).arg( y ); + m_latitude = QString("%1").arg(latitude); } -void LocationPrivate::setY( const QString &y ) +void LocationPrivate::setlatitude(const QString &latitude) { - m_y = y; + m_latitude = latitude; } -QString LocationPrivate::y() const +QString LocationPrivate::latitude() const { - return m_y; + return m_latitude; } -void LocationPrivate::setValid( bool valid ) +void LocationPrivate::setValid(bool valid) { - m_valid = valid; + qDebug() << Q_FUNC_INFO << "/valid/" << valid; + m_valid = valid; } bool LocationPrivate::isValid() const { - return m_valid; + return m_valid; } diff --git a/src/location_p.h b/src/location_p.h index e32b267..1524035 100644 --- a/src/location_p.h +++ b/src/location_p.h @@ -10,35 +10,34 @@ class LocationPrivate : public QObject Q_OBJECT public: - LocationPrivate( const QString &x, const QString &y, const QString &label ); - LocationPrivate( const QString &label ); - virtual ~LocationPrivate(); + LocationPrivate(const QString &longitude, const QString &latitude, const QString &label); + LocationPrivate(const QString &label); + virtual ~LocationPrivate(); - void setX( uint x ); - void setX( const QString &x ); - QString x() const; + void setLongitude(double longitude); + void setLongitude(const QString &longitude); + QString longitude() const; - void setY( uint y ); - void setY( const QString &y ); - QString y() const; + void setlatitude(double latitude); + void setlatitude(const QString &latitude); + QString latitude() const; - void setAddress( const QString &address ); - QString address() const; + void setAddress(const QString &address); + QString address() const; - void setLabel( const QString &label ); - QString label() const; + void setLabel(const QString &label); + QString label() const; - void setValid( bool valid ); - bool isValid() const; + void setValid(bool valid); + bool isValid() const; - void parseReply( const QByteArray &reply ); + void parseReply(const QByteArray &reply); - QString m_label; - QString m_address; - QString m_x; - QString m_y; - bool m_valid; + QString m_label; + QString m_address; + QString m_longitude; + QString m_latitude; + bool m_valid; }; #endif // LOCATION_P_H - diff --git a/src/locations.cpp b/src/locations.cpp index 358a2cc..c2fed4a 100644 --- a/src/locations.cpp +++ b/src/locations.cpp @@ -12,10 +12,11 @@ bool Locations::initialised = false; Locations::Locations() { - if ( !initialised ) { - QCoreApplication::setOrganizationName("ZouBa"); - QCoreApplication::setOrganizationDomain("zouba.yi.org"); + if (!initialised) { + qDebug() << "Initialising locations"; + QCoreApplication::setOrganizationDomain("zouba.maemo.org"); QCoreApplication::setOrganizationName("ZouBa"); + QCoreApplication::setApplicationName("ZouBa"); restoreLocations(); initialised = true; @@ -26,82 +27,85 @@ Locations::~Locations() { } -bool Locations::addLocation( Location *location ) +bool Locations::addLocation(Location *location) { - bool succeeded=false; - - // if it's valid now, save the setting - if ( location->isValid() ) { - saveLocation( location ); - } - - if ( !locationHash.contains( location->label() ) ) { - qDebug() << "Adding location" << location->label(); - locationHash[ location->label() ] = location; - succeeded = true; - } else { - qDebug() << "FAILED to add location" << location->label(); - } - - return succeeded; + bool succeeded=false; + + // if it's valid now, save the setting + if (location->isValid()) { + saveLocation(location); + } else { + qDebug() << "Location not valid, so not saving"; + } + + if (!locationHash.contains(location->label())) { + qDebug() << "Adding location" << location->label(); + locationHash[ location->label() ] = location; + succeeded = true; + } else { + qDebug() << "FAILED to add location" << location->label(); + } + + return succeeded; } void Locations::restoreLocations() { - QSettings settings; + QSettings settings; - settings.beginGroup( "Locations" ); - QStringList labels = settings.childGroups(); + settings.beginGroup("Locations"); + QStringList labels = settings.childGroups(); - for( int i=0; isetAddress( address ); + qDebug() << "restoring" << label; + Location *location = new Location(longitude, latitude , label); + location->setAddress(address); - locationHash[ label ] = location; - } + locationHash[ label ] = location; + } - settings.endGroup(); + settings.endGroup(); } -void Locations::saveLocation( Location *location ) +void Locations::saveLocation(Location *location) { - qDebug() << "Saving location" << location->label(); - QSettings settings; - settings.beginGroup( "Locations" ); - settings.beginGroup( location->label() ); - settings.setValue( "address", location->address() ); - settings.setValue( "x", location->x() ); - settings.setValue( "y", location->y() ); - settings.endGroup(); - settings.endGroup(); + qDebug() << "Saving location" << location->label(); + QSettings settings; + settings.beginGroup("Locations"); + settings.beginGroup(location->label()); + settings.setValue("address", location->address()); + settings.setValue("longitude", location->longitude()); + settings.setValue("latitude", location->latitude()); + settings.endGroup(); + settings.endGroup(); } void Locations::saveLocation() { - Location *location = qobject_cast(sender()); + qDebug() << "Saving location (slot)"; + Location *location = qobject_cast(sender()); - saveLocation( location ); + saveLocation(location); } -Location *Locations::location( const QString &label ) +Location *Locations::location(const QString &label) { - qDebug() << "requesting location" << label; - Location *retVal = 0; - - if ( locationHash.contains( label ) ) { - qDebug() << "found location" << label; - retVal = locationHash[ label ]; - } else { - qDebug() << "didn't find location" << label; - } + qDebug() << "requesting location" << label; + Location *retVal = 0; + + if (locationHash.contains(label)) { + qDebug() << "found location" << label; + retVal = locationHash[ label ]; + } else { + qDebug() << "didn't find location" << label; + } - return retVal; + return retVal; } diff --git a/src/locations.h b/src/locations.h index fa74faa..21e1c3e 100644 --- a/src/locations.h +++ b/src/locations.h @@ -9,25 +9,25 @@ class Locations: public QObject { - Q_OBJECT + Q_OBJECT public: - Locations(); - ~Locations(); + Locations(); + ~Locations(); - static Locations *instance(); - bool addLocation( Location *location ); + static Locations *instance(); + bool addLocation(Location *location); - Location *location( const QString &label ); + Location *location(const QString &label); public Q_SLOTS: - void saveLocation(); + void saveLocation(); private: - void restoreLocations(); - static QHash locationHash; - static bool initialised; + void restoreLocations(); + static QHash locationHash; + static bool initialised; - void saveLocation( Location *location ); + void saveLocation(Location *location); }; #endif // LOCATIONS_H diff --git a/src/main.cpp b/src/main.cpp index bd3898b..3db85fb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,54 +11,54 @@ #include #include -int main(int argc, char *argv[] ) +int main(int argc, char *argv[]) { - QApplication app(argc, argv); + QApplication app(argc, argv); - QMainWindow *mainWindow = new QMainWindow; - Ui *ui = new Ui;; - ui->setupUi(mainWindow); + QMainWindow *mainWindow = new QMainWindow; + Ui *ui = new Ui; + ui->setupUi(mainWindow); - UiController *uiController = new UiController( ui ); - Route *route = new Route(); - GpsController *gpsController = new GpsController(); + UiController *uiController = new UiController(ui); + Route *route = new Route(); + GpsController *gpsController = new GpsController(); - QObject::connect( - route, SIGNAL( routeReady( QList ) ), - uiController, SLOT( displayRoute( QList ) ) - ); + QObject::connect( + route, SIGNAL(routeReady(QList)), + uiController, SLOT(displayRoute(QList)) + ); - QObject::connect( - gpsController, SIGNAL( locationChanged( Location* ) ), - route, SLOT( setFromLocation( Location* ) ) - ); + QObject::connect( + gpsController, SIGNAL(locationChanged(Location*)), + route, SLOT(setFromLocation(Location*)) + ); - QObject::connect( - uiController, SIGNAL( destinationChanged( Location* ) ), - route, SLOT( setToLocation( Location* ) ) - ); + QObject::connect( + uiController, SIGNAL(destinationChanged(Location*)), + route, SLOT(setToLocation(Location*)) + ); - QObject::connect( - uiController, SIGNAL( buttonClicked() ), - gpsController, SLOT( getGps() ) - ); + QObject::connect( + uiController, SIGNAL(buttonClicked()), + gpsController, SLOT(getGps()) + ); - QObject::connect( - ui, SIGNAL( fakeGpsPressed( const QString & ) ), - gpsController, SLOT( useFakeGps( const QString & ) ) - ); + QObject::connect( + ui, SIGNAL(fakeGpsPressed(const QString &)), + gpsController, SLOT(useFakeGps(const QString &)) + ); - QObject::connect( - ui, SIGNAL( liveGpsPressed() ), - gpsController, SLOT( useLiveGps() ) - ); + QObject::connect( + ui, SIGNAL(liveGpsPressed()), + gpsController, SLOT(useLiveGps()) + ); - QObject::connect( - route, SIGNAL( busy( bool ) ), - ui, SLOT( setBusy( bool ) ) - ); + QObject::connect( + route, SIGNAL(busy(bool)), + ui, SLOT(setBusy(bool)) + ); - mainWindow->show(); + mainWindow->show(); - return app.exec(); + return app.exec(); } diff --git a/src/route.cpp b/src/route.cpp index 5d5e794..4941c35 100644 --- a/src/route.cpp +++ b/src/route.cpp @@ -17,102 +17,107 @@ #include "ytv.h" Route::Route() : - q( new RoutePrivate( this ) ), - manager( new QNetworkAccessManager(this) ) + q(new RoutePrivate(this)), + manager(new QNetworkAccessManager(this)) { - connect( manager, SIGNAL( finished(QNetworkReply*) ), this, SLOT( replyFinished(QNetworkReply*) ) ); + connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); } Route::~Route() { - delete manager; - manager = 0; + delete manager; + manager = 0; } void Route::getRoute() { - qDebug() << "getting route from Ytv"; - - QUrl fullUrl( Ytv::Url ); - - QStringList a; - a << q->fromLocation()->x() << q->fromLocation()->y(); - QStringList b; - b << q->toLocation()->x() << q->toLocation()->y(); - - fullUrl.addQueryItem( "a", a.join(",") ); - fullUrl.addQueryItem( "b", b.join(",") ); - fullUrl.addQueryItem( "show", QString::number(Ytv::ShowFiveResults) ); - fullUrl.addQueryItem( "walkspeed", QString::number(Ytv::WalkSpeedFast) ); - fullUrl.addQueryItem( "optimize", QString::number(Ytv::OptimizeLeastWalking) ); - fullUrl.addQueryItem( "user", Ytv::Username ); - fullUrl.addQueryItem( "pass", Ytv::Password ); - - manager->get( QNetworkRequest( fullUrl ) ); - qDebug() << "getting url" << fullUrl.toEncoded(); - qDebug() << "waiting for reply from Ytv"; - emit( busy( true ) ); + qDebug() << "getting route from Ytv"; + + QUrl fullUrl(Ytv::Url); + + QStringList a; + a << q->fromLocation()->longitude() << q->fromLocation()->latitude(); + QStringList b; + b << q->toLocation()->longitude() << q->toLocation()->latitude(); + + fullUrl.addQueryItem("user", Ytv::Username); + fullUrl.addQueryItem("pass", Ytv::Password); + fullUrl.addQueryItem("request", Ytv::Route); + fullUrl.addQueryItem("format", Ytv::Xml); + fullUrl.addQueryItem("language", Ytv::English); + fullUrl.addQueryItem("epsg_in", Ytv::WGS84); + fullUrl.addQueryItem("epsg_out", Ytv::WGS84); + fullUrl.addQueryItem("from", a.join(",")); + fullUrl.addQueryItem("to", b.join(",")); + fullUrl.addQueryItem("show", QString::number(Ytv::ShowFiveResults)); + fullUrl.addQueryItem("walkspeed", QString::number(Ytv::WalkSpeedFast)); + fullUrl.addQueryItem("optimize", QString::number(Ytv::OptimizeLeastWalking)); + + manager->get(QNetworkRequest(fullUrl)); + qDebug() << "getting url" << fullUrl.toEncoded(); + qDebug() << "waiting for reply from Ytv"; + emit(busy(true)); } -void Route::replyFinished( QNetworkReply * reply ) +void Route::replyFinished(QNetworkReply * reply) { - qDebug() << "have reply from Ytv"; - QList routeData = q->parseReply( reply->readAll() ); + qDebug() << "have reply from Ytv"; + QList routeData = q->parseReply(reply->readAll()); - emit( routeReady( routeData ) ); - emit( busy( false ) ); + emit(routeReady(routeData)); + emit(busy(false)); } -void Route::setFromLocation( Location *location ) +void Route::setFromLocation(Location *location) { - qDebug() << "setting new From location (" << location->label() << ")"; - - if ( location && location->isValid() ) { - qDebug() << "From is valid"; - q->setFromLocation( location ); - if ( q->toValid() ) { - qDebug() << "To is also valid"; - getRoute(); + qDebug() << "setting new From location (" << location->label() << ")"; + + if (location && location->isValid()) { + qDebug() << "From is valid"; + q->setFromLocation(location); + if (q->toValid()) { + qDebug() << "To is also valid"; + getRoute(); + } else { + qDebug() << "To not valid - waiting"; + } } else { - qDebug() << "To not valid - waiting"; + qDebug() << "ERROR:From is not valid"; + qDebug() << "location=" << location; + if (location) { + qDebug() << "location->isValid()=" << location->isValid(); + } } - } else { - qDebug() << "ERROR:From is not valid"; - qDebug() << "location=" << location; - if ( location ) { - qDebug() << "location->isValid()=" << location->isValid(); - } - } } Location *Route::fromLocation() const { - return q->fromLocation(); + return q->fromLocation(); } -void Route::setToLocation( Location *location ) +void Route::setToLocation(Location *location) { - qDebug() << "setting new To location (" << location->label() << ")"; - - if ( location && location->isValid() ) { - qDebug() << "To is valid"; - q->setToLocation( location ); - if ( q->fromValid() ) { - qDebug() << "From is also valid"; - getRoute(); + qDebug() << "setting new To location (" << location->label() << ")"; + + if (location && location->isValid()) { + qDebug() << "To is valid"; + q->setToLocation(location); + if (q->fromValid()) { + qDebug() << "From is also valid"; + getRoute(); + } else { + qDebug() << "From not valid - waiting"; + } } else { - qDebug() << "From not valid - waiting"; - } - } else { - qDebug() << "ERROR:From is not valid"; - qDebug() << "location=" << location; - if ( location ) { - qDebug() << "location->isValid()=" << location->isValid(); + qDebug() << "ERROR:From is not valid"; + qDebug() << "location=" << location; + if (location) { + qDebug() << "location->isValid()=" << location->isValid(); + } } - } } Location *Route::toLocation() const { - return q->toLocation(); + return q->toLocation(); } diff --git a/src/route.h b/src/route.h index 9a311b5..0143e7a 100644 --- a/src/route.h +++ b/src/route.h @@ -12,52 +12,52 @@ class RoutePrivate; class Route: public QObject { - Q_OBJECT + Q_OBJECT public: - Route(); - ~Route(); + Route(); + ~Route(); - /*! + /*! * \brief Gets the route data from the server */ - void getRoute(); + void getRoute(); - /*! + /*! \brief Get the from location \return The from location */ - Location *fromLocation() const; + Location *fromLocation() const; - /*! + /*! \brief Get the to location \return The to location */ - Location *toLocation() const; + Location *toLocation() const; public Q_SLOTS: - /*! + /*! * \brief Sets the from location * \param fromLocation The from location */ - void setFromLocation( Location *location=0 ); + void setFromLocation(Location *location=0); - /*! + /*! * \brief Sets the to location * \param toLocation The to location */ - void setToLocation( Location *location=0 ); + void setToLocation(Location *location=0); Q_SIGNALS: - void routeReady( QList ); - void busy( bool busy ); + void routeReady(QList); + void busy(bool busy); private Q_SLOTS: - void replyFinished( QNetworkReply* ); + void replyFinished(QNetworkReply*); private: - RoutePrivate *q; - QNetworkAccessManager *manager; + RoutePrivate *q; + QNetworkAccessManager *manager; }; #endif // ROUTE_H diff --git a/src/route_p.cpp b/src/route_p.cpp index d2125da..2a5f6dc 100644 --- a/src/route_p.cpp +++ b/src/route_p.cpp @@ -1,5 +1,6 @@ #include "route_p.h" #include "location.h" +#include "xmlparser.h" #include #include @@ -8,223 +9,62 @@ #include #include -RoutePrivate::RoutePrivate( QObject *parent ) : +RoutePrivate::RoutePrivate(QObject *parent) : m_fromValid(false), m_toValid(false), m_fromLocation(0), m_toLocation(0) { - Q_UNUSED( parent ) + Q_UNUSED(parent) } RoutePrivate::~RoutePrivate() { } -QList RoutePrivate::parseReply( const QByteArray &reply ) +QList RoutePrivate::parseReply(const QByteArray &reply) { - qDebug() << "parsing route"; + qDebug() << "parsing route/" << reply; - QList retVal; - RouteData routeData; - LegData legData; + XmlParser parser; + QList retVal = parser.parseRouteData(reply); - QXmlStreamReader xml( reply ); - - QHash in; - QHash have; - - QStringList haveKeys; - QStringList inKeys; - - haveKeys - << "LINE" - << "TIME" - << "TRIP" - << "DEPARTURE" - << "ARRIVAL" - ; - - inKeys - << "ROUTE" - << "LINE" - << "STOP" - << "WALK" - << "POINT" - ; - - foreach( QString key, haveKeys ) { - have[ key ] = false; - } - - foreach( QString key, inKeys ) { - in[ key ] = false; - } - - while ( !xml.atEnd() ) { - xml.readNext(); - - QString xmlName = xml.name().toString(); - - if ( xml.isStartElement() ) { - if ( inKeys.contains( xmlName ) ) { - in[ xmlName ] = true; - //qDebug() << "in[" << xmlName << "] = true"; - } - - if ( xmlName == "ROUTE" ) { - foreach( QString key, haveKeys ) { - have[ key ] = false; - } - } - - if ( xmlName == "WALK" ) { - legData.m_how = "WALK"; - have[ "DEPARTURE" ] = false; - have[ "ARRIVAL" ] = false; - have[ "LENGTH" ] = false; - } - - if ( xmlName == "LINE" ) { - legData.m_how = "LINE"; - QString lineCode( xml.attributes().value("code").toString() ); - legData.m_lineCode = parseJORECode( lineCode ); - have[ "DEPARTURE" ] = false; - have[ "ARRIVAL" ] = false; - have[ "LENGTH" ] = false; - } - } - - if ( xml.isEndElement() ) { - if ( inKeys.contains( xmlName ) ) { - in[ xmlName ] = false; - //qDebug() << "in[" << xmlName << "] = false"; - } - - if ( xmlName == "ROUTE" ) { - retVal.append( routeData ); - routeData.clear(); - } - - if ( xmlName == "WALK" || xmlName == "LINE" ) { - routeData.m_legData.append( legData ); - legData.clear(); - have[ "LENGTH" ] = false; - } - } - - if ( !have[ "ARRIVAL" ] && ( in[ "WALK" ] || in[ "LINE" ] ) && ( in[ "STOP" ] || in[ "POINT" ] ) && xml.isStartElement() && xmlName == "ARRIVAL" ) { - QString arrivalTime( xml.attributes().value("time").toString() ); - legData.m_arrivalTime = arrivalTime.rightJustified(4).insert(2,":"); - - // don't set have[ "ARRIVAL" ] since we want the last one of many STOPs - } - - if ( !have[ "DEPARTURE" ] && in[ "LINE" ] && in[ "STOP" ] && xml.isStartElement() && xmlName == "DEPARTURE" ) { - QString departureTime( xml.attributes().value("time").toString() ); - legData.m_departureTime = departureTime.rightJustified(4).insert(2,":"); - - have[ "DEPARTURE" ] = true; - } - - if ( !have[ "DEPARTURE" ] && in[ "WALK" ] && ( in[ "POINT" ] || in[ "STOP" ] ) && xml.isStartElement() && xmlName == "DEPARTURE" ) { - QString departureTime( xml.attributes().value("time").toString() ); - legData.m_departureTime = departureTime.rightJustified(4).insert(2,":"); - - have[ "DEPARTURE" ] = true; - } - - if ( !have[ "LENGTH" ] && ( in[ "WALK" ] || in[ "LINE" ] ) && xml.isStartElement() && xmlName == "LENGTH" ) { - legData.m_tripTime = xml.attributes().value("time").toString(); - legData.m_tripDistance = xml.attributes().value("dist").toString(); - - have[ "LENGTH" ] = true; - } - - if ( !have[ "TRIP" ] && in[ "ROUTE" ] && xml.isStartElement() && xmlName == "LENGTH" ) { - routeData.m_tripTime = xml.attributes().value("time").toString(); - routeData.m_tripDistance = xml.attributes().value("dist").toString(); - - have[ "TRIP" ] = true; - } - - if ( !have[ "LINE" ] && in[ "ROUTE" ] && xml.isStartElement() && xmlName == "LINE" ) { - QString lineCode( xml.attributes().value("code").toString() ); - - routeData.m_lineCode = parseJORECode( lineCode ); - have[ "LINE" ] = true; - } - - if ( !have[ "TIME" ] && in[ "ROUTE" ] && in[ "LINE" ] && in[ "STOP" ] && xmlName == "DEPARTURE" ) { - QString departureTime( xml.attributes().value("time").toString() ); - - routeData.m_departureTime = departureTime.rightJustified(4).insert(2,":"); - have[ "TIME" ] = true; + if (retVal.isEmpty()) { + qDebug() << "no routes found"; + QMaemo5InformationBox::information(0, "no routes found"); } - } - - if ( xml.hasError() ) { - qDebug() << "xml error:" << xml.errorString(); - } - - if ( retVal.isEmpty() ) { - qDebug() << "no routes found"; - QMaemo5InformationBox::information( 0, "no routes found" ); - } - - return retVal; + return retVal; } -void RoutePrivate::setFromLocation( Location *location ) +void RoutePrivate::setFromLocation(Location *location) { - m_fromLocation = location; - m_fromValid = true; + m_fromLocation = location; + m_fromValid = true; } Location *RoutePrivate::fromLocation() const { - return m_fromLocation; -} - -void RoutePrivate::setToLocation( Location *toLocation ) -{ - m_toLocation = toLocation; - m_toValid = true; + return m_fromLocation; } -QString RoutePrivate::parseJORECode( const QString &joreCode ) const +void RoutePrivate::setToLocation(Location *toLocation) { - QString retVal; - - QString areaTransportTypeCode( joreCode.mid(0,1) ); - QString lineCode( joreCode.mid(1,3) ); - QString letterVariant( joreCode.mid(4,1) ); - QString letterNumberVariant( joreCode.mid(5,1) ); - QString direction( joreCode.mid(6,1) ); - - lineCode.setNum( lineCode.toInt() ); - - retVal = lineCode; - - if ( letterVariant != " " ) { - retVal += letterVariant; - } - - return retVal; + m_toLocation = toLocation; + m_toValid = true; } Location *RoutePrivate::toLocation() const { - return m_toLocation; + return m_toLocation; } bool RoutePrivate::fromValid() { - return m_fromValid; + return m_fromValid; } bool RoutePrivate::toValid() { - return m_toValid; + return m_toValid; } diff --git a/src/route_p.h b/src/route_p.h index fddce34..de858ee 100644 --- a/src/route_p.h +++ b/src/route_p.h @@ -9,34 +9,32 @@ class RoutePrivate: public QObject { - Q_OBJECT + Q_OBJECT -public: - RoutePrivate( QObject *parent=0 ); - ~RoutePrivate(); - - QList parseReply( const QByteArray &reply ); + Q_PROPERTY(Location* fromLocation READ fromLocation WRITE setFromLocation) + Q_PROPERTY(Location* toLocation READ toLocation WRITE setToLocation) - Q_PROPERTY(Location* fromLocation READ fromLocation WRITE setFromLocation); - Q_PROPERTY(Location* toLocation READ toLocation WRITE setToLocation); - - void setFromLocation( Location *fromLocation ); +public: + RoutePrivate(QObject *parent=0); + ~RoutePrivate(); - Location *fromLocation() const; + QList parseReply(const QByteArray &reply); - void setToLocation( Location *toLocation ); + void setFromLocation(Location *fromLocation); + Location *fromLocation() const; - Location *toLocation() const; + void setToLocation(Location *toLocation); + Location *toLocation() const; - bool toValid(); - bool fromValid(); + bool toValid(); + bool fromValid(); private: - bool m_fromValid; - bool m_toValid; - Location *m_fromLocation; - Location *m_toLocation; + bool m_fromValid; + bool m_toValid; + Location *m_fromLocation; + Location *m_toLocation; - QString parseJORECode( const QString &joreCode ) const; + QString parseJORECode(const QString &joreCode) const; }; #endif // ROUTE_P_H diff --git a/src/routedata.h b/src/routedata.h index b1bec0b..7fa9a4d 100644 --- a/src/routedata.h +++ b/src/routedata.h @@ -3,88 +3,89 @@ #include #include +#include struct LegData { - LegData() : - m_how(), - m_tripTime(), - m_tripDistance(), - m_departureTime(), - m_arrivalTime(), - m_lineCode() - { - }; + LegData() : + m_how(), + m_tripTime(), + m_tripDistance(), + m_departureTime(), + m_arrivalTime(), + m_lineCode() + { + } - LegData( QString how, QString tripTime, QString tripDistance, QString departureTime, QString arrivalTime, QString lineCode=QString() ) : - m_how(how), - m_tripTime(tripTime), - m_tripDistance(tripDistance), - m_departureTime(departureTime), - m_arrivalTime(arrivalTime), - m_lineCode(lineCode) - { - }; + LegData(QString how, QString tripTime, QString tripDistance, QString departureTime, QString arrivalTime, QString lineCode=QString()) : + m_how(how), + m_tripTime(tripTime), + m_tripDistance(tripDistance), + m_departureTime(departureTime), + m_arrivalTime(arrivalTime), + m_lineCode(lineCode) + { + } - void clear() - { - m_how = ""; - m_tripTime = ""; - m_tripDistance = ""; - m_departureTime = ""; - m_arrivalTime = ""; - m_lineCode = ""; - }; + void clear() + { + m_how = ""; + m_tripTime = ""; + m_tripDistance = ""; + m_departureTime = ""; + m_arrivalTime = ""; + m_lineCode = ""; + } - QString m_how; - QString m_tripTime; - QString m_tripDistance; - QString m_departureTime; - QString m_arrivalTime; - QString m_lineCode; + QString m_how; + QString m_tripTime; + QString m_tripDistance; + QString m_departureTime; + QString m_arrivalTime; + QString m_lineCode; }; struct RouteData { - RouteData(): - m_tripTime(), - m_tripDistance(), - m_departureTime(), - m_lineCode(), - m_legData() - { - }; + RouteData(): + m_tripTime(), + m_tripDistance(), + m_departureTime(), + m_lineCode(), + m_legData() + { + } - RouteData( QString tripTime, QString tripDistance, QString departureTime, QString lineCode ): - m_tripTime(tripTime), - m_tripDistance(tripDistance), - m_departureTime(departureTime), - m_lineCode(lineCode), - m_legData() - { - }; + RouteData(QString tripTime, QString tripDistance, QString departureTime, QString lineCode): + m_tripTime(tripTime), + m_tripDistance(tripDistance), + m_departureTime(departureTime), + m_lineCode(lineCode), + m_legData() + { + } - RouteData &operator <<(const LegData &legData) - { - m_legData.append( legData ); - return *this; - }; + RouteData &operator <<(const LegData &legData) + { + m_legData.append(legData); + return *this; + } - void clear() - { - m_tripTime = ""; - m_tripDistance = ""; - m_departureTime = ""; - m_lineCode = ""; - m_legData.clear(); - }; + void clear() + { + m_tripTime = ""; + m_tripDistance = ""; + m_departureTime = ""; + m_lineCode = ""; + m_legData.clear(); + } - QString m_tripTime; - QString m_tripDistance; - QString m_departureTime; - QString m_lineCode; - QList m_legData; + QString m_tripTime; + QString m_tripDistance; + QString m_departureTime; + QString m_lineCode; + QList m_legData; }; diff --git a/src/ui.cpp b/src/ui.cpp index ee18f3a..6396c83 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -20,11 +20,11 @@ #include Ui::Ui() : - m_centralWidget(0), - m_destinationButtons(0), - m_routeStack(0), - m_usingFakeGps( false ), - m_fakeLocationLabel( "work" ) + m_centralWidget(0), + m_destinationButtons(0), + m_routeStack(0), + m_usingFakeGps(false), + m_fakeLocationLabel("work") { } @@ -32,146 +32,146 @@ Ui::~Ui() { } -void Ui::setupUi( QMainWindow *mainWindow ) +void Ui::setupUi(QMainWindow *mainWindow) { - m_mainWindow = mainWindow; - m_mainWindow->resize(800,480); - - m_menu = mainWindow->menuBar()->addMenu("Settings"); - - QAction *setHomeAddressAction = new QAction("Set home address", this); - QAction *setWorkAddressAction = new QAction("Set work address", this); - m_toggleFakeGpsAction = new QAction("Use fake GPS", this); - m_menu->addAction(setHomeAddressAction); - m_menu->addAction(setWorkAddressAction); - m_menu->addAction(m_toggleFakeGpsAction); - - connect( - setHomeAddressAction, SIGNAL(triggered()), - this, SLOT(setHomeAddress()) - ); - connect( - setWorkAddressAction, SIGNAL(triggered()), - this, SLOT(setWorkAddress()) - ); - connect( - m_toggleFakeGpsAction, SIGNAL(triggered()), - this, SLOT(toggleFakeGps()) - ); - - m_centralWidget = new QWidget( m_mainWindow ); - m_mainWindow->setCentralWidget( m_centralWidget); - - QRadioButton *homeButton = new QRadioButton(); - homeButton->setObjectName( QString::fromUtf8("homeButton") ); - homeButton->setText( "GPS->HOME" ); - homeButton->setEnabled(false); - - QRadioButton *workButton = new QRadioButton(); - workButton->setObjectName( QString::fromUtf8("workButton") ); - workButton->setText( "GPS->WORK" ); - workButton->setEnabled(false); - - m_destinationButtons = new QButtonGroup(); - m_destinationButtons->addButton( homeButton, HomeButtonId ); - m_destinationButtons->addButton( workButton, WorkButtonId ); - m_destinationButtons->setExclusive( true ); - - m_routeButtons = new QButtonGroup(); - m_routeButtons->setExclusive( true ); - m_routeStack = new QVBoxLayout(); - for ( int i=0; isetObjectName( "routeButton"+i ); - button->setEnabled( false ); - - m_routeStack->addWidget( button, i ); - m_routeButtons->addButton( button, i ); - } - m_routeStack->addStretch(); - - QStringList headers( QStringList() << "How" << "Time" << "Dist" << "Dep" << "Arr" ); - m_routeDetailTable = new QTableWidget(); - m_routeDetailTable->setColumnCount( headers.count() ); - m_routeDetailTable->setHorizontalHeaderLabels( headers ); - m_routeDetailTable->resizeColumnsToContents(); - m_routeDetailTable->setSelectionMode( QAbstractItemView::NoSelection ); - - QHBoxLayout *topLayout = new QHBoxLayout(); - topLayout->addLayout( m_routeStack ); - topLayout->addWidget( m_routeDetailTable ); - - m_buttonLayout = new QGridLayout(); - m_buttonLayout->addWidget( homeButton, 0, 0 ); - m_buttonLayout->addWidget( workButton, 0, 1 ); - - m_mainLayout = new QVBoxLayout(); - m_mainLayout->addLayout( topLayout ); - m_mainLayout->addLayout( m_buttonLayout ); - - m_centralWidget->setLayout( m_mainLayout ); + m_mainWindow = mainWindow; + m_mainWindow->resize(800,480); + + m_menu = mainWindow->menuBar()->addMenu("Settings"); + + QAction *setHomeAddressAction = new QAction("Set home address", this); + QAction *setWorkAddressAction = new QAction("Set work address", this); + m_toggleFakeGpsAction = new QAction("Use fake GPS", this); + m_menu->addAction(setHomeAddressAction); + m_menu->addAction(setWorkAddressAction); + m_menu->addAction(m_toggleFakeGpsAction); + + connect( + setHomeAddressAction, SIGNAL(triggered()), + this, SLOT(setHomeAddress()) + ); + connect( + setWorkAddressAction, SIGNAL(triggered()), + this, SLOT(setWorkAddress()) + ); + connect( + m_toggleFakeGpsAction, SIGNAL(triggered()), + this, SLOT(toggleFakeGps()) + ); + + m_centralWidget = new QWidget(m_mainWindow); + m_mainWindow->setCentralWidget(m_centralWidget); + + QRadioButton *homeButton = new QRadioButton(); + homeButton->setObjectName(QString::fromUtf8("homeButton")); + homeButton->setText("GPS->HOME"); + homeButton->setEnabled(false); + + QRadioButton *workButton = new QRadioButton(); + workButton->setObjectName(QString::fromUtf8("workButton")); + workButton->setText("GPS->WORK"); + workButton->setEnabled(false); + + m_destinationButtons = new QButtonGroup(); + m_destinationButtons->addButton(homeButton, HomeButtonId); + m_destinationButtons->addButton(workButton, WorkButtonId); + m_destinationButtons->setExclusive(true); + + m_routeButtons = new QButtonGroup(); + m_routeButtons->setExclusive(true); + m_routeStack = new QVBoxLayout(); + for (int i=0; isetObjectName("routeButton"+i); + button->setEnabled(false); + + m_routeStack->addWidget(button, i); + m_routeButtons->addButton(button, i); + } + m_routeStack->addStretch(); + + QStringList headers(QStringList() << "How" << "Time" << "Dist" << "Dep" << "Arr"); + m_routeDetailTable = new QTableWidget(); + m_routeDetailTable->setColumnCount(headers.count()); + m_routeDetailTable->setHorizontalHeaderLabels(headers); + m_routeDetailTable->resizeColumnsToContents(); + m_routeDetailTable->setSelectionMode(QAbstractItemView::NoSelection); + + QHBoxLayout *topLayout = new QHBoxLayout(); + topLayout->addLayout(m_routeStack); + topLayout->addWidget(m_routeDetailTable); + + m_buttonLayout = new QGridLayout(); + m_buttonLayout->addWidget(homeButton, 0, 0); + m_buttonLayout->addWidget(workButton, 0, 1); + + m_mainLayout = new QVBoxLayout(); + m_mainLayout->addLayout(topLayout); + m_mainLayout->addLayout(m_buttonLayout); + + m_centralWidget->setLayout(m_mainLayout); } void Ui::setHomeAddress() { - setAddress( "home" ); + setAddress("home"); } void Ui::setWorkAddress() { - setAddress( "work" ); + setAddress("work"); } void Ui::toggleFakeGps() { - m_usingFakeGps = !m_usingFakeGps; + m_usingFakeGps = !m_usingFakeGps; - if ( m_usingFakeGps ) { - useFakeGps(); - } else { - useLiveGps(); - } + if (m_usingFakeGps) { + useFakeGps(); + } else { + useLiveGps(); + } } void Ui::useFakeGps() { - emit fakeGpsPressed( m_fakeLocationLabel ); - m_toggleFakeGpsAction->setText( "Use Live GPS" ); + emit fakeGpsPressed(m_fakeLocationLabel); + m_toggleFakeGpsAction->setText("Use Live GPS"); } void Ui::useLiveGps() { - emit liveGpsPressed(); - m_toggleFakeGpsAction->setText( "Use Fake GPS" ); + emit liveGpsPressed(); + m_toggleFakeGpsAction->setText("Use Fake GPS"); } -void Ui::setAddress( const QString &label ) +void Ui::setAddress(const QString &label) { - Locations locations; - Location *location=locations.location( label ); - - bool ok; - QString address = QInputDialog::getText( - m_centralWidget, - tr("Enter address for \""+QString(label).toLatin1()+"\""), - tr("Address"), - QLineEdit::Normal, - location->address(), - &ok - ); - - if ( ok ) { - qDebug() << "new address" << address; Locations locations; - Location *location = locations.location( label ); - qDebug() << "location" << location; - if ( location ) { - location->resolveAddress( address ); + Location *location=locations.location(label); + + bool ok; + QString address = QInputDialog::getText( + m_centralWidget, + tr("Enter address for \""+QString(label).toLatin1()+"\""), + tr("Address"), + QLineEdit::Normal, + location->address(), + &ok + ); + + if (ok) { + qDebug() << "new address" << address; + Locations locations; + Location *location = locations.location(label); + qDebug() << "location" << location; + if (location) { + location->resolveAddress(address); + } } - } } -void Ui::setBusy( bool busy ) +void Ui::setBusy(bool busy) { - m_mainWindow->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, busy); + m_mainWindow->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, busy); } diff --git a/src/ui.h b/src/ui.h index 94dc687..312703d 100644 --- a/src/ui.h +++ b/src/ui.h @@ -16,52 +16,52 @@ class Location; class Ui : public QObject { - Q_OBJECT + Q_OBJECT public: - Ui(); - ~Ui(); - void setupUi( QMainWindow *mainWindow ); + Ui(); + ~Ui(); + void setupUi(QMainWindow *mainWindow); - enum { - HomeButtonId=0, - WorkButtonId=1 - }; + enum { + HomeButtonId=0, + WorkButtonId=1 + }; - enum { - ScreenWidth=800, - ScreenHeight=480 - }; + enum { + ScreenWidth=800, + ScreenHeight=480 + }; - QMainWindow *m_mainWindow; - QWidget *m_centralWidget; - QButtonGroup *m_destinationButtons; - QButtonGroup *m_routeButtons; - QVBoxLayout *m_routeStack; - QTableWidget *m_routeDetailTable; - QVBoxLayout *m_mainLayout; - QGridLayout *m_buttonLayout; - QMenu *m_menu; - QAction *m_toggleFakeGpsAction; - QAction *m_useLiveGpsAction; - bool m_usingFakeGps; - QString m_fakeLocationLabel; + QMainWindow *m_mainWindow; + QWidget *m_centralWidget; + QButtonGroup *m_destinationButtons; + QButtonGroup *m_routeButtons; + QVBoxLayout *m_routeStack; + QTableWidget *m_routeDetailTable; + QVBoxLayout *m_mainLayout; + QGridLayout *m_buttonLayout; + QMenu *m_menu; + QAction *m_toggleFakeGpsAction; + QAction *m_useLiveGpsAction; + bool m_usingFakeGps; + QString m_fakeLocationLabel; Q_SIGNALS: - void homeAddressChanged( QString address ); - void workAddressChanged( QString address ); - void fakeGpsPressed( const QString &fakeLocationLabel ); - void liveGpsPressed(); + void homeAddressChanged(QString address); + void workAddressChanged(QString address); + void fakeGpsPressed(const QString &fakeLocationLabel); + void liveGpsPressed(); private Q_SLOTS: - void setHomeAddress(); - void setWorkAddress(); - void toggleFakeGps(); - void setBusy( bool busy ); + void setHomeAddress(); + void setWorkAddress(); + void toggleFakeGps(); + void setBusy(bool busy); private: - void useFakeGps(); - void useLiveGps(); - void setAddress( const QString &label ); + void useFakeGps(); + void useLiveGps(); + void setAddress(const QString &label); }; #endif //UI_H diff --git a/src/uicontroller.cpp b/src/uicontroller.cpp index 8365378..e26109f 100644 --- a/src/uicontroller.cpp +++ b/src/uicontroller.cpp @@ -13,77 +13,77 @@ #include #include -UiController::UiController( Ui *ui ) : - m_routeData(), - m_destination(), - m_ui(ui), - m_currentDestination(-1), - m_currentRoute(-1) +UiController::UiController(Ui *ui) : + m_locations(new Locations), + m_routeData(), + m_destination(), + m_ui(ui), + m_currentDestination(-1), + m_currentRoute(-1) { - Locations locations; - Location *homeLocation = locations.location( "home" ); - Location *workLocation = locations.location( "work" ); - - if ( homeLocation==0 ) { - homeLocation = new Location( "home" ); - locations.addLocation( homeLocation ); - } else if ( homeLocation->isValid() ) { - setHomeButtonValid(); - } - - if ( workLocation==0 ) { - workLocation = new Location( "work" ); - locations.addLocation( workLocation ); - } else if ( workLocation->isValid() ) { - setWorkButtonValid(); - } - - connect( - homeLocation, SIGNAL( becomeValid() ), - this, SLOT( setHomeButtonValid() ) - ); - connect( - homeLocation, SIGNAL( becomeInValid() ), - this, SLOT( setHomeButtonInValid() ) - ); - connect( - homeLocation, SIGNAL( becomeValid() ), - &locations, SLOT( saveLocation() ) - ); - connect( - homeLocation, SIGNAL( busy( bool ) ), - ui, SLOT( setBusy( bool ) ) - ); - - connect( - workLocation, SIGNAL( becomeValid() ), - this, SLOT( setWorkButtonValid() ) - ); - connect( - workLocation, SIGNAL( becomeInValid() ), - this, SLOT( setWorkButtonInValid() ) - ); - connect( - workLocation, SIGNAL( becomeValid() ), - &locations, SLOT( saveLocation() ) - ); - connect( - workLocation, SIGNAL( busy( bool ) ), - ui, SLOT( setBusy( bool ) ) - ); - - m_destination.append( homeLocation ); - m_destination.append( workLocation ); - - connect( - m_ui->m_destinationButtons, SIGNAL( buttonClicked( int ) ), - this, SLOT( changeDestination( int ) ) - ); - - connect( - m_ui->m_routeButtons, SIGNAL( buttonClicked( int ) ), - this, SLOT( changeRoute( int ) ) - ); + Location *homeLocation = m_locations->location("home"); + Location *workLocation = m_locations->location("work"); + + if (homeLocation==0) { + homeLocation = new Location("home"); + m_locations->addLocation(homeLocation); + } else if (homeLocation->isValid()) { + setHomeButtonValid(); + } + + if (workLocation==0) { + workLocation = new Location("work"); + m_locations->addLocation(workLocation); + } else if (workLocation->isValid()) { + setWorkButtonValid(); + } + + connect( + homeLocation, SIGNAL(becomeValid()), + this, SLOT(setHomeButtonValid()) + ); + connect( + homeLocation, SIGNAL(becomeInValid()), + this, SLOT(setHomeButtonInValid()) + ); + connect( + homeLocation, SIGNAL(becomeValid()), + m_locations, SLOT(saveLocation()) + ); + connect( + homeLocation, SIGNAL(busy(bool)), + ui, SLOT(setBusy(bool)) + ); + + connect( + workLocation, SIGNAL(becomeValid()), + this, SLOT(setWorkButtonValid()) + ); + connect( + workLocation, SIGNAL(becomeInValid()), + this, SLOT(setWorkButtonInValid()) + ); + connect( + workLocation, SIGNAL(becomeValid()), + m_locations, SLOT(saveLocation()) + ); + connect( + workLocation, SIGNAL(busy(bool)), + ui, SLOT(setBusy(bool)) + ); + + m_destination.append(homeLocation); + m_destination.append(workLocation); + + connect( + m_ui->m_destinationButtons, SIGNAL(buttonClicked(int)), + this, SLOT(changeDestination(int)) + ); + + connect( + m_ui->m_routeButtons, SIGNAL(buttonClicked(int)), + this, SLOT(changeRoute(int)) + ); } UiController::~UiController() @@ -92,128 +92,128 @@ UiController::~UiController() void UiController::setHomeButtonInValid() { - qDebug() << "setting home button invalid"; - setButtonValid( Ui::HomeButtonId, false ); + qDebug() << "setting home button invalid"; + setButtonValid(Ui::HomeButtonId, false); } void UiController::setHomeButtonValid() { - qDebug() << "setting home button valid"; - setButtonValid( Ui::HomeButtonId, true ); + qDebug() << "setting home button valid"; + setButtonValid(Ui::HomeButtonId, true); } void UiController::setWorkButtonInValid() { - qDebug() << "setting work button invalid"; - setButtonValid( Ui::WorkButtonId, false ); + qDebug() << "setting work button invalid"; + setButtonValid(Ui::WorkButtonId, false); } void UiController::setWorkButtonValid() { - qDebug() << "setting work button valid"; - setButtonValid( Ui::WorkButtonId, true ); + qDebug() << "setting work button valid"; + setButtonValid(Ui::WorkButtonId, true); } -void UiController::setButtonValid( int id, bool isValid ) +void UiController::setButtonValid(int id, bool isValid) { - m_ui->m_destinationButtons->button( id )->setEnabled( isValid ); + m_ui->m_destinationButtons->button(id)->setEnabled(isValid); } -void UiController::changeDestination( int id ) +void UiController::changeDestination(int id) { - bool destinationHasChanged = ( m_currentDestination != id ); - qDebug() << "Destination has changed=" << destinationHasChanged; - if ( destinationHasChanged ) { - qDebug() << "Emitting destination changed (" << m_destination[id]->label() << ")"; - emit destinationChanged( m_destination[id] ); - m_currentDestination = id; - } - - // always want to emit this so that the gps position is updated - // and the user gets new information - emit buttonClicked(); + bool destinationHasChanged = (m_currentDestination != id); + qDebug() << "Destination has changed=" << destinationHasChanged; + if (destinationHasChanged) { + qDebug() << "Emitting destination changed (" << m_destination[id]->label() << ")"; + emit destinationChanged(m_destination[id]); + m_currentDestination = id; + } + + // always want to emit this so that the gps position is updated + // and the user gets new information + emit buttonClicked(); } -void UiController::changeRoute( int id ) +void UiController::changeRoute(int id) { - bool routeHasChanged = ( m_currentRoute != id ); - if ( routeHasChanged ) { - displayRouteDetail( id ); - } + bool routeHasChanged = (m_currentRoute != id); + if (routeHasChanged) { + displayRouteDetail(id); + } } -void UiController::displayRouteDetail( int id ) +void UiController::displayRouteDetail(int id) { - QTableWidget *table = m_ui->m_routeDetailTable; - - if ( id < m_routeData.count() ) { - QList &legDataList = m_routeData[ id ].m_legData; - table->setRowCount( legDataList.count() ); - - int row=0; - foreach( LegData thisLegData, legDataList ) { - QString thisHow = thisLegData.m_how; - - bool thisIsLine = ( thisHow == "LINE" ); - if ( thisIsLine ) { - thisHow = thisLegData.m_lineCode; - } - - QStringList tableStrings; - tableStrings - << thisHow - << thisLegData.m_tripTime - << thisLegData.m_tripDistance - << thisLegData.m_departureTime - << thisLegData.m_arrivalTime; - - int col=0; - foreach( QString thisString, tableStrings ) { - QTableWidgetItem *newItem = new QTableWidgetItem(); - newItem->setText( thisString ); - table->setItem( row,col, newItem ); - ++col; - } - - ++row; + QTableWidget *table = m_ui->m_routeDetailTable; + + if (id < m_routeData.count()) { + QList &legDataList = m_routeData[ id ].m_legData; + table->setRowCount(legDataList.count()); + + int row=0; + foreach(LegData thisLegData, legDataList) { + QString thisHow = thisLegData.m_how; + + bool notWalk = (thisHow != "walk"); + if (notWalk) { + thisHow = thisLegData.m_lineCode; + } + + QStringList tableStrings; + tableStrings + << thisHow + << thisLegData.m_tripTime + << thisLegData.m_tripDistance + << thisLegData.m_departureTime + << thisLegData.m_arrivalTime; + + int col=0; + foreach(QString thisString, tableStrings) { + QTableWidgetItem *newItem = new QTableWidgetItem(); + newItem->setText(thisString); + table->setItem(row,col, newItem); + ++col; + } + + ++row; + } + } else { + table->setRowCount(0); } - } else { - table->setRowCount( 0 ); - } - table->resizeColumnsToContents(); + table->resizeColumnsToContents(); } -void UiController::displayRoute( const QList &routeData ) +void UiController::displayRoute(const QList &routeData) { - m_routeData = routeData; + m_routeData = routeData; - qDebug() << "displaying route"; + qDebug() << "displaying route"; - for ( int i=0; im_routeStack->itemAt( i )->widget(); - QRadioButton *button = qobject_cast(widget); + QWidget *widget = m_ui->m_routeStack->itemAt(i)->widget(); + QRadioButton *button = qobject_cast(widget); - if ( isetEnabled( true ); - } else { - button->setEnabled( false ); - } + if (isetEnabled(true); + } else { + button->setEnabled(false); + } - if ( i==0 ) { - button->setChecked( true ); - } else { - button->setChecked( false ); - } + if (i==0) { + button->setChecked(true); + } else { + button->setChecked(false); + } - button->setText( label ); - } + button->setText(label); + } - displayRouteDetail( 0 ); + displayRouteDetail(0); } diff --git a/src/uicontroller.h b/src/uicontroller.h index 7cbbbf5..d669dda 100644 --- a/src/uicontroller.h +++ b/src/uicontroller.h @@ -7,40 +7,41 @@ #include class Ui; +class Locations; class UiController : public QObject { - Q_OBJECT + Q_OBJECT public: - UiController( Ui *ui ); - ~UiController(); + UiController(Ui *ui); + ~UiController(); public Q_SLOTS: - void displayRoute( const QList &routeData ); + void displayRoute(const QList &routeData); Q_SIGNALS: - void buttonClicked(); - void destinationChanged( Location *newDestination ); + void buttonClicked(); + void destinationChanged(Location *newDestination); private Q_SLOTS: - void changeDestination( int id ); - void changeRoute( int id ); - void setHomeButtonValid(); - void setWorkButtonValid(); - void setHomeButtonInValid(); - void setWorkButtonInValid(); - void displayRouteDetail( int id ); + void changeDestination(int id); + void changeRoute(int id); + void setHomeButtonValid(); + void setWorkButtonValid(); + void setHomeButtonInValid(); + void setWorkButtonInValid(); + void displayRouteDetail(int id); private: - void setButtonValid( int id, bool isValid ); + void setButtonValid(int id, bool isValid); private: - QList m_routeData; - QList m_destination; - Ui *m_ui; - int m_currentDestination; - int m_currentRoute; + Locations *m_locations; + QList m_routeData; + QList m_destination; + Ui *m_ui; + int m_currentDestination; + int m_currentRoute; }; #endif // UICONTROLLER_H - diff --git a/src/xmlparser.cpp b/src/xmlparser.cpp new file mode 100644 index 0000000..7e82322 --- /dev/null +++ b/src/xmlparser.cpp @@ -0,0 +1,293 @@ +#include "xmlparser.h" +#include "routedata.h" + +#include +#include +#include +#include +#include +#include +#include + +XmlParser::XmlParser() +{ +} + +QList XmlParser::parseLocs(QXmlStreamReader &xml) +{ + QList retVal; + retVal.clear(); + + QSet elements; + elements + << "coord" + << "x" + << "y" + << "arrTime" + << "depTime" + << "name"; + + QString name; + + while (xml.readNextStartElement()) { + QHash text; + + while (xml.readNextStartElement()) { + if (xml.name() == "coord") { + xml.readNextStartElement(); + // x + text.insert(xml.name().toString(),xml.readElementText()); + + xml.readNextStartElement(); + // y + text.insert(xml.name().toString(),xml.readElementText()); + + xml.readNextStartElement(); // up a level + } else { + text.insert(xml.name().toString(),xml.readElementText()); + } + } + + LocsData data; + data.m_x = text.value("x"); + data.m_y = text.value("y"); + data.m_arrTime = text.value("arrTime"); + data.m_depTime = text.value("depTime"); + data.m_name = text.value("name"); + + retVal << data; + } + + return retVal; +} + +QList XmlParser::parseLegs(QXmlStreamReader &xml) +{ + QList retVal; + + while (xml.readNextStartElement()) { // loop over leg s + QString how; + QString tripTime; + QString tripDistance; + QString departureTime; + QString arrivalTime; + QString lineCode; + + if (xml.name() == "node") { // new leg + xml.readNextStartElement(); + + if (xml.name() == "length") { + tripDistance = xml.readElementText(); + } + + xml.readNextStartElement(); + + if (xml.name() == "duration") { + tripTime = xml.readElementText(); + } + + xml.readNextStartElement(); + + if (xml.name() == "type") { + how = parseType(xml.readElementText()); + } + + xml.readNextStartElement(); + + if (xml.name() == "code") { // only if type != walk + lineCode = xml.readElementText(); + + xml.readNextStartElement(); + } + + if (xml.name() == "locs") { + QList locs = parseLocs(xml); + arrivalTime = parseTime(locs[0].m_arrTime); + departureTime = parseTime(locs[0].m_depTime); + + LegData legData; + + legData.m_arrivalTime = arrivalTime; + legData.m_departureTime = departureTime; + legData.m_how = how; + legData.m_lineCode = parseJORECode(lineCode); + legData.m_tripDistance = tripDistance; + legData.m_tripTime = tripTime; + + retVal << legData; + + xml.skipCurrentElement(); + } + } + } + + return retVal; +} + +QList XmlParser::parseRouteData(const QByteArray &reply) +{ + QList retVal; + + QXmlStreamReader xml(reply); + + // find response + while (!xml.atEnd()) { + xml.readNext(); + + if (xml.name() == "response") { + + while (xml.readNextStartElement()) { // loop over route + RouteData routeData; + + if (xml.name() == "node") { // ROUTE node + + xml.readNextStartElement(); // redundant single + + xml.readNextStartElement(); + + if (xml.name() == "length") { + routeData.m_tripDistance = xml.readElementText(); + } + + xml.readNextStartElement(); + + if (xml.name() == "duration") { + routeData.m_tripTime = xml.readElementText(); + } + + xml.readNextStartElement(); + + if (xml.name() == "legs") { + QList legData = parseLegs(xml); + + foreach (LegData thisLeg, legData) { + // set the departure time of the Route to the departure time of the + // first non-walk (usually the bus) + if (thisLeg.m_how != "walk" && routeData.m_departureTime.isEmpty()) { + routeData.m_departureTime = thisLeg.m_departureTime; + routeData.m_lineCode = thisLeg.m_lineCode; + } + + routeData << thisLeg; + } + + xml.skipCurrentElement(); + } + } + + retVal << routeData; + routeData.clear(); + + xml.readNext(); + } + } + } + + if (xml.hasError()) { + qDebug() << "xml error:" << xml.errorString(); + } + + return retVal; +} + +QPair XmlParser::parseGeocode(const QByteArray &reply) +{ + QPair retVal; + + m_error = false; + + QXmlStreamReader xml(reply); + + while (!xml.atEnd()) { + xml.readNext(); + + if (xml.name() == "coords") { + QString text(xml.readElementText()); + + QStringList coords(text.split(",")); + + QString newLongitude(coords.at(0)); + QString newLatitude(coords.at(1)); + + retVal.first = newLongitude; + retVal.second = newLatitude; + + break; + } + + if (xml.name() == "ERROR") { + qDebug() << "ERROR"; + m_error = true; + } + } + + if (m_error) { + qDebug() << "xml error"; + } + + return retVal; +} + +QString XmlParser::parseJORECode(const QString &joreCode) const +{ + QString retVal; + + QString areaTransportTypeCode(joreCode.mid(0,1)); + QString lineCode(joreCode.mid(1,3)); + QString letterVariant(joreCode.mid(4,1)); + QString letterNumberVariant(joreCode.mid(5,1)); + QString direction(joreCode.mid(6,1)); + + Q_UNUSED(areaTransportTypeCode); + Q_UNUSED(letterNumberVariant); + Q_UNUSED(direction); + + lineCode.setNum(lineCode.toInt()); + + retVal = lineCode; + + if (letterVariant != " ") { + retVal += letterVariant; + } + + return retVal; +} + +QString XmlParser::parseTime(const QString &time) const +{ + QString retVal = time.right(4).insert(2,":"); + + return retVal; +} + +QString XmlParser::parseType(const QString &type) const +{ + QString retVal; + QStringList transportType; + transportType + << "Helsi" + << "Trams" + << "Espoo" + << "Vanta" + << "Regio" + << "Metro" + << "Ferry" + << "ULine" + << "CTrai" + << "HelSe" + << "HelNi" + << "EspSe" + << "VanSe" + << "RegNi" + << "Kirkk" + << "Kerav" + ; + + if (type=="walk") { + retVal = "walk"; + } else { + retVal = transportType.at(type.toInt()-1); + } + + return retVal; +} diff --git a/src/xmlparser.h b/src/xmlparser.h new file mode 100644 index 0000000..a74a955 --- /dev/null +++ b/src/xmlparser.h @@ -0,0 +1,40 @@ +#ifndef XMLPARSER_H +#define XMLPARSER_H + +#include "routedata.h" + +#include +#include +#include + +class XmlParser +{ +public: + XmlParser(); + + struct LocsData { + QString m_x; + QString m_y; + QString m_arrTime; + QString m_depTime; + QString m_name; + }; + + QPair parseGeocode(const QByteArray &reply); + QList parseRouteData(const QByteArray &reply); + + bool error() { + return m_error; + } + +private: + QList parseLocs(QXmlStreamReader &xml); + QList parseLegs(QXmlStreamReader &xml); + QString parseJORECode(const QString &joreCode) const; + QString parseTime(const QString &time) const; + QString parseType(const QString &type) const; + + bool m_error; +}; + +#endif // XMLPARSER_H diff --git a/src/ytv.h b/src/ytv.h index 9e34102..86645bb 100644 --- a/src/ytv.h +++ b/src/ytv.h @@ -2,34 +2,34 @@ #include namespace Ytv { - const QString Url( "http://api.reittiopas.fi/public-ytv/fi/api/" ); - const QString Username( "zouba" ); - const QString Password( "caf9r3ee" ); + const QString Url("http://api.reittiopas.fi/hsl/prod/"); + const QString Username("zouba"); + const QString Password("caf9r3ee"); + const QString Geocode("geocode"); + const QString Route("route"); + const QString Xml("xml"); + const QString English("en"); + const QString WGS84("wgs84"); - //const QString Home( QByteArray::fromPercentEncoding( "Taivaanvuohentie%207%2CHelsinki" ) ); - //const QString Work( QByteArray::fromPercentEncoding( "It%E4merenkatu%2011%2CHelsinki" ) ); + enum { + WalkSpeedSlow=1, + WalkSpeedFast=2, + WalkSpeedNormal=3, + WalkSpeedRunning=4, + WalkSpeedCycling=5, + NoWalkSpeeds=5 + }; - enum { - WalkSpeedSlow=1, - WalkSpeedFast=2, - WalkSpeedNormal=3, - WalkSpeedRunning=4, - WalkSpeedCycling=5, - NoWalkSpeeds=5 - }; - - enum { - ShowOneResult=1, - ShowThreeResults=3, - ShowFiveResults=5 - }; - - enum { - OptimizeDefault=1, - OptimizeFastest=2, - OptimizeLeastTransfers=3, - OptimizeLeastWalking=4 - }; + enum { + ShowOneResult=1, + ShowThreeResults=3, + ShowFiveResults=5 + }; + enum { + OptimizeDefault=1, + OptimizeFastest=2, + OptimizeLeastTransfers=3, + OptimizeLeastWalking=4 + }; }; - diff --git a/tests/routeParserTest/main.cpp b/tests/routeParserTest/main.cpp new file mode 100644 index 0000000..b28c9ab --- /dev/null +++ b/tests/routeParserTest/main.cpp @@ -0,0 +1,55 @@ +#include "../../src/xmlparser.h" + +#include +#include +#include +#include +#include + +QDebug operator <<(QDebug dbg, const RouteData &routeData) +{ + QStringList routeDataBits; + routeDataBits + << routeData.m_tripTime + << routeData.m_tripDistance + << routeData.m_departureTime + << routeData.m_lineCode; + QStringList legDataBits; + + foreach(LegData legData, routeData.m_legData) { + legDataBits + << legData.m_arrivalTime + << legData.m_departureTime + << legData.m_how + << legData.m_lineCode + << legData.m_tripDistance + << legData.m_tripTime; + } + + dbg.nospace() << "[" + << routeDataBits.join(", ") + << " [" << legDataBits.join(", ") << "] " + << "]"; + + return dbg.space(); +} + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc,argv); + + QFile file("routeResponse.xml"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return 0; + + QByteArray reply = file.readAll(); + + XmlParser parser; + QList nodes = parser.parseRouteData(reply); + + foreach(RouteData node, nodes) { + qDebug() << node; + } + + return 0; +} diff --git a/tests/routeParserTest/routeParserTest.pro b/tests/routeParserTest/routeParserTest.pro new file mode 100644 index 0000000..aace932 --- /dev/null +++ b/tests/routeParserTest/routeParserTest.pro @@ -0,0 +1,12 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Sat May 28 12:35:33 2011 +###################################################################### + +TEMPLATE = app +TARGET = +INCLUDEPATH += . ../../src +DEPENDPATH += . $INCLUDEPATH + +# Input +HEADERS += ../../src/xmlparser.h +SOURCES += main.cpp ../../src/xmlparser.cpp diff --git a/tests/routeParserTest/routeResponse-2-pretty.xml b/tests/routeParserTest/routeResponse-2-pretty.xml new file mode 100644 index 0000000..32a5893 --- /dev/null +++ b/tests/routeParserTest/routeResponse-2-pretty.xml @@ -0,0 +1,258 @@ + + + + + 389.183 + 240 + + + 389 + 288.12 + walk + + + + 24.8843991291 + 60.1612003139 + + 201105291827 + 201105291827 + + + + + 24.8811518377 + 60.1618691039 + + 201105291830 + 201105291830 + + + + + 24.8820872616 + 60.1624328568 + + 201105291831 + 201105291831 + + + + + 24.8825483159 + 60.1618275013 + + 201105291831 + 201105291831 + + + + + + + + + + 389.183 + 240 + + + 389 + 288.12 + walk + + + + 24.8843991291 + 60.1612003139 + + 201105291828 + 201105291828 + + + + + 24.8811518377 + 60.1618691039 + + 201105291831 + 201105291831 + + + + + 24.8820872616 + 60.1624328568 + + 201105291832 + 201105291832 + + + + + 24.8825483159 + 60.1618275013 + + 201105291832 + 201105291832 + + + + + + + + + + 389.183 + 240 + + + 389 + 288.12 + walk + + + + 24.8843991291 + 60.1612003139 + + 201105291829 + 201105291829 + + + + + 24.8811518377 + 60.1618691039 + + 201105291832 + 201105291832 + + + + + 24.8820872616 + 60.1624328568 + + 201105291833 + 201105291833 + + + + + 24.8825483159 + 60.1618275013 + + 201105291833 + 201105291833 + + + + + + + + + + 389.183 + 240 + + + 389 + 288.12 + walk + + + + 24.8843991291 + 60.1612003139 + + 201105291830 + 201105291830 + + + + + 24.8811518377 + 60.1618691039 + + 201105291833 + 201105291833 + + + + + 24.8820872616 + 60.1624328568 + + 201105291834 + 201105291834 + + + + + 24.8825483159 + 60.1618275013 + + 201105291834 + 201105291834 + + + + + + + + + + 389.183 + 240 + + + 389 + 288.12 + walk + + + + 24.8843991291 + 60.1612003139 + + 201105291831 + 201105291831 + + + + + 24.8811518377 + 60.1618691039 + + 201105291834 + 201105291834 + + + + + 24.8820872616 + 60.1624328568 + + 201105291835 + 201105291835 + + + + + 24.8825483159 + 60.1618275013 + + 201105291835 + 201105291835 + + + + + + + + diff --git a/tests/routeParserTest/routeResponse-2.xml b/tests/routeParserTest/routeResponse-2.xml new file mode 100644 index 0000000..05a4cc5 --- /dev/null +++ b/tests/routeParserTest/routeResponse-2.xml @@ -0,0 +1 @@ +389.183240389288.12walk24.884399129160.161200313920110529182720110529182724.881151837760.161869103920110529183020110529183024.882087261660.162432856820110529183120110529183124.882548315960.1618275013201105291831201105291831389.183240389288.12walk24.884399129160.161200313920110529182820110529182824.881151837760.161869103920110529183120110529183124.882087261660.162432856820110529183220110529183224.882548315960.1618275013201105291832201105291832389.183240389288.12walk24.884399129160.161200313920110529182920110529182924.881151837760.161869103920110529183220110529183224.882087261660.162432856820110529183320110529183324.882548315960.1618275013201105291833201105291833389.183240389288.12walk24.884399129160.161200313920110529183020110529183024.881151837760.161869103920110529183320110529183324.882087261660.162432856820110529183420110529183424.882548315960.1618275013201105291834201105291834389.183240389288.12walk24.884399129160.161200313920110529183120110529183124.881151837760.161869103920110529183420110529183424.882087261660.162432856820110529183520110529183524.882548315960.1618275013201105291835201105291835 diff --git a/tests/routeParserTest/routeResponse-pretty.xml b/tests/routeParserTest/routeResponse-pretty.xml new file mode 100644 index 0000000..2e7c0a7 --- /dev/null +++ b/tests/routeParserTest/routeResponse-pretty.xml @@ -0,0 +1,1159 @@ + + + + + 3972.706 + 1200 + + + 166 + 122.64 + walk + + + + 24.8843991291 + 60.1612003139 + + 201105291723 + 201105291723 + + + + + 24.8849737013 + 60.161135443 + + 201105291724 + 201105291724 + Koillisvyl + + + + 24.8851061757 + 60.1607037122 + + 201105291725 + 201105291725 + Lauttasaarentie + + + + 24.8840610166 + 60.1604800039 + + 201105291726 + 201105291726 + Koillisvyl + + + + + 3077 + 420 + 5 + 2103T 2 + + + + 24.8840610166 + 60.1604800039 + + 201105291726 + 201105291726 + Koillisvyl + + + + 24.8912987534 + 60.1610688341 + + 201105291728 + 201105291728 + Lauttasaaren silta + + + + 24.9058315134 + 60.1636451749 + + 201105291729 + 201105291729 + Salmisaari + + + + 24.9134665043 + 60.1642300842 + + 201105291730 + 201105291730 + Lnsivyl + + + + 24.9267577712 + 60.1661035862 + + 201105291732 + 201105291732 + Lapinrinne + + + + 24.9301475091 + 60.1687726522 + + 201105291733 + 201105291733 + Kamppi, tulolaituri + + + + + 728 + 624.18 + walk + + + + 24.9301475091 + 60.1687726522 + + 201105291733 + 201105291733 + Kamppi, tulolaituri + + + + 24.9314926601 + 60.1693277999 + + 201105291734 + 201105291734 + + + + + 24.9316654649 + 60.169386725 + + 201105291734 + 201105291734 + Salomonkatu + + + + 24.9323912416 + 60.1696338492 + + 201105291735 + 201105291735 + + + + + 24.932991506 + 60.1698378702 + + 201105291735 + 201105291735 + Salomonkatu + + + + 24.9339865173 + 60.1701764415 + + 201105291736 + 201105291736 + + + + + 24.9356165422 + 60.1706720944 + + 201105291738 + 201105291738 + Salomonkatu + + + + 24.935991995 + 60.1708247296 + + 201105291738 + 201105291738 + + + + + 24.9363710793 + 60.1709782358 + + 201105291739 + 201105291739 + Mannerheimintie + + + + 24.9368129938 + 60.1708072627 + + 201105291739 + 201105291739 + Postikatu + + + + 24.9389832898 + 60.1709777147 + + 201105291741 + 201105291741 + + + + + 24.9389572102 + 60.1710739428 + + 201105291741 + 201105291741 + + + + + 24.9410959958 + 60.1711494377 + + 201105291743 + 201105291743 + + + + + 24.9410086564 + 60.1712452034 + + 201105291743 + 201105291744 + + + + + + + + + + 4375.038 + 960 + + + 200 + 148.32 + walk + + + + 24.8843991291 + 60.1612003139 + + 201105291735 + 201105291735 + + + + + 24.8849737013 + 60.161135443 + + 201105291736 + 201105291736 + Koillisvyl + + + + 24.8851061757 + 60.1607037122 + + 201105291736 + 201105291736 + Lauttasaarentie + + + + 24.8867859992 + 60.160686203 + + 201105291738 + 201105291738 + Koillisvyl + + + + + 3947 + 660 + 1 + 1065A 1 + + + + 24.8867859992 + 60.160686203 + + 201105291738 + 201105291738 + Koillisvyl + + + + 24.8912444909 + 60.161060223 + + 201105291740 + 201105291740 + Lauttasaaren silta + + + + 24.9058680229 + 60.1636628774 + + 201105291743 + 201105291743 + Salmisaari + + + + 24.913430488 + 60.1642303324 + + 201105291744 + 201105291744 + Lnsivyl + + + + 24.9306289735 + 60.1685987294 + + 201105291746 + 201105291746 + Kamppi (M) + + + + 24.9322953035 + 60.1682818385 + + 201105291748 + 201105291748 + Kampintori + + + + 24.9354588292 + 60.168672453 + + 201105291748 + 201105291748 + Simonkatu + + + + 24.9392084131 + 60.1700282525 + + 201105291749 + 201105291749 + Kaivokatu + + + + + 226 + 188.76 + walk + + + + 24.9392084131 + 60.1700282525 + + 201105291749 + 201105291749 + Kaivokatu + + + + 24.9396683488 + 60.1701739957 + + 201105291749 + 201105291749 + + + + + 24.9393509582 + 60.1704150068 + + 201105291749 + 201105291749 + + + + + 24.9397003895 + 60.1705390927 + + 201105291750 + 201105291750 + Asema-aukio + + + + 24.9401321312 + 60.1707065766 + + 201105291750 + 201105291750 + Asema-aukio + + + + 24.9402267451 + 60.1709285111 + + 201105291751 + 201105291751 + + + + + 24.9403117391 + 60.1711289712 + + 201105291751 + 201105291751 + + + + + 24.9410959958 + 60.1711494377 + + 201105291752 + 201105291752 + + + + + 24.9410086564 + 60.1712452034 + + 201105291752 + 201105291752 + + + + + + + + + + 4219.384 + 1140 + + + 200 + 148.32 + walk + + + + 24.8843991291 + 60.1612003139 + + 201105291736 + 201105291736 + + + + + 24.8849737013 + 60.161135443 + + 201105291737 + 201105291737 + Koillisvyl + + + + 24.8851061757 + 60.1607037122 + + 201105291737 + 201105291737 + Lauttasaarentie + + + + 24.88678 + 59992 + 60.160686203 + + 201105291739 + 201105291739 + Koillisvyl + + + + + 1861 + 360 + 1 + 1020 2 + + + + 24.8867859992 + 60.160686203 + + 201105291739 + 201105291739 + Koillisvyl + + + + 24.8912444909 + 60.161060223 + + 201105291740 + 201105291740 + Lauttasaaren silta + + + + 24.9058680229 + 60.1636628774 + + 201105291743 + 201105291743 + Salmisaari + + + + 24.9076974035 + 60.1633810852 + + 201105291744 + 201105291744 + Salmisaari + + + + 24.9137980243 + 60.1631955599 + + 201105291745 + 201105291745 + Ruoholahti(M) + + + + + 57 + 49.26 + walk + + + + 24.9137980243 + 60.1631955599 + + 201105291745 + 201105291745 + Ruoholahti(M) + + + + 24.9137385246 + 60.1631932772 + + 201105291745 + 201105291745 + + + + + 24.9138385973 + 60.1627105763 + + 201105291745 + 201105291751 + Ruoholahti + + + + + 1934 + 180 + 6 + 1300V 1 + + + + 24.9138385973 + 60.1627105763 + + 201105291745 + 201105291751 + Ruoholahti + + + + 24.931502109 + 60.1688977825 + + 201105291752 + 201105291752 + Kamppi + + + + 24.9411273485 + 60.1703557347 + + 201105291754 + 201105291754 + Rautatientori + + + + + 165 + 135.78 + walk + + + + 24.9411273485 + 60.1703557347 + + 201105291754 + 201105291754 + Rautatientori + + + + 24.9414606702 + 60.1702312944 + + 201105291754 + 201105291754 + + + + + 24.941532741 + 60.1702316803 + + 201105291754 + 201105291754 + + + + + 24.9410959958 + 60.1711494377 + + 201105291756 + 201105291756 + + + + + 24.9410086564 + 60.1712452034 + + 201105291756 + 201105291756 + + + + + + + + + + 4375.038 + 960 + + + 200 + 148.32 + walk + + + + 24.8843991291 + 60.1612003139 + + 201105291750 + 201105291750 + + + + + 24.8849737013 + 60.161135443 + + 201105291751 + 201105291751 + Koillisvyl + + + + 24.8851061757 + 60.1607037122 + + 201105291751 + 201105291751 + Lauttasaarentie + + + + 24.8867859992 + 60.160686203 + + 201105291753 + 201105291753 + Koillisvyl + + + + + 3947 + 660 + 1 + 1065A 1 + + + + 24.8867859992 + 60.160686203 + + 201105291753 + 201105291753 + Koillisvyl + + + + 24.8912444909 + 60.161060223 + + 201105291755 + 201105291755 + Lauttasaaren silta + + + + 24.9058680229 + 60.1636628774 + + 201105291758 + 201105291758 + Salmisaari + + + + 24.913430488 + 60.1642303324 + + 201105291759 + 201105291759 + Lnsivyl + + + + 24.9306289735 + 60.1685987294 + + 201105291801 + 201105291801 + Kamppi (M) + + + + 24.9322953035 + 60.1682818385 + + 201105291803 + 201105291803 + Kampintori + + + + 24.9354588292 + 60.168672453 + + 201105291803 + 201105291803 + Simonkatu + + + + 24.9392084131 + 60.1700282525 + + 201105291804 + 201105291804 + Kaivokatu + + + + + 226 + 188.76 + walk + + + + 24.9392084131 + 60.1700282525 + + 201105291804 + 201105291804 + Kaivokatu + + + + 24.9396683488 + 60.1701739957 + + 201105291804 + 201105291804 + + + + + 24.9393509582 + 60.1704150068 + + 201105291804 + 201105291804 + + + + + 24.9397003895 + 60.1705390927 + + 201105291805 + 201105291805 + Asema-aukio + + + + 24.9401321312 + 60.1707065766 + + 201105291805 + 201105291805 + Asema-aukio + + + + 24.9402267451 + 60.1709285111 + + 201105291806 + 201105291806 + + + + + 24.9403117391 + 60.1711289712 + + 201105291806 + 201105291806 + + + + + 24.9410959958 + 60.1711494377 + + 201105291807 + 201105291807 + + + + + 24.9410086564 + 60.1712452034 + + 201105291807 + 201105291807 + + + + + + + + + + 3972.706 + 1200 + + + 166 + 122.64 + walk + + + + 24.8843991291 + 60.1612003139 + + 201105291753 + 201105291753 + + + + + 24.8849737013 + 60.161135443 + + 201105291754 + 201105291754 + Koillisvyl + + + + 24.8851061757 + 60.1607037122 + + 201105291755 + 201105291755 + Lauttasaarentie + + + + 24.8840610166 + 60.1604800039 + + 201105291756 + 201105291756 + Koillisvyl + + + + + 3077 + 420 + 5 + 2160T 2 + + + + 24.8840610166 + 60.1604800039 + + 201105291756 + 201105291756 + Koillisvyl + + + + 24.8912987534 + 60.1610688341 + + 201105291757 + 201105291757 + Lauttasaaren silta + + + + 24.9058315134 + 60.1636451749 + + 201105291759 + 201105291759 + Salmisaari + + + + 24.9134665043 + 60.1642300842 + + 201105291800 + 201105291800 + Lnsivyl + + + + 24.9267577712 + 60.1661035862 + + 201105291802 + 201105291802 + Lapinrinne + + + + 24.9301475091 + 60.1687726522 + + 201105291803 + 201105291803 + Kamppi, tulolaituri + + + + + 728 + 624.18 + walk + + + + 24.9301475091 + 60.1687726522 + + 201105291803 + 201105291803 + Kamppi, tulolaituri + + + + 24.9314926601 + 60.1693277999 + + 201105291804 + 201105291804 + + + + + 24.9316654649 + 60.169386725 + + 201105291804 + 201105291804 + Salomonkatu + + + + 24.9323912416 + 60.1696338492 + + 201105291805 + 201105291805 + + + + + 24.932991506 + 60.1698378702 + + 201105291805 + 201105291805 + Salomonkatu + + + + 24.9339865173 + 60.1701764415 + + 201105291806 + 201105291806 + + + + + 24.9356165422 + 60.1706720944 + + 201105291808 + 201105291808 + Salomonkatu + + + + 24.935991995 + 60.1708247296 + + 201105291808 + 201105291808 + + + + + 24.9363710793 + 60.1709782358 + + 201105291809 + 201105291809 + Mannerheimintie + + + + 24.9368129938 + 60.1708072627 + + 201105291809 + 201105291809 + Postikatu + + + + 24.9389832898 + 60.1709777147 + + 201105291811 + 201105291811 + + + + + 24.9389572102 + 60.1710739428 + + 201105291811 + 201105291811 + + + + + 24.9410959958 + 60.1711494377 + + 201105291813 + 201105291813 + + + + + 24.9410086564 + 60.1712452034 + + 201105291813 + 201105291814 + + + + + + + + diff --git a/tests/routeParserTest/routeResponse.xml b/tests/routeParserTest/routeResponse.xml new file mode 120000 index 0000000..4d215a6 --- /dev/null +++ b/tests/routeParserTest/routeResponse.xml @@ -0,0 +1 @@ +routeResponse-2.xml \ No newline at end of file diff --git a/tests/testSummary b/tests/testSummary deleted file mode 100755 index 3766d93..0000000 --- a/tests/testSummary +++ /dev/null @@ -1,310 +0,0 @@ -#! /usr/bin/perl -require 5.008_004; # we need at least Perl version v5.8.4 -$ENV{MALLOC_CHECK_} = 2; - -use Term::ANSIColor; - -my $startTime = time(); - -my %opts = ( - "a" => 0, # all directories, irrespective of if they're in tests.pro - "r" => 0, # don't reverse sort - "s" => "D", # by default, sort by directory name - "j" => 1, # one make job at a time by default -); - -for ( my $argNo=0; $argNo<@ARGV; $argNo++ ) { - my $arg = $ARGV[ $argNo ]; - if ( $arg eq "-h" ) { - print "usage: $0 [-a] [-s letter] [-r] [-j number] [-h]\n"; - print " -a include all ut_*/ directories - default is just the ones in tests.pro\n"; - print " -s [DTPFS] sort by column (Dirs, Tests, P(ass), F(ail), S(kipped)\n"; - print " -r reverse sort\n"; - print " -j use make jobs. Default is 1\n"; - print " -h this help\n"; - exit; - } elsif ( $arg eq "-r" ) { - $opts{ "r" } = 1; - } elsif ( $arg eq "-a" ) { - $opts{ "a" } = 1; - } elsif ( $arg eq "-s" ) { - $opts{ "s" } = $ARGV[ ++$argNo ]; - if ( $opts{ "s" } !~ /[DTPFS]/ ) { - print "Unrecognised column identifier\n"; - print "Must be one of [DTPFS] :\n"; - print " D = Dirs\n"; - print " T = Tests\n"; - print " P = Pass\n"; - print " F = Fail\n"; - print " S = Skipped\n"; - exit(-1); - } - } elsif ( $arg eq "-j" ) { - my $jobs = $ARGV[ ++$argNo ]; - # Test that the argument is a positive integer number - if ( $jobs * 1 eq $jobs && $jobs > 0 ) { - $opts{ "j" } = $jobs; - } - } -} - -# some globals to help sort be faster -$sortCol = $opts{ "s" }; -$sortIsNumeric = ( $sortCol =~ /[PFS]/ ); -$reverseSort = $opts{ "r" }; -# helper variable for the number of jobs -$numJobs = $opts{ "j" }; - -%maxLen = (); -%segFault = (); - -my @rowHeaders = ( - "D", # Dirs - "T", # Tests -); -my @rowData = ( - "P", # Passed - "F", # Failed - "S", # Skipped -); - -my @keys = ( @rowHeaders, @rowData ); - -my %title = ( - "D"=>"Dirs", - "T"=>"Tests", - "P"=>"P", - "F"=>"F", - "S"=>"S", -); - -my $headerLabelFormat = "%-*s"; -my $headerDataFormat = "%*s"; - -my $labelFormat = "%s%-*s%s%*s"; -my $dataFormat = "%*s%s%*s%s"; - -my %format = ( - "D" => $labelFormat, - "T" => $labelFormat, - "P" => $dataFormat, - "F" => $dataFormat, - "S" => $dataFormat, -); - -my %separator = ( - "D" => " ", - "T" => " : ", - "P" => " ", - "F" => " ", - "S" => " ", -); - -my %data = ( -); - -foreach $key ( @keys ) { - $maxLen{ $key } = length( $title{ key } ); -} - -# set the maximum length of the directories -if ( $opts{ "a" } ) { - push @allDirs, ; - push @allDirs, ; - foreach ( @allDirs ) { - setMaxLen( "D", length( $_ ) ); - $tested{ $_ } = 0; - } -} - -# Compile first with possibly multiple jobs -print "Compiling..."; -`make -j$numJobs -k > /dev/null 2>&1`; -print "done.\nNow checking...\n"; - -# then check with only one job so that the parsing succeeds -open( MAKE, "make -k check 2>&1|" ) || die( "Could not run make:$!" ); - -#$|=1; - -my $thisDir = ""; -while () { - chomp; - - if ( /Entering directory \`.*tests\/(\w+)\'/ ) { - $thisDir = $1; - print STDERR "Tests: $thisDir", ' 'x( $maxLen{ "D" }-length( $thisDir )+length("Tests: ") ), "\r"; - $tested{ $thisDir } = 1; - push @allDirs, $thisDir if ( !grep( /^$thisDir$/, @allDirs ) ); - setMaxLen( "D", length( $thisDir ) ); - } elsif ( /Segmentation fault/ ) { - $segFault{ $thisDir } = $_; - } elsif ( /Start testing of (\w+)/ ) { - $thisTest = $1; - $data{ "T" }{ $thisDir } = $thisTest; - setMaxLen( "T", length( $data{ "T" }{ $thisDir } ) ); - } elsif ( /^Totals: (\d+) passed, (\d+) failed, (\d+) skipped/ ) { - $data{ "P" }{ $thisDir } = "$1"; - $data{ "F" }{ $thisDir } = "$2"; - $data{ "S" }{ $thisDir } = "$3"; - setMaxLen( "P", length( $data{ "P" }{ $thisDir } ) ); - setMaxLen( "F", length( $data{ "F" }{ $thisDir } ) ); - setMaxLen( "S", length( $data{ "S" }{ $thisDir } ) ); - } -} - -close( MAKE ); - -print STDERR ' 'x( $maxLen{ "D" } + length( "Tests: " ) ), "\r"; - -foreach $thisDir ( @allDirs ) { - if ( !defined( $data{ "P" }{ $thisDir } ) || $data{ "P" }{ $thisDir } eq "" ) { - $data{ "P" }{ $thisDir } = "0"; - setMaxLen( "P", length( $data{ "P" }{ $thisDir } ) ); - } - if ( !defined( $data{ "F" }{ $thisDir } ) ) { - $data{ "F" }{ $thisDir } = "0"; - setMaxLen( "F", length( $data{ "F" }{ $thisDir } ) ); - } - if ( !defined( $data{ "S" }{ $thisDir } ) ) { - $data{ "S" }{ $thisDir } = "0"; - setMaxLen( "S", length( $data{ "S" }{ $thisDir } ) ); - } - - $data{ "D" }{ $thisDir } = $thisDir; -} - -my ( $testsPassed, $testsNeedWork ) = ( 0, 0 ); -my $noTests = scalar( @allDirs ); -my $noDigits = ($noTests>0)?int( log( $noTests )/log( 10 ) )+1:1; - -my $header = sprintf( "%*s ", $noDigits, "" ); - -foreach ( @rowHeaders ) { - $header .= sprintf( $headerLabelFormat.$separator{ $_ }, $maxLen{ $_ }, $title{ $_ } ); -} - -foreach ( @rowData ) { - $header .= sprintf( $headerDataFormat.$separator{ $_ }, $maxLen{ $_ }, $title{ $_ } ); -} - -my $headerLen = length( $header ); - -my $headerColor = color( 'reset' ); - -print "P = Pass, F = Fail, S = Skip\n"; -print $headerColor, "$header\n"; -print '-'x$headerLen, "\n"; - -my $testNo = 1; - -foreach $thisDir ( sort byCol @allDirs ) { - my %colors = (); - - foreach $key ( @keys ) { - $colors{ $key } = color( 'reset' ); - } - - if ( - ( defined( $data{ "P" }{ $thisDir } ) && $data{ "P" }{ $thisDir } ne "0" ) && - ( defined( $data{ "F" }{ $thisDir } ) && $data{ "F" }{ $thisDir } eq "0" ) && - ( defined( $data{ "S" }{ $thisDir } ) && $data{ "S" }{ $thisDir } eq "0" ) && - ( defined( $data{ "T" }{ $thisDir } ) && $data{ "T" }{ $thisDir } ne "" ) - ) { - $testsPassed++; - } else { - $testsNeedWork++; - } - - if ( defined( $data{ "P" }{ $thisDir } ) && $data{ "P" }{ $thisDir } eq "0" ) { - $colors{ "D" } .= color( 'reverse green' ); - $colors{ "T" } .= color( 'reverse green' ); - $colors{ "P" } .= color( 'reverse green' ); - } else { - $colors{ "D" } .= color( 'green' ); - $colors{ "T" } .= color( 'green' ); - $colors{ "P" } .= color( 'green' ); - } - - if ( defined( $data{ "F" }{ $thisDir} ) && $data{ "F" }{ $thisDir } eq "0" ) { - $colors{ "F" } .= color( 'red' ); - } else { - $colors{ "F" } .= color( 'reverse red' ); - } - - if ( defined( $data{ "S" }{ $thisDir } ) && $data{ "S" }{ $thisDir } eq "0" ) { - $colors{ "S" } .= color( 'blue' ); - } else { - $colors{ "S" } .= color( 'reverse blue' ); - } - - if ( !defined( $data{ "T" }{ $thisDir } ) || $data{ "T" }{ $thisDir } eq "" || $segFault{ $thisDir } ) { - $colors{ "T" } .= color( 'reverse red' ); - } - - printf( "%*s ", $noDigits, $testNo ); - - foreach ( @rowHeaders ) { - my $thisData = $data{ $_ }{ $thisDir }; - my $dataLength = length( $thisData ); - my $spaceLength = $maxLen{ $_ }-$dataLength; - - printf( - $format{ $_ }.$separator{ $_ }, - $colors{ $_ }, $dataLength, $thisData, - color( 'reset' ), $spaceLength, "" ); - } - - foreach ( @rowData ) { - my $thisData = $data{ $_ }{ $thisDir }; - my $dataLength = length( $thisData ); - my $spaceLength = $maxLen{ $_ }-$dataLength; - - printf( - $format{ $_ }.$separator{ $_ }, - $spaceLength, "", - $colors{ $_ }, $dataLength, $thisData, - color( 'reset' ) ); - } - - printf( $headerColor."\n" ); - - $testNo++; -} - -print '-'x$headerLen, "\n"; -print( "Tests with zero fails/skips : $testsPassed\n" ); -print( "Tests needing further work : $testsNeedWork\n" ); - -printf( "Elapsed time : %d seconds\n", time() - $startTime ); - -sub setMaxLen -{ - my ( $test, $length ) = @_; - - $maxLen{ $test } = $length if ( defined( $maxLen{ $test} ) && $length > $maxLen{ $test } ); -} - -sub byCol -{ - my $retVal = 0; - - my $localA = $a; - my $localB = $b; - - if ( $reverseSort ) { - my $tmp = $localA; - $localA = $localB; - $localB = $tmp; - } - - if ( $sortIsNumeric ) { - # numeric comparison - $retVal = $data{ $sortCol }{ $localA } <=> $data{ $sortCol }{ $localB }; - } else { - # string comparison - $retVal = $data{ $sortCol }{ $localA } cmp $data{ $sortCol }{ $localB }; - } - - return $retVal; -} diff --git a/tests/tests.pri b/tests/tests.pri deleted file mode 100644 index c8e85f1..0000000 --- a/tests/tests.pri +++ /dev/null @@ -1,2 +0,0 @@ -ZOUBASRC = ../../src - diff --git a/tests/tests.pro b/tests/tests.pro deleted file mode 100644 index c81345e..0000000 --- a/tests/tests.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE=subdirs -SUBDIRS = \ - ut_location/ \ - ut_route/ \ - ut_gpscontroller/ \ - -check.target = check -check.CONFIG = recursive -QMAKE_EXTRA_TARGETS += check diff --git a/tests/ut_gpscontroller/ut_gpscontroller.cpp b/tests/ut_gpscontroller/ut_gpscontroller.cpp deleted file mode 100644 index e391645..0000000 --- a/tests/ut_gpscontroller/ut_gpscontroller.cpp +++ /dev/null @@ -1,222 +0,0 @@ -#include -#include -#include "ut_gpscontroller.h" - -#include "gpscontroller.h" -#include "gpscontroller_p.h" - -class MyGpsControllerPrivate: public GpsControllerPrivate -{ -public: - MyGpsControllerPrivate(); - ~MyGpsControllerPrivate(); - - void init(); - void startGps(); - void stopGps(); - - void setGps( QGeoPositionInfoSource *gps ); - void setFakeLocationLabel( const QString &label ); - void setUseFakeLocation( bool useFake ); - void updateLocation(); - - QGeoPositionInfoSource *gps(); - Location *liveLocation(); - Location *fakeLocation(); - bool useFakeLocation(); - - bool m_gpsOn; - Location *m_liveLocation; - Location *m_fakeLocation; - QString m_fakeLocationLabel; - bool m_useFakeLocation; -}; - -MyGpsControllerPrivate::MyGpsControllerPrivate() : - m_gpsOn(false), - m_liveLocation( new Location( "livegps" ) ), - m_fakeLocation( new Location( "fakegps" ) ), - m_fakeLocationLabel(), - m_useFakeLocation(false) -{ -} - -MyGpsControllerPrivate::~MyGpsControllerPrivate() -{ - delete m_liveLocation; - m_liveLocation = 0; - delete m_fakeLocation; - m_fakeLocation = 0; -} - -void MyGpsControllerPrivate::init() -{ -} - -void MyGpsControllerPrivate::startGps() -{ - m_gpsOn=true; -} - -void MyGpsControllerPrivate::stopGps() -{ - m_gpsOn=false; -} - -QGeoPositionInfoSource *MyGpsControllerPrivate::gps() -{ - return 0; -} - -void MyGpsControllerPrivate::setGps( QGeoPositionInfoSource *gps ) -{ - Q_UNUSED( gps ); -} - -Location *MyGpsControllerPrivate::liveLocation() -{ - return m_liveLocation; -} - -Location *MyGpsControllerPrivate::fakeLocation() -{ - return m_fakeLocation; -} - -void MyGpsControllerPrivate::setFakeLocationLabel( const QString &label ) -{ - m_fakeLocationLabel = label; - m_fakeLocation->setLabel( label ); -} - -bool MyGpsControllerPrivate::useFakeLocation() -{ - return m_useFakeLocation; -} - -void MyGpsControllerPrivate::setUseFakeLocation( bool useFake ) -{ - m_useFakeLocation = useFake; -} - -void MyGpsControllerPrivate::updateLocation() -{ -} - -void Ut_GpsController::init() -{ - qRegisterMetaType( "Location*" ); - - m_subject_p = new MyGpsControllerPrivate(); - m_subject = new GpsController( m_subject_p ); // private ownership transferred -} - -void Ut_GpsController::cleanup() -{ - delete m_subject; - m_subject = 0; -} - -void Ut_GpsController::initTestCase() -{ -} - -void Ut_GpsController::cleanupTestCase() -{ -} - -void Ut_GpsController::testGetGpsWithNoGpsUpdates() -{ - QSignalSpy spy(m_subject, SIGNAL(locationChanged(Location*))); - - // this should start the gps, - // one signal to invalidate the previous display - // (which could be showing fake results, for example - m_subject->getGps(); - - QCOMPARE(m_subject_p->m_gpsOn, true); - QCOMPARE(spy.count(), 1); -} - -void Ut_GpsController::testGetGpsWithGpsUpdates() -{ - QSignalSpy spy(m_subject, SIGNAL(locationChanged(Location*))); - - // make test call - m_subject->getGps(); - - // check effect - QCOMPARE(m_subject_p->m_gpsOn, true); - QCOMPARE(spy.count(), 1); - QList arguments = spy.takeFirst(); - QCOMPARE(arguments.at(0).value(), m_subject_p->m_liveLocation); -} - -void Ut_GpsController::testFakeGps() -{ - QSignalSpy spy(m_subject, SIGNAL(locationChanged(Location*))); - - Location *gpsLocation = m_subject_p->m_liveLocation; // position from GPS - - // make test call - m_subject->useFakeGps( "fakegps" ); - m_subject->getGps(); - - // check effect - QList arguments; - - // gps should be off - QCOMPARE(m_subject_p->m_gpsOn, false); - - // should get two signals, one from useFakeGps() and one from getGps() - QVERIFY2(spy.count()==2, "Should receive two signals" ); - - // both args should be the fake gps position supplied to useFakeGps() - arguments = spy.takeFirst(); - QCOMPARE( arguments.at(0).value(), m_subject_p->m_fakeLocation ); - QCOMPARE( arguments.at(0).value()->label(), QString( "fakegps" ) ); - arguments = spy.takeFirst(); - QCOMPARE( arguments.at(0).value(), m_subject_p->m_fakeLocation ); - QCOMPARE( arguments.at(0).value()->label(), QString( "fakegps" ) ); - - // switch back to GPS - m_subject->useLiveGps(); - m_subject->getGps(); - - // gps should be on - QCOMPARE(m_subject_p->m_gpsOn, true); - - QVERIFY2(spy.count()==2, "should get two locationChanged signals" ); - arguments = spy.takeFirst(); - QCOMPARE(arguments.at(0).value(), m_subject_p->m_liveLocation); - QCOMPARE( arguments.at(0).value()->label(), QString( "livegps" ) ); - arguments = spy.takeFirst(); - QCOMPARE(arguments.at(0).value(), m_subject_p->m_liveLocation); - QCOMPARE( arguments.at(0).value()->label(), QString( "livegps" ) ); - - // get GPS location - m_subject->getGps(); - - // check effect - QCOMPARE(spy.count(), 1); - arguments = spy.takeFirst(); - QCOMPARE(arguments.at(0).value(), m_subject_p->m_liveLocation); - QCOMPARE( arguments.at(0).value()->label(), QString( "livegps" ) ); -} - -void Ut_GpsController::testLiveToFakeToLive() -{ - m_subject_p->updateLocation(); // pretend GPS has given an update - - m_subject->useFakeGps( "fakegps" ); - m_subject->getGps(); - - // switch back to live GPS - m_subject->useLiveGps(); - m_subject->getGps(); - - m_subject->useFakeGps( "fakegps" ); - m_subject->getGps(); -} - -QTEST_APPLESS_MAIN(Ut_GpsController) diff --git a/tests/ut_gpscontroller/ut_gpscontroller.h b/tests/ut_gpscontroller/ut_gpscontroller.h deleted file mode 100644 index 50fdcb7..0000000 --- a/tests/ut_gpscontroller/ut_gpscontroller.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef UT_GPSCONTROLLER_H -#define UT_GPSCONTROLLER_H - -#include -#include - -class GpsController; -class MyGpsControllerPrivate; -class Location; - -Q_DECLARE_METATYPE(GpsController*); -Q_DECLARE_METATYPE(MyGpsControllerPrivate*); -Q_DECLARE_METATYPE(Location*); - -class Ut_GpsController : public QObject -{ -Q_OBJECT - -public: - -private slots: - void init(); - void cleanup(); - void initTestCase(); - void cleanupTestCase(); - void testGetGpsWithNoGpsUpdates(); - void testGetGpsWithGpsUpdates(); - void testFakeGps(); - void testLiveToFakeToLive(); - -private: - GpsController *m_subject; - MyGpsControllerPrivate *m_subject_p; -}; -#endif // UT_GPSCONTROLLER_H diff --git a/tests/ut_gpscontroller/ut_gpscontroller.pro b/tests/ut_gpscontroller/ut_gpscontroller.pro deleted file mode 100644 index 9021c16..0000000 --- a/tests/ut_gpscontroller/ut_gpscontroller.pro +++ /dev/null @@ -1,44 +0,0 @@ -include( ../tests.pri ) -CONFIG += \ - qt \ - debug \ - mobility \ - -MOBILITY = \ - location \ - bearer \ - -QT += \ - testlib \ - network \ - maemo5 \ - -INCLUDEPATH += \ - $$ZOUBASRC \ - -DEPENDPATH += $INCLUDEPATH - -TEMPLATE = app - -LIBS += \ - /usr/lib/libQtLocation.so \ - -SOURCES = \ - ut_gpscontroller.cpp \ - $$ZOUBASRC/gpscontroller.cpp \ - $$ZOUBASRC/gpscontroller_p.cpp \ - $$ZOUBASRC/locations.cpp \ - $$ZOUBASRC/location.cpp \ - $$ZOUBASRC/location_p.cpp \ - -HEADERS += \ - ut_gpscontroller.h \ - $$ZOUBASRC/gpscontroller.h \ - $$ZOUBASRC/gpscontroller_p.h \ - $$ZOUBASRC/locations.h \ - $$ZOUBASRC/location.h \ - $$ZOUBASRC/location_p.h \ - -QMAKE_EXTRA_TARGETS += check -check.depends = $$TARGET -check.commands = ./$$TARGET diff --git a/tests/ut_location/ut_location.cpp b/tests/ut_location/ut_location.cpp deleted file mode 100644 index e7e4ca6..0000000 --- a/tests/ut_location/ut_location.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include -#include -#include "location.h" -#include "location_p.h" -#include "ut_location.h" - -QTM_USE_NAMESPACE - -QByteArray sampleInput( -"\ -\ -\ -\ -\ -\ -" - -); - -void Ut_Location::init() -{ -} - -void Ut_Location::cleanup() -{ -} - -void Ut_Location::initTestCase() -{ -} - -void Ut_Location::cleanupTestCase() -{ -} - -void Ut_Location::testParseReply() -{ - QString label("home"); - LocationPrivate m_subject(label); - - m_subject.parseReply( sampleInput ); - - QCOMPARE( m_subject.label(), label ); - QCOMPARE( m_subject.x(), QString( "2549182" ) ); - QCOMPARE( m_subject.y(), QString( "6672569" ) ); -} - -void Ut_Location::testSet() -{ - QString label( "home" ); - LocationPrivate m_subject(label); - - label = "work"; - QString address( "Taivaanvuohentie 7 B 27, Helsinki" ); - QString x( "2549182" ); - QString y( "6672569" ); - m_subject.setAddress( address ); - m_subject.setLabel( label ); - m_subject.setX( x ); - m_subject.setY( y ); - QCOMPARE( m_subject.address(), address ); - QCOMPARE( m_subject.label(), label ); - QCOMPARE( m_subject.x(), x ); - QCOMPARE( m_subject.y(), y ); -} - -void Ut_Location::testConstructorQGeoPositionInfo() -{ - QGeoPositionInfo thisPositionInfo( QGeoCoordinate( 60.16183, 24.88256 ), QDateTime( QDate( 1965, 11, 11 ) ) ); - Location subject( thisPositionInfo ); - - QString x( "2549182" ); - QString y( "6672569" ); - QCOMPARE( subject.x(), x ); - QCOMPARE( subject.y(), y ); -} - -QTEST_APPLESS_MAIN(Ut_Location) diff --git a/tests/ut_location/ut_location.h b/tests/ut_location/ut_location.h deleted file mode 100644 index 552c4eb..0000000 --- a/tests/ut_location/ut_location.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef UT_LOCATION_H -#define UT_LOCATION_H - -#include -#include - -#include - -Q_DECLARE_METATYPE(LocationPrivate*); - -class Ut_Location : public QObject -{ -Q_OBJECT - -public: - -private slots: - void init(); - void cleanup(); - void initTestCase(); - void cleanupTestCase(); - void testParseReply(); - void testSet(); - void testConstructorQGeoPositionInfo(); - -private: - LocationPrivate *m_subject; -}; -#endif // UT_LOCATION_H diff --git a/tests/ut_location/ut_location.pro b/tests/ut_location/ut_location.pro deleted file mode 100644 index 9a3fdc0..0000000 --- a/tests/ut_location/ut_location.pro +++ /dev/null @@ -1,38 +0,0 @@ -include( ../tests.pri ) -CONFIG += \ - qt \ - debug \ - mobility \ - -MOBILITY = \ - location \ - bearer \ - -QT += \ - testlib \ - network \ - maemo5 \ - -INCLUDEPATH += \ - $$ZOUBASRC \ - -DEPENDPATH += $$INCLUDEPATH - -LIBS += \ - /usr/lib/libQtLocation.so \ - -TEMPLATE = app - -SOURCES = \ - ut_location.cpp \ - $$ZOUBASRC/location.cpp \ - $$ZOUBASRC/location_p.cpp \ - -HEADERS += \ - ut_location.h \ - $$ZOUBASRC/location.h \ - $$ZOUBASRC/location_p.h \ - -QMAKE_EXTRA_TARGETS += check -check.depends = $$TARGET -check.commands = ./$$TARGET diff --git a/tests/ut_route/ut_route.cpp b/tests/ut_route/ut_route.cpp deleted file mode 100644 index 0a47349..0000000 --- a/tests/ut_route/ut_route.cpp +++ /dev/null @@ -1,158 +0,0 @@ -#include -#include -#include -#include "ut_route.h" - -#include "ut_sampleinput.h" - -void Ut_Route::init() -{ - m_subject = new RoutePrivate(); -} - -void Ut_Route::cleanup() -{ - delete m_subject; - m_subject = 0; -} - -void Ut_Route::initTestCase() -{ -} - -void Ut_Route::cleanupTestCase() -{ -} - -void Ut_Route::testParseReply() -{ - QFETCH(QByteArray, xmlInput); - QFETCH(QList, expectedResults); - - QList routeData = m_subject->parseReply( xmlInput ); - - QCOMPARE( routeData.count(), expectedResults.count() ); - - for( int routeIndex=0; routeIndex("xmlInput"); - QTest::addColumn< QList >("expectedResults"); - - QTest::newRow("single route") - << sampleInput[0] - << ( QList() - // Summary : TTime TDist First Vehicle - << ( RouteData( "14.411", "2510.063", "18:20", "65A" ) - // How TTime TDist Depart Arrive Line - << LegData( "WALK", "4.475", "357.069", "18:15", "18:20" ) - << LegData( "LINE", "5.000", "1760.931", "18:20", "18:25", "65A" ) - << LegData( "WALK", "4.936", "392.062", "18:25", "18:29" ) - ) - // Summary : TTime TDist First Vehicle - << ( RouteData( "13.411", "2501.497", "18:26", "102T" ) - // How TTime TDist Depart Arrive Line - << LegData( "WALK", "4.475", "357.069", "18:21", "18:26" ) - << LegData( "LINE", "4.000", "1751.582", "18:26", "18:30", "102T" ) - << LegData( "WALK", "4.936", "392.846", "18:30", "18:34" ) - ) - // Summary : TTime TDist First Vehicle - << ( RouteData( "13.411", "2501.497", "18:34", "110T" ) - // How TTime TDist Depart Arrive Line - << LegData( "WALK", "4.475", "357.069", "18:29", "18:34" ) - << LegData( "LINE", "4.000", "1751.582", "18:34", "18:38", "110T" ) - << LegData( "WALK", "4.936", "392.846", "18:38", "18:42" ) - ) - ); - - QTest::newRow("route with bus change") - << sampleInput[1] - << ( QList() - // Summary : TTime TDist First Vehicle - << ( RouteData( "28.633", "8902.040", "08:18", "111" ) - // How TTime TDist Depart Arrive Line - << LegData( "WALK", "3.479", "254.753", "08:14", "08:18" ) - << LegData( "LINE", "8.000", "5225.092", "08:18", "08:26", "111" ) - << LegData( "LINE", "5.000", "2926.431", "08:32", "08:37", "121T" ) - << LegData( "WALK", "6.154", "495.764", "08:37", "08:43" ) - ) - // Summary : TTime TDist First Vehicle - << ( RouteData( "25.633", "8902.040", "08:33", "111" ) - // How TTime TDist Depart Arrive Line - << LegData( "WALK", "3.479", "254.753", "08:29", "08:33" ) - << LegData( "LINE", "8.000", "5225.092", "08:33", "08:41", "111" ) - << LegData( "LINE", "5.000", "2926.431", "08:44", "08:49", "102T" ) - << LegData( "WALK", "6.154", "495.764", "08:49", "08:55" ) - ) - // Summary : TTime TDist First Vehicle - << ( RouteData( "33.510", "11193.458", "08:34", "111T" ) - // How TTime TDist Depart Arrive Line - << LegData( "WALK", "2.356", "172.693", "08:31", "08:34" ) - << LegData( "LINE", "6.000", "3392.054", "08:34", "08:40", "111T" ) - << LegData( "LINE", "5.000", "4206.516", "08:43", "08:48", "112" ) - << LegData( "LINE", "5.000", "2926.431", "08:54", "08:59", "102T" ) - << LegData( "WALK", "6.154", "495.764", "08:59", "09:05" ) - ) - // Summary : TTime TDist First Vehicle - << ( RouteData( "29.633", "8902.040", "08:50", "111" ) - // How TTime TDist Depart Arrive Line - << LegData( "WALK", "3.479", "254.753", "08:46", "08:50" ) - << LegData( "LINE", "8.000", "5225.092", "08:50", "08:58", "111" ) - << LegData( "LINE", "5.000", "2926.431", "09:05", "09:10", "102T" ) - << LegData( "WALK", "6.154", "495.764", "09:10", "09:16" ) - ) - // Summary : TTime TDist First Vehicle - << ( RouteData( "29.633", "8902.040", "09:07", "111" ) - // How TTime TDist Depart Arrive Line - << LegData( "WALK", "3.479", "254.753", "09:03", "09:07" ) - << LegData( "LINE", "8.000", "5225.092", "09:07", "09:15", "111" ) - << LegData( "LINE", "5.000", "2926.431", "09:22", "09:27", "160T" ) - << LegData( "WALK", "6.154", "495.764", "09:27", "09:33" ) - ) - ); -} - -void Ut_Route::testSetFromLocation() -{ - Location work( "2551042", "6672829" ); - QCOMPARE( m_subject->fromValid(), false ); - m_subject->setFromLocation( &work ); - QCOMPARE( m_subject->fromLocation()->x(), work.x() ); - QCOMPARE( m_subject->fromLocation()->y(), work.y() ); - QCOMPARE( m_subject->fromValid(), true ); -} - -void Ut_Route::testSetToLocation() -{ - Location work( "2551042", "6672829" ); - QCOMPARE( m_subject->toValid(), false ); - m_subject->setToLocation( &work ); - QCOMPARE( m_subject->toLocation()->x(), work.x() ); - QCOMPARE( m_subject->toLocation()->y(), work.y() ); - QCOMPARE( m_subject->toValid(), true ); -} - -QTEST_APPLESS_MAIN(Ut_Route) diff --git a/tests/ut_route/ut_route.h b/tests/ut_route/ut_route.h deleted file mode 100644 index a444405..0000000 --- a/tests/ut_route/ut_route.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef UT_ROUTE_H -#define UT_ROUTE_H - -#include -#include - -#include - -Q_DECLARE_METATYPE(RoutePrivate*); -Q_DECLARE_METATYPE(QList); - -class Ut_Route : public QObject -{ - Q_OBJECT - -public: - -private slots: - void init(); - void cleanup(); - void initTestCase(); - void cleanupTestCase(); - void testParseReply(); - void testParseReply_data(); - void testSetFromLocation(); - void testSetToLocation(); - -private: - RoutePrivate *m_subject; -}; -#endif // UT_ROUTE_H diff --git a/tests/ut_route/ut_route.pro b/tests/ut_route/ut_route.pro deleted file mode 100644 index 00aeaa8..0000000 --- a/tests/ut_route/ut_route.pro +++ /dev/null @@ -1,40 +0,0 @@ -include( ../tests.pri ) -CONFIG += \ - qt \ - debug \ - mobility \ - -MOBILITY = \ - location \ - bearer \ - -QT += \ - testlib \ - network \ - maemo5 \ - -INCLUDEPATH += \ - $$ZOUBASRC \ - -DEPENDPATH += $INCLUDEPATH - -TEMPLATE = app - -LIBS += \ - /usr/lib/libQtLocation.so \ - -SOURCES = \ - ut_route.cpp \ - $$ZOUBASRC/route_p.cpp \ - $$ZOUBASRC/location.cpp \ - $$ZOUBASRC/location_p.cpp \ - -HEADERS += \ - ut_route.h \ - $$ZOUBASRC/route_p.h \ - $$ZOUBASRC/location.h \ - $$ZOUBASRC/location_p.h \ - -QMAKE_EXTRA_TARGETS += check -check.depends = $$TARGET -check.commands = ./$$TARGET diff --git a/tests/ut_route/ut_sampleinput.h b/tests/ut_route/ut_sampleinput.h deleted file mode 100644 index ec38afe..0000000 --- a/tests/ut_route/ut_sampleinput.h +++ /dev/null @@ -1,1238 +0,0 @@ - -QByteArray sampleInput[2] = { -"\ -\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -\ -", - -"\ -\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -\ -" -}; - -- 1.7.9.5