removed old UI (and other) files and added new UI skeleton.
+++ /dev/null
-# -------------------------------------------------
-# Project created by QtCreator 2010-02-23T14:17:30
-# @author Speed Freak team
-# @copyright (c) 2010 Speed Freak team
-# @license http://opensource.org/licenses/gpl-license.php GNU Public License
-# -------------------------------------------------
-QT += network \
- dbus \
- xml
-TARGET = UI
-TEMPLATE = app
-SOURCES += main.cpp \
- carmainwindow.cpp \
- resultdialog.cpp \
- stringlistmodel.cpp \
- measuredialog.cpp \
- calculate.cpp \
- accelerometer.cpp \
- loginwindow.cpp \
- registration.cpp \
- measures.cpp \
- xmlwriter.cpp \
- xmlreader.cpp \
- httpclient.cpp \
- categorylist.cpp \
- welcomedialog.cpp \
- gpsdata.cpp \
- maemo5locationprivate.cpp \
- maemo5location.cpp \
- routedialog.cpp \
- movingaverage.cpp
-HEADERS += carmainwindow.h \
- resultdialog.h \
- stringlistmodel.h \
- measuredialog.h \
- accelerometer.h \
- calculate.h \
- loginwindow.h \
- registration.h \
- measures.h \
- xmlwriter.h \
- xmlreader.h \
- httpclient.h \
- categorylist.h \
- welcomedialog.h \
- gpsdata.h \
- maemo5locationprivate.h \
- maemo5location.h \
- routedialog.h \
- movingaverage.h
-FORMS += carmainwindow.ui \
- resultdialog.ui \
- measuredialog.ui \
- loginwindow.ui \
- registration.ui \
- welcomedialog.ui \
- routedialog.ui
-
-contains(QT_CONFIG, hildon):CONFIG += hildon
-CONFIG += link_pkgconfig
-
-# Enable this to disable debugging
-# DEFINES += QT_NO_DEBUG_OUTPUT
-target.path += /usr/lib
-devincludes.files = $$HEADERS
-devincludes.path += /usr/include/$$TEMPLATE$$TARGET
-INSTALLS += target \
- devincludes
-PKGCONFIG += glib-2.0 \
- liblocation
-exists(/usr/lib/liblocation.so) {
- DEFINES += LIBLOCATION
- message(liblocation found)
-}
+++ /dev/null
-<!DOCTYPE QtCreatorProject>
-<qtcreator>
- <data>
- <variable>RunConfiguration0-BaseEnvironmentBase</variable>
- <value type="int">2</value>
- </data>
- <data>
- <variable>RunConfiguration0-CommandLineArguments</variable>
- <valuelist type="QVariantList"/>
- </data>
- <data>
- <variable>RunConfiguration0-ProFile</variable>
- <value type="QString">UI.pro</value>
- </data>
- <data>
- <variable>RunConfiguration0-RunConfiguration.name</variable>
- <value type="QString">UI</value>
- </data>
- <data>
- <variable>RunConfiguration0-UseDyldImageSuffix</variable>
- <value type="bool">false</value>
- </data>
- <data>
- <variable>RunConfiguration0-UseTerminal</variable>
- <value type="bool">false</value>
- </data>
- <data>
- <variable>RunConfiguration0-UserEnvironmentChanges</variable>
- <valuelist type="QVariantList"/>
- </data>
- <data>
- <variable>RunConfiguration0-UserSetName</variable>
- <value type="bool">false</value>
- </data>
- <data>
- <variable>RunConfiguration0-UserSetWorkingDirectory</variable>
- <value type="bool">false</value>
- </data>
- <data>
- <variable>RunConfiguration0-UserWorkingDirectory</variable>
- <value type="QString"></value>
- </data>
- <data>
- <variable>RunConfiguration0-type</variable>
- <value type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
- </data>
- <data>
- <variable>activeRunConfiguration</variable>
- <value type="int">0</value>
- </data>
- <data>
- <variable>activebuildconfiguration</variable>
- <value type="QString">Debug</value>
- </data>
- <data>
- <variable>buildConfiguration-Debug</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
- <value key="QtVersionId" type="int">0</value>
- <value key="ToolChain" type="int">0</value>
- <value key="addQDumper" type=""></value>
- <value key="buildConfiguration" type="int">2</value>
- </valuemap>
- </data>
- <data>
- <variable>buildConfiguration-Release</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
- <value key="QtVersionId" type="int">0</value>
- <value key="ToolChain" type="int">0</value>
- <value key="addQDumper" type=""></value>
- <value key="buildConfiguration" type="int">0</value>
- </valuemap>
- </data>
- <data>
- <variable>buildconfiguration-Debug-buildstep0</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
- <valuelist key="abstractProcess.Environment" type="QVariantList">
- <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-51tDZ2Xnqs,guid=d9736a446700e43c64f1e7f04ba083b3</value>
- <value type="QString">DESKTOP_SESSION=gnome</value>
- <value type="QString">DISPLAY=:0.0</value>
- <value type="QString">GDMSESSION=gnome</value>
- <value type="QString">GDM_KEYBOARD_LAYOUT=fi classic</value>
- <value type="QString">GDM_LANG=en_US.UTF-8</value>
- <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
- <value type="QString">GNOME_KEYRING_SOCKET=/tmp/keyring-GEEl2F/socket</value>
- <value type="QString">GTK_MODULES=canberra-gtk-module</value>
- <value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/tkk/.gtkrc-1.2-gnome2</value>
- <value type="QString">HOME=/home/tkk</value>
- <value type="QString">LANG=en_US.UTF-8</value>
- <value type="QString">LD_LIBRARY_PATH=/home/tkk/qtsdk-2010.01/lib/qtcreator:</value>
- <value type="QString">LOGNAME=tkk</value>
- <value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-tkk</value>
- <value type="QString">PATH=/home/tkk/qtsdk-2010.01/qt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
- <value type="QString">PWD=/home/tkk/qtsdk-2010.01/bin</value>
- <value type="QString">QTDIR=/home/tkk/qtsdk-2010.01/qt</value>
- <value type="QString">SESSION_MANAGER=local/tkk-laptop:@/tmp/.ICE-unix/1211,unix/tkk-laptop:/tmp/.ICE-unix/1211</value>
- <value type="QString">SHELL=/bin/bash</value>
- <value type="QString">SPEECHD_PORT=7560</value>
- <value type="QString">SSH_AGENT_PID=1380</value>
- <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-GEEl2F/socket.ssh</value>
- <value type="QString">USER=tkk</value>
- <value type="QString">USERNAME=tkk</value>
- <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-tkk-r3DlIx/database</value>
- <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
- <value type="QString">XDG_SESSION_COOKIE=cac5a30ec2a4b235840876964b6a848d-1268810656.39871-1736995145</value>
- </valuelist>
- <valuelist key="abstractProcess.arguments" type="QVariantList">
- <value type="QString">/home/tkk/speedfreak/Client/UI.pro</value>
- <value type="QString">-spec</value>
- <value type="QString">linux-g++</value>
- <value type="QString">-r</value>
- <value type="QString">CONFIG+=debug</value>
- </valuelist>
- <value key="abstractProcess.command" type="QString">/home/tkk/qtsdk-2010.01/qt/bin/qmake</value>
- <value key="abstractProcess.enabled" type="bool">false</value>
- <value key="abstractProcess.workingDirectory" type="QString">/home/tkk/speedfreak/Client</value>
- </valuemap>
- </data>
- <data>
- <variable>buildconfiguration-Debug-buildstep1</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
- <valuelist key="abstractProcess.Environment" type="QVariantList">
- <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-51tDZ2Xnqs,guid=d9736a446700e43c64f1e7f04ba083b3</value>
- <value type="QString">DESKTOP_SESSION=gnome</value>
- <value type="QString">DISPLAY=:0.0</value>
- <value type="QString">GDMSESSION=gnome</value>
- <value type="QString">GDM_KEYBOARD_LAYOUT=fi classic</value>
- <value type="QString">GDM_LANG=en_US.UTF-8</value>
- <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
- <value type="QString">GNOME_KEYRING_SOCKET=/tmp/keyring-GEEl2F/socket</value>
- <value type="QString">GTK_MODULES=canberra-gtk-module</value>
- <value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/tkk/.gtkrc-1.2-gnome2</value>
- <value type="QString">HOME=/home/tkk</value>
- <value type="QString">LANG=en_US.UTF-8</value>
- <value type="QString">LD_LIBRARY_PATH=/home/tkk/qtsdk-2010.01/lib/qtcreator:</value>
- <value type="QString">LOGNAME=tkk</value>
- <value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-tkk</value>
- <value type="QString">PATH=/home/tkk/qtsdk-2010.01/qt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
- <value type="QString">PWD=/home/tkk/qtsdk-2010.01/bin</value>
- <value type="QString">QTDIR=/home/tkk/qtsdk-2010.01/qt</value>
- <value type="QString">SESSION_MANAGER=local/tkk-laptop:@/tmp/.ICE-unix/1211,unix/tkk-laptop:/tmp/.ICE-unix/1211</value>
- <value type="QString">SHELL=/bin/bash</value>
- <value type="QString">SPEECHD_PORT=7560</value>
- <value type="QString">SSH_AGENT_PID=1380</value>
- <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-GEEl2F/socket.ssh</value>
- <value type="QString">USER=tkk</value>
- <value type="QString">USERNAME=tkk</value>
- <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-tkk-r3DlIx/database</value>
- <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
- <value type="QString">XDG_SESSION_COOKIE=cac5a30ec2a4b235840876964b6a848d-1268810656.39871-1736995145</value>
- </valuelist>
- <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
- <valuelist key="abstractProcess.arguments" type="QVariantList">
- <value type="QString">-w</value>
- </valuelist>
- <value key="abstractProcess.command" type="QString">/usr/bin/make</value>
- <value key="abstractProcess.enabled" type="bool">true</value>
- <value key="abstractProcess.workingDirectory" type="QString">/home/tkk/speedfreak/Client</value>
- </valuemap>
- </data>
- <data>
- <variable>buildconfiguration-Debug-cleanstep0</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
- <valuelist key="abstractProcess.Environment" type="QVariantList">
- <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-51tDZ2Xnqs,guid=d9736a446700e43c64f1e7f04ba083b3</value>
- <value type="QString">DESKTOP_SESSION=gnome</value>
- <value type="QString">DISPLAY=:0.0</value>
- <value type="QString">GDMSESSION=gnome</value>
- <value type="QString">GDM_KEYBOARD_LAYOUT=fi classic</value>
- <value type="QString">GDM_LANG=en_US.UTF-8</value>
- <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
- <value type="QString">GNOME_KEYRING_SOCKET=/tmp/keyring-GEEl2F/socket</value>
- <value type="QString">GTK_MODULES=canberra-gtk-module</value>
- <value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/tkk/.gtkrc-1.2-gnome2</value>
- <value type="QString">HOME=/home/tkk</value>
- <value type="QString">LANG=en_US.UTF-8</value>
- <value type="QString">LD_LIBRARY_PATH=/home/tkk/qtsdk-2010.01/lib/qtcreator:</value>
- <value type="QString">LOGNAME=tkk</value>
- <value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-tkk</value>
- <value type="QString">PATH=/home/tkk/qtsdk-2010.01/qt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
- <value type="QString">PWD=/home/tkk/qtsdk-2010.01/bin</value>
- <value type="QString">QTDIR=/home/tkk/qtsdk-2010.01/qt</value>
- <value type="QString">SESSION_MANAGER=local/tkk-laptop:@/tmp/.ICE-unix/1211,unix/tkk-laptop:/tmp/.ICE-unix/1211</value>
- <value type="QString">SHELL=/bin/bash</value>
- <value type="QString">SPEECHD_PORT=7560</value>
- <value type="QString">SSH_AGENT_PID=1380</value>
- <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-GEEl2F/socket.ssh</value>
- <value type="QString">USER=tkk</value>
- <value type="QString">USERNAME=tkk</value>
- <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-tkk-r3DlIx/database</value>
- <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
- <value type="QString">XDG_SESSION_COOKIE=cac5a30ec2a4b235840876964b6a848d-1268810656.39871-1736995145</value>
- </valuelist>
- <value key="abstractProcess.IgnoreReturnValue" type="bool">true</value>
- <valuelist key="abstractProcess.arguments" type="QVariantList">
- <value type="QString">clean</value>
- <value type="QString">-w</value>
- </valuelist>
- <value key="abstractProcess.command" type="QString">/usr/bin/make</value>
- <value key="abstractProcess.enabled" type="bool">true</value>
- <value key="abstractProcess.workingDirectory" type="QString">/home/tkk/speedfreak/Client</value>
- <value key="cleanConfig" type="bool">true</value>
- <valuelist key="makeargs" type="QVariantList">
- <value type="QString">clean</value>
- </valuelist>
- </valuemap>
- </data>
- <data>
- <variable>buildconfiguration-Release-buildstep0</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
- </valuemap>
- </data>
- <data>
- <variable>buildconfiguration-Release-buildstep1</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
- </valuemap>
- </data>
- <data>
- <variable>buildconfiguration-Release-cleanstep0</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
- </valuemap>
- </data>
- <data>
- <variable>buildconfigurations</variable>
- <valuelist type="QVariantList">
- <value type="QString">Debug</value>
- <value type="QString">Release</value>
- </valuelist>
- </data>
- <data>
- <variable>buildstep0</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
- <value key="mkspec" type="QString"></value>
- </valuemap>
- </data>
- <data>
- <variable>buildstep1</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
- </valuemap>
- </data>
- <data>
- <variable>buildsteps</variable>
- <valuelist type="QVariantList">
- <value type="QString">trolltech.qt4projectmanager.qmake</value>
- <value type="QString">trolltech.qt4projectmanager.make</value>
- </valuelist>
- </data>
- <data>
- <variable>cleanstep0</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
- <value key="clean" type="bool">true</value>
- </valuemap>
- </data>
- <data>
- <variable>cleansteps</variable>
- <valuelist type="QVariantList">
- <value type="QString">trolltech.qt4projectmanager.make</value>
- </valuelist>
- </data>
- <data>
- <variable>defaultFileEncoding</variable>
- <value type="QByteArray">System</value>
- </data>
- <data>
- <variable>project</variable>
- <valuemap type="QVariantMap"/>
- </data>
-</qtcreator>
+++ /dev/null
-/*
- * Accelerometer class to access the device accelerometer
- *
- * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
- * @author Kai Rasilainen <kai.rasilainen@fudeco.com>
- * @author Jukka Kurttila <jukka.kurttila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "accelerometer.h"
-
-#include <QDBusConnection>
-#include <QDBusInterface>
-#include <QDBusPendingReply>
-
-#define kFilteringFactor 0.2
-
-/**
- * Default constructor for Accelerometer class
- *
- */
-Accelerometer::Accelerometer()
-{
- initValues();
-}
-
-/**
- * Default destructor for Accelerometer class
- *
- */
-Accelerometer::~Accelerometer()
-{
-}
-
-/**
- * Init class members
- *
- */
-void Accelerometer::initValues()
-{
- previousAccelerationX = 0;
- previousAccelerationY = 0;
- previousAccelerationZ = 0;
- calibrationX = 0;
- calibrationY = 0;
- calibrationZ = 0;
-}
-
-/**
- * Calibrate. Purpose of this function is to calibrate
- * accelerometer when stationary.
- *
- */
-void Accelerometer::calibrate(void)
-{
- unsigned int iteration = 0;
- qreal sampleX, sampleY, sampleZ;
-
- do {
-
- getAcceleration(sampleX, sampleY, sampleZ);
-
- calibrationX += sampleX; // Accumulate Samples
- calibrationY += sampleY; // for all axes.
- calibrationZ += sampleZ;
-
- iteration++;
-
- } while(iteration != 1024); // 1024 times
-
- calibrationX = calibrationX/1024; // division by 1024
- calibrationY = calibrationY/1024;
- calibrationZ = calibrationZ/1024;
-}
-
-/**
- * Smooths Accelerometer data by applying a low pass filter to data
- *
- * @param x accelerometer's x-axis input
- * @param y accelerometer's y-axis input
- * @param z accelerometer's z-axis input
- */
-void Accelerometer::smoothData(qreal &x, qreal &y, qreal &z)
-{
- x = (previousAccelerationX * (1 - kFilteringFactor)) + (x * kFilteringFactor);
- y = (previousAccelerationY * (1 - kFilteringFactor)) + (y * kFilteringFactor);
- z = (previousAccelerationZ * (1 - kFilteringFactor)) + (z * kFilteringFactor);
-
- previousAccelerationX = x;
- previousAccelerationY = y;
- previousAccelerationZ = z;
-}
-
-/**
- * Gets the raw acceleration data from accelerometer
- *
- * @param x accelerometer's x-axis input
- * @param y accelerometer's y-axis input
- * @param z accelerometer's z-axis input
- */
-void Accelerometer::getAcceleration(qreal &x, qreal &y, qreal &z)
-{
- QDBusConnection connection(QDBusConnection::systemBus());
- if (connection.isConnected()) {
- QDBusInterface interface("com.nokia.mce", "/com/nokia/icd", QString(), connection);
- QDBusPendingReply<QString, QString, QString, int, int, int> reply;
- reply = interface.asyncCall("get_device_orientation");
- reply.waitForFinished();
- x = static_cast<qreal>(reply.argumentAt<3>()) / 1000;
- y = static_cast<qreal>(reply.argumentAt<4>()) / 1000;
- z = static_cast<qreal>(reply.argumentAt<5>()) / 1000;
- }
-}
-
-/**
- * Get the x calibration component
- *
- * @return calibrationX x calibration component
- */
-qreal Accelerometer::getCalibrationX()
-{
- return calibrationX;
-}
-
-/**
- * Get the y calibration component
- *
- * @return calibrationY y calibration component
- */
-qreal Accelerometer::getCalibrationY()
-{
- return calibrationY;
-}
-
-/**
- * Get the z calibration component
- *
- * @return calibrationZ z calibration component
- */
-qreal Accelerometer::getCalibrationZ()
-{
- return calibrationZ;
-}
+++ /dev/null
-/*
- * Accelerometer class to access the device accelerometer
- *
- * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
- * @author Kai Rasilainen <kai.rasilainen@fudeco.com>
- * @author Jukka Kurttila <jukka.kurttila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef ACCELEROMETER_H
-#define ACCELEROMETER_H
-
-#include <QObject>
-
-#include "calculate.h"
-
-class Accelerometer : public QObject
-{
- Q_OBJECT
-public:
- Accelerometer();
- ~Accelerometer();
-
- void getAcceleration(qreal &x, qreal &y, qreal &z);
- void smoothData(qreal &x, qreal &y, qreal &z);
- void calibrate();
- void initValues();
-
- qreal getCalibrationX();
- qreal getCalibrationY();
- qreal getCalibrationZ();
-
-private:
- qreal previousAccelerationX, previousAccelerationY, previousAccelerationZ;
- qreal calibrationX, calibrationY, calibrationZ;
-};
-
-#endif // ACCELEROMETER_H
+++ /dev/null
-/*
- * Calculate class to process accelerometer data
- *
- * @author Kai Rasilainen
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "calculate.h"
-#include <math.h>
-
-#include <QFile>
-#include <QString>
-#include <QTimer>
-#include <QRegExp>
-
-const double G_ACCELERATION = 9.80665;
-const double SECONDS_IN_HOUR = 3600;
-const double AIR_DENSITY = 1.225;
-const double WATTS_PER_HORSEPOWER = 745.69987158227025;
-
-const double carFrontalArea = 1.5;
-const double dragCoefficient = 0.31;
-const int carWeight = 850;
-
-Calculate::Calculate()
-{
- this->reset();
-}
-
-Calculate::~Calculate()
-{
-
-}
-
-void Calculate::reset()
-{
- averageSpeed = 0;
- averagePower = 0;
- peakPower = 0;
- currentPower = 0;
- currentSpeed = 0;
- maxSpeed = 0;
- distanceTraveled = 0;
- lastAcceleration = 0;
- lastDistance = 0;
- lastSpeed = 0;
- numOfIterations = 0;
- totalTime = 0;
- count = 0;
-
- speedCheckPoints.append(10);
- speedCheckPoints.append(20);
- speedCheckPoints.append(30);
- speedCheckPoints.append(40);
-
-}
-
-
-/**
- * This is a main function for calculating various parameters. Accelerometer
- * provides currentAcceleration and calling function measures time (seconds).
- * This function should be called 20-30 times/second to minimize
- * calculation error.
-
- * To be added: ---
- */
-void Calculate::calculateParameters(double currentAcceleration, double seconds)
-{
- double force, power1, power2;
-
- currentAcceleration *= G_ACCELERATION;
- numOfIterations++;
- totalTime = (totalTime + seconds);
-
- // v=v0 + a*t
- // v(n) = v(n-1)+(a(n) + a(n-1))*(seconds)/2
-
- // First integration of acceleration provides speed
- currentSpeed = (lastSpeed + (((currentAcceleration + lastAcceleration) * seconds) / 2));
-
- // Update maximum speed
- if (currentSpeed > maxSpeed)
- maxSpeed = currentSpeed;
-
- // Second integration: distance.
- distanceTraveled = (lastDistance + (((currentSpeed + lastSpeed) * seconds) / 2));
-
- // Average speed
- averageSpeed = (distanceTraveled / totalTime);
-
- // F=ma
- force = (carWeight * currentAcceleration);
-
- power1 = (force * currentSpeed);
-
- power2 = ((AIR_DENSITY * (pow(currentSpeed, 3)
- * (carFrontalArea * dragCoefficient))) / 2);
-
- currentPower = ((power1 + power2) / WATTS_PER_HORSEPOWER);
-
- // Save peak power
- if ((currentPower > peakPower))
- {
- peakPower = currentPower;
- }
-
- if ((currentPower > 0))
- {
- averagePower = (averagePower + currentPower);
- }
- else
- {
- numOfIterations--;
- }
-
- // Checkpoints
- if ((lastSpeed == 0))
- {
- lastCheckpoint = 0;
- }
-
- // List of checkpoints
- if (!(speedCheckPoints.isEmpty()))
- {
- foreach (double speed, speedCheckPoints)
- {
- if ((lastCheckpoint != floor(speed)) && (floor(getCurrentSpeed()) == floor(speed)))
- {
- emit checkPointReached(totalTime, getCurrentSpeed());
- lastCheckpoint = floor(getCurrentSpeed());
- }
- }
- }
-
- // Check for movement
- accelStoppedCheck(currentAcceleration);
-
- lastSpeed = currentSpeed;
- lastAcceleration = currentAcceleration;
- lastDistance = distanceTraveled;
-}
-
-/**
- * This function checks if acceleration has stopped for
- * a short period of time. Velocity is set to zero to avoid
- * distance errors.
- */
-void Calculate::accelStoppedCheck(double currentAcceleration)
-{
- // counting number of acceleration samples that equals zero
- if (currentAcceleration==0) {
- count++;
- } else {
- count = 0;
- }
-
- // if count exceeds 25, we assume that velocity is zero
- if (count >= 25)
- {
- currentSpeed=0;
- }
-}
-
-// Getters and setters
-
-double Calculate::getAverageSpeed()
-{
- return averageSpeed;
-}
-
-void Calculate::setAverageSpeed(double value)
-{
- averageSpeed = value;
-}
-
-double Calculate::getCurrentSpeed()
-{
- return currentSpeed;
-}
-
-void Calculate::setCurrentSpeed(double value)
-{
- currentSpeed = value;
-}
-
-double Calculate::getDistanceTraveled()
-{
- return distanceTraveled;
-}
-
-void Calculate::setDistanceTraveled(double value)
-{
- distanceTraveled = value;
-}
-
-double Calculate::getLastAcceleration()
-{
- return lastAcceleration;
-}
-
-void Calculate::setLastAcceleration(double value)
-{
- lastAcceleration = value;
-}
-
-double Calculate::getLastDistance()
-{
- return lastDistance;
-}
-
-void Calculate::setLastDistance(double value)
-{
- lastDistance = value;
-}
-
-double Calculate::getLastSpeed()
-{
- return lastSpeed;
-}
-
-void Calculate::setLastSpeed(double value)
-{
- lastSpeed = value;
-}
-
-long Calculate::getNumOfIterations()
-{
- return numOfIterations;
-}
-
-void Calculate::setNumOfIterations(long value)
-{
- numOfIterations = value;
-}
-
-double Calculate::getTotalTime()
-{
- return totalTime;
-}
-
-void Calculate::setTotalTime(double value)
-{
- totalTime = value;
-}
-
-double Calculate::getCurrentPower()
-{
- return currentPower;
-}
-
-void Calculate::setCurrentPower(double value)
-{
- currentPower = value;
-}
-
-double Calculate::getPeakPower()
-{
- return peakPower;
-}
-
-void Calculate::setPeakPower(double value)
-{
- peakPower = value;
-}
-
-double Calculate::getAveragePower()
-{
- if (numOfIterations > 0)
- {
- return (averagePower/numOfIterations);
- }
- else
- {
- return 0;
- }
-}
-
-void Calculate::setAveragePower(double value)
-{
- averagePower = value;
-}
-
-double Calculate::getMaxSpeed()
-{
- return maxSpeed;
-}
-
-void Calculate::setMaxSpeed(double value)
-{
- maxSpeed = value;
-}
-
+++ /dev/null
-/*
- * Calculate class to process accelerometer data
- *
- * @author Kai Rasilainen
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef CALCULATE_H
-#define CALCULATE_H
-
-#include <QObject>
-#include <QTime>
-#include <QList>
-
-class Calculate : public QObject
-{
- Q_OBJECT
-
-public:
- Calculate();
- ~Calculate();
-
- void reset();
- void calculateParameters(double currentAcceleration, double seconds);
- void accelStoppedCheck(double currentAcceleration);
-
- double getAverageSpeed();
- void setAverageSpeed(double value);
-
- double getCurrentSpeed();
- void setCurrentSpeed(double value);
-
- double getDistanceTraveled();
- void setDistanceTraveled(double value);
-
- double getLastAcceleration();
- void setLastAcceleration(double value);
-
- double getLastCheckpoint();
- void setLastCheckpoint(double value);
-
- double getLastDistance();
- void setLastDistance(double value);
-
- double getLastSpeed();
- void setLastSpeed(double value);
-
- long getNumOfIterations();
- void setNumOfIterations(long value);
-
- double getTotalTime();
- void setTotalTime(double value);
-
- double getCurrentPower();
- void setCurrentPower(double value);
-
- double getPeakPower();
- void setPeakPower(double value);
-
- double getAveragePower();
- void setAveragePower(double value);
-
- double getMaxSpeed();
- void setMaxSpeed(double value);
-
-private:
- double averageSpeed;
- double currentSpeed;
- double maxSpeed;
- double distanceTraveled;
- double lastAcceleration;
- double lastCheckpoint;
- double lastDistance;
- double lastSpeed;
- long numOfIterations;
- double totalTime;
- int count;
- double peakPower;
- double currentPower;
- double averagePower;
- QList<int> speedCheckPoints;
-
-signals:
- void checkPointReached(double totalTime, double currentSpeed);
-
-};
-
-#endif // CALCULATE_H
+++ /dev/null
-/*
- * CarMainWindow main class
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @author Janne Änäkkälä <janne.anakkala@fudeco.com>
- * @author Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
- * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
- * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
- * @author Kai Rasilainen <kai.rasilainen@fudeco.com>
- * @author Jukka Kurttila <jukka.kurttila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "carmainwindow.h"
-#include "math.h"
-
-#define kAccelerometerSampleRate 40
-#define kFilteringFactor 0.1
-#define kSecondsInHour 3600
-
-/**
- *Constructor of this class.
- *@param QWidget pointer to parent object. By default the value is NULL.
- */
-CarMainWindow::CarMainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::CarMainWindow)
-{
- ui->setupUi(this);
- ui->tabWidget->setCurrentWidget(this->ui->StartTab);
-
- //Disable start buttons before calibration
- ui->autoStartButton->setEnabled(false);
- ui->manualStartButton->setEnabled(false);
-
- result = new ResultDialog();
- //measure = new MeasureDialog();
- welcomeDialog = new WelcomeDialog();
- welcomeDialog->show();
-
- initComboBoxStartTabUnits();
- initListViewStartTabAccelerationCategories();
-
- myLogin = new LoginWindow(this);
- myCategorylist = new CategoryList();
- myHttpClient = new HttpClient(this);
- myRegistration = new Registration(this);
- connect(myRegistration,SIGNAL(sendregistration()),this,SLOT(regUserToServer()));
- connect(myLogin,SIGNAL(userNameChanged()),this,SLOT(userLogin()));
- connect(myHttpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
- connect(myHttpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));
- myRoute = new RouteDialog( this);
-
- //GPS
- location = new Maemo5Location(this);
- gpsData = new GPSData(location);
- connect(location,SIGNAL(agnss()),this,SLOT(gpsStatus()));
- gpsTime = new QDateTime();
- gpsTimer = new QTimer();
- connect(gpsTimer, SIGNAL(timeout()),this, SLOT(gpsTimerTimeout()));
- gpsSpeedNow = 0.0;
- gpsSpeedPrevious = 0.0;
- gpsAcceleration = 0.0;
- timeFromGps = 0.0; //Measure-tab view.
- gpsSpeed = 0.0;
-
- this->time = 0;
- this->speed = 0;
- counterForSaveResults = 0;
- timer = new QTimer();
-
- // Accelerometer
- accelerometer = new Accelerometer();
- movingAverageZ = new MovingAverage(10);
-
- reverseAccelerationFlag = false;
- vehicleStartedMoving = false;
- isNewRun = true;
- isSetup = false;
- stopTime = 0;
- accelerationStartThreshold = 0.1;
-
- accelerometerTimer = new QTimer(this);
- connect(accelerometerTimer, SIGNAL(timeout()), this, SLOT(readAccelerometerData()));
- //accelerometerTimer->start(kAccelerometerSampleRate);
-
- // Calculate
- calculate = new Calculate();
- connect(calculate, SIGNAL(checkPointReached()), this, SLOT(handleCheckPoint()));
-
- resetAccelerometerMeasurements();
-
- measures = new Measures();
- measures->initializeMembers();
-
- this->timer->setInterval(100);
-
- connect(this->timer, SIGNAL(timeout()), this, SLOT(after_timeout()));
- connect(myLogin, SIGNAL( userNameChanged()), this, SLOT(updateUserName()));
-
- ui->labelMeasureTabResult->hide();
- ui->pushButtonShowResultDialog->setEnabled(false);
- ui->pushButtonShowResultDialog->setEnabled(false);
-
- this->setWindowTitle("Speed Freak");
-}
-
-/**
- *Destructor of this class. Deletes all dynamic objects and sets them to NULL.
- */
-CarMainWindow::~CarMainWindow()
-{
- delete ui;
- ui = NULL;
- //delete result;
- //delete measure;
- delete myCategorylist;
- myCategorylist = NULL;
- delete welcomeDialog;
- welcomeDialog = NULL;
- delete myRoute;
- myRoute = NULL;
- delete gpsData;
- gpsData = NULL;
- delete gpsTime;
- gpsTime = NULL;
-
- //Route-tab view
- gpsSpeedNow = 0.0;
- gpsSpeedPrevious = 0.0;
- gpsAcceleration = 0.0;
- timeFromGps = 0.0;
- gpsSpeed = 0.0;
- gpsUpdateTime = 0;
-}
-
-/**
- *This function is used to .
- *@param
- */
-void CarMainWindow::changeEvent(QEvent *e)
-{
- QMainWindow::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-/**
- *This slot function is called when ever list view is update. Start-tab view.
- */
-void CarMainWindow::on_listViewStartTabAccelerationCategories_clicked(QModelIndex index)
-{
- QString str = index.data().toString();
- QStringList list = str.split("-");
- QStringList list3 = list[1].split(" ");
- QStringList list2 = list[0].split(" ");
-
- ui->lineEditStartTabMin->setText(list2[1]);
- ui->lineEditStartTabMax->setText(list3[0]);
- updateComboBoxStartTabUnits(list3[1]);
-}
-
-/**
- *This slot function is called when ever auto start button clicked. Start-tab view.
- *@todo Check setDiagramGapStem(100) <- (choiceInt == 2)
- */
-void CarMainWindow::on_autoStartButton_clicked()
-{
- measures->initializeMembers();
- resetAccelerometerMeasurements();
- ui->pushButtonSendResult->setEnabled(false);
- ui->pushButtonShowResultDialog->setEnabled(false);
- choice = ui->listViewStartTabAccelerationCategories->currentIndex();
- choiceInt = choice.row();
- //qDebug() << "choiceInt" << choiceInt << " " << catList.at(choiceInt);
- if (choiceInt == 0)
- {
- ui->labelMeasureTabHeader->setText("Accelerate to 40 km/h");
- result->setDiagramGapStem(75);
- }
- else if (choiceInt == 1)
- {
- ui->labelMeasureTabHeader->setText("Accelerate to 100 km/h");
- result->setDiagramGapStem(30);
- }
- else if (choiceInt == 2)
- {
- ui->labelMeasureTabHeader->setText("Accelerate to 10 km/h");
- result->setDiagramGapStem(100);
- }
- else
- {
- ui->labelMeasureTabHeader->setText("Accelerate to 80 km/h");
- result->setDiagramGapStem(37.5);
- }
- ui->labelMeasureTabResult->setText("");
-
- this->accelerometerTimer->start(kAccelerometerSampleRate);
- this->timer->start();
- this->time = 0;
- this->speed = 0;
- ui->tabWidget->setCurrentWidget(this->ui->tabMeasureResult);
-}
-
-/**
- *This slot function is called when ever list view is update. Start-tab view.
- *@param QString unit.
- */
-void CarMainWindow::updateComboBoxStartTabUnits(QString unit)
-{
- ui->comboBoxStartTabUnits->setCurrentIndex(ui->comboBoxStartTabUnits->findText(unit, Qt::MatchExactly));
-}
-
-/**
- *This function is used to init unit combobox. Start-tab view.
- */
-void CarMainWindow::initComboBoxStartTabUnits()
-{
- units << "km/h" << "km" << "h" << "m" << "min" << "Mile" << "Mph" << "in" << "ft" << "yrd";
- ui->comboBoxStartTabUnits->addItems(units);
-}
-
-/**
- *This function is used to set items to unit combobox. Start-tab view.
- *@param QStringlist units
- */
-void CarMainWindow::setComboBoxStartTabUnits(QStringList units)
-{
- ui->comboBoxStartTabUnits->addItems(units);
-}
-
-/**
- *This function is used to init listViewStartTabAccelerationCategories. Start-tab view.
- *@todo During development categories index values that are used for measuring are hardcoded
- *@todo and accelerationCategoriesStartTab and catList are used instead of using
- *@todo CategoryList::categoryList and CategoryList::cats.
- */
-void CarMainWindow::initListViewStartTabAccelerationCategories()
-{
- //Connect the user`s choice fron GUI to a correct variable name
- catList.insert(0,"acceleration-0-40");
- catList.insert(1,"acceleration-0-100");
- catList.insert(2,"acceleration-0-10");
-
- accelerationCategoriesStartTab << "Acceleration 0-40 km/h" << "Acceleration 0-100 km/h" << "Acceleration 0-10 km/h";
- //<< "0-1/4 Mile" << "0-1/8 Mile" << "50-100 Mile" << "0-60 Mph" << "0-100 m" << "0-50 ft" << "0-50 yrd" << "0-500 in";
- QAbstractItemModel *model = new StringListModel(accelerationCategoriesStartTab);
- ui->listViewStartTabAccelerationCategories->setModel(model);
-}
-
-/**
- *This function is used to set items to listViewStartTabAccelerationCategories. Start-tab view.
- *@param QStringlist accelerationCategoriesStartTab
- */
-void CarMainWindow::setListViewStartTabAccelerationCategories(QStringList accelerationCategoriesStartTab)
-{
- QAbstractItemModel *model = new StringListModel(accelerationCategoriesStartTab);
- ui->listViewStartTabAccelerationCategories->setModel(model);
-}
-
-void CarMainWindow::setLabelInfoToUser(QString infoText)
-{
- ui->labelInfoToUser->setText(infoText);
-}
-
-/**
- *This function is used to set items to category combobox. Top-tab view.
- *@param
- */
-void CarMainWindow::setCategoryCompoBox()
-{
- qDebug() << "_setCategoryCompoBox";
- ui->comboBoxTopCategory->addItems(myHttpClient->myXmlreader->myCategoryList->getCategoryList());
-}
-
-/**
- *This function prcesses UI updating after a new top10List has been received.
- *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged.
- */
-void CarMainWindow::showTop10()
-{
- int limitNr = 5;
- setListViewTopList(recentCategory, limitNr);
-}
-
-/**
- *This function is used to set items to labelTopList. Top-tab view.
- *@param Category
- *@param Size, number of results.
- */
-void CarMainWindow::setListViewTopList(QString category, int size)
-{
- qDebug() << "_setListViewTopList";
- QString topList;
- topList.append(myHttpClient->myXmlreader->myCategoryList->getTopList(category, size));
- ui->labelTopList->setText(topList);
-}
-
-/**
- *This slot function is called when speed is achieved in measure dialog. Opens result dialog.
- */
-void CarMainWindow::openResultView()
-{
-
-}
-
-/**
- *This slot function is called when registrate button is clicked.
- */
-void CarMainWindow::on_registratePushButton_clicked()
-{
- myRegistration->show();
-}
-
-/**
- *This slot function is called when ever refresh button clicked. Top-tab view.
- */
-void CarMainWindow::on_buttonTopRefresh_clicked()
-{
- myHttpClient->requestCategories();
-}
-
-/**
- *This slot function is called when ever category combobox current index changed. Top-tab view.
- *@param QString category.
- *@todo Check where limitNr is taken, fixed or user input, see showTop10.
- */
-void CarMainWindow::on_comboBoxTopCategory_currentIndexChanged(QString category)
-{
- qDebug() << "_on_comboBoxTopCategory_currentIndexChanged: " << category;
- recentCategory = category; //for showTop10()
- int limitNr = 5;
- QString limit = QString::number(limitNr);
- myHttpClient->requestTopList(category, limit);
-}
-
-/**
- *This slot function is called when set/change user button is clicked.
- */
-void CarMainWindow::on_setUserPushButton_clicked()
-{
- myLogin->show();
-}
-
-/**
- *@brief Just for development, for the real button is not shown until
- *measurin started and there are results.
- *@todo Implement with real code and yet leave sendXml in the bottom in use.
- */
-void CarMainWindow::on_manualStartButton_clicked()
-{
-
-}
-
-/**
- * This slot function is called when timer gives timeout signal. Checks current speed
- * and stores times in measure class.
- */
-void CarMainWindow::after_timeout()
-{
- //IF GPS checkbox is ON
- if (ui->gpsOnCheckBox->isChecked())
- {
- if ( gpsSpeed > 1.0 )
- {
- timeFromGps += 0.1;
- }
- }
-
- else
- {
- ui->labelMeasureTabSpeed->setText(QString::number(this->speed)); //Set speed. //Measure-tab view.
- ui->labelMeasureTabTime->setText(QString::number(this->time)); //Set time. //Measure-tab view.
- }
-}
-
-/**
- * This slot function is called when Abort button is clicked.
- */
-void CarMainWindow::on_pushButtonMeasureTabAbort_clicked()
-{
- ui->pushButtonSendResult->setEnabled(false);
- ui->pushButtonShowResultDialog->setEnabled(false);
- ui->labelMeasureTabResult->hide();
- ui->labelMeasureTabTime->setText("");
- ui->labelMeasureTabSpeed->setText("");
- measures->initializeMembers();
- this->accelerometerTimer->stop();
- this->timer->stop();
- this->time = 0;
- this->speed = 0;
- ui->tabWidget->setCurrentWidget(this->ui->StartTab);
- //this->close();
-
- //GPS
- gpsSpeed = 0.0;
- timeFromGps = 0.0;
-}
-
-/**
- *This slot function is called when pushButtonSendResult is clicked.
- *@todo Use real category value.
- */
-void CarMainWindow::on_pushButtonSendResult_clicked()
-{
- //Pick up relevant category name and pass it to the server
- myHttpClient->sendResultXml(catList.at(choiceInt));
- ui->pushButtonSendResult->setEnabled(false);
-}
-
-void CarMainWindow::updateUserName()
-{
- QString newUserName;
-
- newUserName = myLogin->getUserName();
- ui->userNameLabel->setText( "User: " + newUserName);
-
- if (newUserName.length())
- {
- ui->setUserPushButton->setText( "Change User");
- this->setWindowTitle("Speed Freak - " + newUserName);
- }
- else
- {
- ui->setUserPushButton->setText( "Set User");
- this->setWindowTitle("Speed Freak");
- }
-}
-
-void CarMainWindow::regUserToServer()
-{
- myHttpClient->requestRegistration();
-}
-
-
-void CarMainWindow::on_drawRoutePushButton_clicked()
-{
- QString routeFile = QString("route.txt");
- if (myRoute->readRouteFromFile( routeFile) == true)
- {
- myRoute->show();
- }
-}
-
-void CarMainWindow::on_sendRoutePushButton_clicked()
-{
- myHttpClient->sendRouteXml();
-}
-
-/**
- * Opens result dialog when show result button is clicked.
- * Sends measures as parameter to the resultdialogs saveMeasuresToArray-function.
- */
-void CarMainWindow::on_pushButtonShowResultDialog_clicked()
-{
- result->saveMeasuresToArray(measures);
- this->result->show();
-}
-
-void CarMainWindow::userLogin()
-{
- myHttpClient->checkLogin();
-}
-
-/**
- * Resets Accelerometer measurement variables
- */
-void CarMainWindow::resetAccelerometerMeasurements()
-{
- currentAcceleration = 0;
- currentAccelerationString = "";
- currentSpeed = "";
- currentTime = 0;
- distanceTraveled = "";
- //firstAcceleration = 0;
- //horsepower = null;
- isNewRun = true;
- //lastScreenUpdateInSeconds = 0;
- previousTime = 0;
- reverseAccelerationFlag = false;
- stopWatch.start();
- //accelerometer->stop();
- totalTime = "";
- vehicleStartedMoving = false;
- calculate->reset();
-}
-
-/**
- * This function is called to handle checkpoints
- *@param totalTime total time elapsed since starting measurements
- *@param currentSpeed current speed of the device
- */
-void CarMainWindow::handleCheckPoint(double totalTime, double currentSpeed)
-{
- switch (counterForSaveResults)
- {
- case 0:
- measures->setTime10kmh(totalTime);
- break;
-
- case 1:
- measures->setTime20kmh(totalTime);
- break;
-
- case 2:
- measures->setTime30kmh(totalTime);
- break;
-
- case 3:
- measures->setTime40kmh(totalTime);
- break;
-
- case 4:
- measures->setTime50kmh(totalTime);
- break;
-
- case 5:
- measures->setTime60kmh(totalTime);
- break;
-
- case 6:
- measures->setTime70kmh(totalTime);
- break;
-
- case 7:
- measures->setTime80kmh(totalTime);
- break;
-
- case 8:
- measures->setTime90kmh(totalTime);
- break;
-
- case 9:
- measures->setTime100kmh(totalTime);
- break;
-
- default:
- break;
- }
- counterForSaveResults++;
-
- if (choiceInt == 0 && measures->getTime40kmh() != 0)
- {
- setTimeAxisGapAndShowResult(measures->getTime40kmh());
- this->timer->stop();
- this->accelerometerTimer->stop();
- this->time = 0;
- this->speed = 0;
- counterForSaveResults = 0;
- }
- else if (choiceInt == 1 && measures->getTime100kmh() != 0)
- {
- setTimeAxisGapAndShowResult(measures->getTime100kmh());
- this->timer->stop();
- this->accelerometerTimer->stop();
- this->time = 0;
- this->speed = 0;
- counterForSaveResults = 0;
- }
- else if (choiceInt == 2 && measures->getTime10kmh() != 0)
- {
- setTimeAxisGapAndShowResult(measures->getTime10kmh());
- this->timer->stop();
- this->accelerometerTimer->stop();
- this->time = 0;
- this->speed = 0;
- counterForSaveResults = 0;
- }
- else if (choiceInt != 1 && choiceInt != 0 && measures->getTime80kmh() != 0)
- {
- setTimeAxisGapAndShowResult(measures->getTime80kmh());
- this->timer->stop();
- this->accelerometerTimer->stop();
- this->time = 0;
- this->speed = 0;
- counterForSaveResults = 0;
- }
- else
- {
- qDebug() << "something wrong in handleCheckPoint()";
- }
-}
-
-/**
- *This function is called to read (and process) data from the accelerometer
- */
-void CarMainWindow::readAccelerometerData()
-{
- QString s;
- double changeInAcceleration = 0;
- qreal x, y, z;
-
- accelerometer->getAcceleration(x, y, z);
-
- // keep the following line as close to the SetKinematicsProperties method as possible
- currentTime = stopWatch.elapsed();
-
- //accelerometer->smoothData(x, y, z);
-
- //Calculate average
- movingAverageZ->Enqueue(z);
- z = movingAverageZ->Average();
-
- // Apply calibration
- x -= accelerometer->getCalibrationX();
- y -= accelerometer->getCalibrationY();
- z -= accelerometer->getCalibrationZ();
-
- QString str = QString("acc x: " + QString::number(x) + "\n" +
- "acc y: " + QString::number(y) + "\n" +
- "acc z: " + QString::number(z) + "\n");
-
- currentAcceleration = z;//sqrt(x*x + y*y + z*z);
- changeInAcceleration = currentAcceleration;
-
- if (((fabs(changeInAcceleration) <= accelerationStartThreshold)
- && !vehicleStartedMoving))
- {
- return;
- }
- else if(!vehicleStartedMoving)
- {
- vehicleStartedMoving = true;
- stopWatch.start();
- previousTime = 0;
- currentTime = 0;
- }
-
- calculate->calculateParameters(changeInAcceleration, (currentTime - previousTime)/1000);
- previousTime = currentTime;
-
- s.sprintf("%.2f", changeInAcceleration);
- currentAccelerationString = s;
-
- speed = 0.0;
- speed = calculate->getCurrentSpeed();
- speed = speed*3.6;//((speed*1000)/kSecondsInHour);
- s.sprintf("%.1f", speed);
- currentSpeed = s;
-
- s.sprintf("%.2f", calculate->getDistanceTraveled());
- distanceTraveled = s;
-
- // TODO
- //distanceTraveled;
- //horsepower;
-
- time = calculate->getTotalTime();
-
- s.sprintf("%.2f", time);
- totalTime = s;
-
- str.append("ca: " + currentAccelerationString + " G\n" );
- str.append("cspeed: " + currentSpeed + " km/h \n" );
- str.append("dist: " + distanceTraveled + " m \n" );
- str.append("time: " + totalTime + " s \n" );
-
- if ((stopTime > 0) && (previousTime >= stopTime))
- {
- // we want to end at a stopping point that the user chose
- // output results
- resetAccelerometerMeasurements();
- }
-}
-
-/**
- *This function is used to calibrate accelerometer
- */
-void CarMainWindow::calibrateAccelerometer()
-{
- resetAccelerometerMeasurements();
- accelerometer->calibrate();
-}
-
-/**
- *This slot function is called when GPS on checkbox state changed. Route-tab view.
- *@param int GPSState
- */
-void CarMainWindow::on_gpsOnCheckBox_stateChanged(int GPSState)
-{
- //Stop polling GPS. Route-tab view.
- if (GPSState == 0)
- {
- ui->labelRouteTabGPSStatus->setText("GPS status: GPS off");
- location->stopPollingGPS();
- gpsUpdateTime = 0;
- gpsTimer->stop();
- }
- //Start polling GPS. Route-tab view.
- else
- {
- ui->labelRouteTabGPSStatus->setText("GPS status: GPS on");
- location->startPollingGPS();
- }
-}
-
-/**
- *This slot function is called when GPS status changed. Route- and measure-tab view.
- */
-void CarMainWindow::gpsStatus()
-{
- //IF GPS checkbox is ON
- if (ui->gpsOnCheckBox->isChecked())
- {
- //If GPS find 4 satellite.
- if (location->getSatellitesInUse() >= 4)
- {
- //Set gps status. Route-tab view.
- ui->labelRouteTabGPSStatus->setText("GPS ready");
-
- //Set time. Route-tab view.
- gpsTime->setTime_t(location->getTime());
- QString gpsDateNow = gpsTime->toString("dd.MM.yyyy hh:mm:ss");
- ui->labelRouteTabGPSTime->setText("GPS time: " + gpsDateNow);
-
- //Set latitude & longitude. Route-tab view.
- ui->labelRouteTabLatitude->setText("Latitude: " + QString::number(location->getLatitude()));
- ui->labelRouteTabLongitude->setText("Longitude: " + QString::number(location->getLongitude()));
-
- //Set rec status. Route-tab view.
- if (ui->startRecPushButton->text() == "Stop recording")
- {
- ui->labelRouteTabRecStatus->setText("Recorded " + QString::number(gpsData->roundCounter) + " point");
- }
-
- //Get speed. Route- and Measure-tab view.
- gpsSpeed = location->getSpeed();
-
- //Set speed. Route-tab view.
- ui->labelRouteTabSpeed->setText("Speed:" + QString::number(gpsSpeed) + "km/h +/-" + QString::number(location->getEps()) + "km/h");
-
- //Measure-tab view.
- if (gpsSpeed < 40.0)
- {
- ui->labelMeasureTabSpeed->setText(QString::number(gpsSpeed)); //Set speed. //Measure-tab view.
- ui->labelMeasureTabTime->setText(QString::number(timeFromGps)); //Set time. //Measure-tab view.
- }
- //Measure-tab view.
- else
- {
- timer->stop(); //Measure timer
- ui->labelMeasureTabResult->setText(QString::number(timeFromGps));
- ui->labelMeasureTabResult->show();
- ui->pushButtonShowResultDialog->setEnabled(true);
- ui->pushButtonShowResultDialog->setEnabled(true);
- }
- }
-
- //If GPS find less than 4 satellite.
- else
- {
- ui->labelRouteTabGPSStatus->setText("GPS status: Waiting for GPS");
- gpsTimer->stop();
- }
-
- gpsUpdateTime = 0;
- gpsTimer->start(10);
- }
-}
-
-/**
- *This slot function is called when gps timer timeout(10ms).
- */
-void CarMainWindow::gpsTimerTimeout()
-{
- int time1000ms = 0;
- time1000ms += 10;
-
- //IF time is 1 second
- if (time1000ms == 1000)
- {
- //Calculate acceleration 1/s
- gpsSpeedPrevious = gpsSpeedNow; //Previous speed
- gpsSpeedNow = (location->getSpeed())/3.6; //Speed now (m/s)
- gpsAcceleration = (gpsSpeedNow - gpsSpeedPrevious)/1; //Calculate acceleration: speed now - previous speed / 1s.
- //Set acceleration. Route-tab view.
- ui->labelRouteTabAcceleration->setText("Acceleration: " + QString::number( gpsAcceleration ) + " m/s2");
- }
-
- gpsUpdateTime++;
- //Set GPS update time. Route-tab view.
- ui->labelRouteTabGPSUpdateTime->setText("GPS update time: " + QString::number(gpsUpdateTime) + " ms");
-}
-
-/**
- *This slot function is called when start rec push button clicked. Route-tab view.
- */
-void CarMainWindow::on_startRecPushButton_clicked()
-{
- //Start route recording.
- if (ui->startRecPushButton->text() == "Start recording")
- {
- ui->startRecPushButton->setText("Stop recording");
- ui->labelRouteTabRecStatus->setText("Recording started");
- gpsData->startRouteRecording(ui->labelRouteTabGPSTime->text());
- }
-
- //Stop route recording.
- else if (ui->startRecPushButton->text() == "Stop recording")
- {
- ui->startRecPushButton->setText("Start recording");
- ui->labelRouteTabRecStatus->setText("Recording stopped");
- gpsData->stopRouteRecording(ui->labelRouteTabGPSTime->text());
- }
-}
-
-/**
- *Sets time axis right way in result dialog and shows target speed result.
- *@param double pTime is the target speed result time which is shown to the user.
- */
-void CarMainWindow::setTimeAxisGapAndShowResult(double pTime)
-{
- ui->pushButtonShowResultDialog->setEnabled(true);
- ui->pushButtonSendResult->setEnabled(true);
- QString timeInteger;
- timeInteger.setNum(pTime);
- ui->labelMeasureTabResult->show();
- ui->labelMeasureTabResult->setText(timeInteger);
-
- if (floor(pTime) <= 5)
- {
- result->setDiagramGapHorizontal(80);
- }
-
- else if (floor(pTime) <= 10)
- {
- result->setDiagramGapHorizontal(40);
- }
-
- else
- {
- result->setDiagramGapHorizontal(20);
- }
-}
-
-void CarMainWindow::on_calibrateButton_clicked()
-{
- ui->autoStartButton->setEnabled(true);
- ui->manualStartButton->setEnabled(true);
-
- this->accelerometer->calibrate();
-}
-
+++ /dev/null
-/*
- * CarMainWindow main class
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @author Janne Änäkkälä <janne.anakkala@fudeco.com>
- * @author Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
- * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
- * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
- * @author Kai Rasilainen <kai.rasilainen@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef CARMAINWINDOW_H
-#define CARMAINWINDOW_H
-
-#include <QMainWindow>
-#include <QStandardItemModel>
-#include <QModelIndex>
-#include <QStringList>
-#include <QString>
-#include <QNetworkAccessManager>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QMessageBox>
-#include <QStandardItemModel>
-#include <QBuffer>
-#include <QByteArray>
-#include <QDebug>
-#include <qdatetime.h>
-#include "resultdialog.h"
-//#include "measuredialog.h"
-#include "welcomedialog.h"
-#include "loginwindow.h"
-#include "registration.h"
-#include "xmlwriter.h"
-#include "xmlreader.h"
-#include "ui_carmainwindow.h"
-#include "stringlistmodel.h"
-#include "measures.h"
-#include "accelerometer.h"
-#include "categorylist.h"
-#include "httpclient.h"
-#include "routedialog.h"
-#include "calculate.h"
-#include "gpsdata.h"
-#include "movingaverage.h"
-#include <maemo5location.h>
-
-namespace Ui {
- class CarMainWindow;
-}
-
-class CarMainWindow : public QMainWindow {
- Q_OBJECT
-public:
- CarMainWindow(QWidget *parent = 0);
- ~CarMainWindow();
- Registration *myRegistration; //Check if this should be public or private
- LoginWindow *myLogin;
- GPSData *gpsData;
-
- void setComboBoxStartTabUnits(QStringList units); //Start-tab view
- void setListViewStartTabAccelerationCategories(QStringList numbers); //Start-tab view
- void setLabelInfoToUser(QString infoText);
-
-protected:
- void changeEvent(QEvent *e);
-
-private:
- Ui::CarMainWindow *ui;
- ResultDialog *result;
- //MeasureDialog *measure;
- WelcomeDialog *welcomeDialog;
- CategoryList *myCategorylist;
- HttpClient *myHttpClient;
- RouteDialog *myRoute;
- Maemo5Location *location;
- //void initCategoryCompoBox();
- void initComboBoxStartTabUnits(); //Start-tab view
- void initListViewStartTabAccelerationCategories(); //Start-tab view
- void setListViewTopList(QString category, int size); //Top-tab view
- void resetAccelerometerMeasurements();
- void calibrateAccelerometer();
- void setTimeAxisGapAndShowResult(double pTime);
-
-private:
- QStringList accelerationCategoriesStartTab; //Start-tab view
- QStringList units; //Start-tab view
- QString recentCategory;
-
- QTimer *timer;
- Accelerometer *accelerometer;
- MovingAverage* movingAverageZ;
- double time;
- double speed;
- Measures *measures;
-
- QModelIndex choice;
- int choiceInt;
- QStringList catList;
-
- Calculate *calculate;
-
- bool reverseAccelerationFlag;
- bool vehicleStartedMoving;
- bool isNewRun;
- bool isSetup;
-
- double stopTime;
- double accelerationStartThreshold;
- double currentAcceleration;
- double currentTime;
- double previousTime;
- //double firstAcceleration;
-
- QTimer *accelerometerTimer;
- QTime stopWatch;
-
- QString currentAccelerationString;
- QString currentSpeed;
- QString distanceTraveled;
- QString horsepower;
- QString totalTime;
-
- QDateTime *gpsTime;
- QTimer *gpsTimer;
- double gpsSpeedNow; //Route-tab view
- double gpsSpeedPrevious;//Route-tab view
- double gpsAcceleration; //Route-tab view
- double timeFromGps; //Route-tab view
- double gpsSpeed; //Route-tab view
- int gpsUpdateTime; //Route-tab view
-
- int counterForSaveResults;
-
-signals:
- void speedAchieved();
- void userNameChanged();
-
-private slots:
- void on_calibrateButton_clicked();
- void gpsTimerTimeout(); //Route-tab view
- void on_startRecPushButton_clicked(); //Route-tab view
- void on_pushButtonShowResultDialog_clicked();
- void on_gpsOnCheckBox_stateChanged(int GPSState); //Route-tab view
- void gpsStatus(); //Route-tab view
- void on_drawRoutePushButton_clicked();
- void on_sendRoutePushButton_clicked();
- void on_pushButtonSendResult_clicked();
- void on_pushButtonMeasureTabAbort_clicked();
- void on_manualStartButton_clicked();
- void on_setUserPushButton_clicked();
- void on_registratePushButton_clicked();
- void on_comboBoxTopCategory_currentIndexChanged(QString category); //Top-tab view
- void on_listViewStartTabAccelerationCategories_clicked(QModelIndex index); //Start-tab view
- void updateComboBoxStartTabUnits(QString unit); //Start-tab view
- void openResultView();
- void on_buttonTopRefresh_clicked(); //Top-tab view: button
- void on_autoStartButton_clicked(); //Start-tab view: button
- void after_timeout();
- void updateUserName();
- void regUserToServer();
- void userLogin();
- void readAccelerometerData();
- void handleCheckPoint(double totalTime, double currentSpeed);
- void setCategoryCompoBox(); //Top-tab
- void showTop10();
-
-};
-
-#endif // CARMAINWINDOW_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>CarMainWindow</class>
- <widget class="QMainWindow" name="CarMainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>480</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Speed freak</string>
- </property>
- <widget class="QWidget" name="centralWidget">
- <widget class="QTabWidget" name="tabWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>781</width>
- <height>361</height>
- </rect>
- </property>
- <property name="currentIndex">
- <number>4</number>
- </property>
- <widget class="QWidget" name="tabTop">
- <attribute name="title">
- <string>Top</string>
- </attribute>
- <widget class="QPushButton" name="buttonTopRefresh">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>210</y>
- <width>221</width>
- <height>71</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>16</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Refresh list</string>
- </property>
- </widget>
- <widget class="QListView" name="listViewTopList">
- <property name="geometry">
- <rect>
- <x>360</x>
- <y>10</y>
- <width>411</width>
- <height>311</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>10</pointsize>
- </font>
- </property>
- <property name="flow">
- <enum>QListView::LeftToRight</enum>
- </property>
- </widget>
- <widget class="QWidget" name="layoutWidget">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>10</y>
- <width>341</width>
- <height>141</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <widget class="QLabel" name="labelCategory">
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>16</pointsize>
- </font>
- </property>
- <property name="text">
- <string>Category:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="comboBoxTopCategory"/>
- </item>
- </layout>
- </widget>
- <widget class="QLabel" name="labelTopList">
- <property name="geometry">
- <rect>
- <x>380</x>
- <y>10</y>
- <width>371</width>
- <height>311</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <pointsize>9</pointsize>
- </font>
- </property>
- <property name="text">
- <string>TopList</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- </widget>
- </widget>
- <widget class="QWidget" name="StartTab">
- <attribute name="title">
- <string>Start</string>
- </attribute>
- <widget class="QListView" name="listViewStartTabAccelerationCategories">
- <property name="geometry">
- <rect>
- <x>20</x>
- <y>10</y>
- <width>251</width>
- <height>301</height>
- </rect>
- </property>
- </widget>
- <widget class="QWidget" name="layoutWidget">
- <property name="geometry">
- <rect>
- <x>320</x>
- <y>10</y>
- <width>161</width>
- <height>301</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QLabel" name="startLabel">
- <property name="text">
- <string>Start:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="lineEditStartTabMin"/>
- </item>
- <item>
- <widget class="QLabel" name="stopLabel">
- <property name="text">
- <string>Stop:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="lineEditStartTabMax"/>
- </item>
- <item>
- <widget class="QLabel" name="unitLabel">
- <property name="text">
- <string>Unit:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="comboBoxStartTabUnits"/>
- </item>
- </layout>
- </widget>
- <widget class="QPushButton" name="autoStartButton">
- <property name="geometry">
- <rect>
- <x>520</x>
- <y>120</y>
- <width>201</width>
- <height>71</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>16</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Auto start</string>
- </property>
- </widget>
- <widget class="QPushButton" name="manualStartButton">
- <property name="geometry">
- <rect>
- <x>520</x>
- <y>230</y>
- <width>201</width>
- <height>71</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>16</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Manual start</string>
- </property>
- </widget>
- <widget class="QPushButton" name="calibrateButton">
- <property name="geometry">
- <rect>
- <x>520</x>
- <y>20</y>
- <width>201</width>
- <height>61</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>16</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Calibrate</string>
- </property>
- </widget>
- </widget>
- <widget class="QWidget" name="settingsTab">
- <attribute name="title">
- <string>Settings</string>
- </attribute>
- <widget class="QLabel" name="userNameLabel">
- <property name="geometry">
- <rect>
- <x>20</x>
- <y>30</y>
- <width>531</width>
- <height>71</height>
- </rect>
- </property>
- <property name="text">
- <string>User:</string>
- </property>
- </widget>
- <widget class="QPushButton" name="setUserPushButton">
- <property name="geometry">
- <rect>
- <x>20</x>
- <y>140</y>
- <width>201</width>
- <height>71</height>
- </rect>
- </property>
- <property name="text">
- <string>Set User</string>
- </property>
- </widget>
- </widget>
- <widget class="QWidget" name="tabMeasureResult">
- <attribute name="title">
- <string>Measure</string>
- </attribute>
- <widget class="QPushButton" name="pushButtonMeasureTabAbort">
- <property name="geometry">
- <rect>
- <x>20</x>
- <y>230</y>
- <width>160</width>
- <height>71</height>
- </rect>
- </property>
- <property name="text">
- <string>Abort</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelMeasureTabHeader">
- <property name="geometry">
- <rect>
- <x>20</x>
- <y>10</y>
- <width>261</width>
- <height>41</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Accelerate to 40 km/h</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelMeasureTabResultHeader">
- <property name="geometry">
- <rect>
- <x>470</x>
- <y>10</y>
- <width>101</width>
- <height>41</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Results:</string>
- </property>
- </widget>
- <widget class="QPushButton" name="pushButtonSendResult">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="geometry">
- <rect>
- <x>470</x>
- <y>230</y>
- <width>160</width>
- <height>71</height>
- </rect>
- </property>
- <property name="text">
- <string>Send result</string>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- </widget>
- <widget class="QLabel" name="labelMeasureTabTimeHeader">
- <property name="geometry">
- <rect>
- <x>20</x>
- <y>70</y>
- <width>60</width>
- <height>41</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>14</pointsize>
- </font>
- </property>
- <property name="text">
- <string>Time:</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelMeasureTabTime">
- <property name="geometry">
- <rect>
- <x>129</x>
- <y>60</y>
- <width>71</width>
- <height>61</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>24</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>0</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelMeasureTabSpeedHeader">
- <property name="geometry">
- <rect>
- <x>20</x>
- <y>160</y>
- <width>81</width>
- <height>41</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>14</pointsize>
- </font>
- </property>
- <property name="text">
- <string>Speed:</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelMeasureTabSpeed">
- <property name="geometry">
- <rect>
- <x>129</x>
- <y>160</y>
- <width>51</width>
- <height>41</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>24</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>0</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelMeasureTabResultHeader_2">
- <property name="geometry">
- <rect>
- <x>470</x>
- <y>60</y>
- <width>71</width>
- <height>61</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>14</pointsize>
- </font>
- </property>
- <property name="text">
- <string>Time:</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelMeasureTabResult">
- <property name="geometry">
- <rect>
- <x>570</x>
- <y>60</y>
- <width>61</width>
- <height>61</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>24</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>0</string>
- </property>
- </widget>
- <widget class="QPushButton" name="pushButtonShowResultDialog">
- <property name="geometry">
- <rect>
- <x>470</x>
- <y>140</y>
- <width>161</width>
- <height>71</height>
- </rect>
- </property>
- <property name="text">
- <string>Show diagram</string>
- </property>
- </widget>
- </widget>
- <widget class="QWidget" name="tab">
- <attribute name="title">
- <string>Route</string>
- </attribute>
- <widget class="QCheckBox" name="gpsOnCheckBox">
- <property name="geometry">
- <rect>
- <x>20</x>
- <y>20</y>
- <width>191</width>
- <height>41</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>16</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>GPS on</string>
- </property>
- <property name="iconSize">
- <size>
- <width>16</width>
- <height>16</height>
- </size>
- </property>
- </widget>
- <widget class="QPushButton" name="startRecPushButton">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>80</y>
- <width>201</width>
- <height>61</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>16</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Start recording</string>
- </property>
- </widget>
- <widget class="QPushButton" name="drawRoutePushButton">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>160</y>
- <width>201</width>
- <height>61</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>16</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Draw route</string>
- </property>
- </widget>
- <widget class="QWidget" name="layoutWidget">
- <property name="geometry">
- <rect>
- <x>310</x>
- <y>16</y>
- <width>461</width>
- <height>291</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="labelRouteTabGPSStatus">
- <property name="text">
- <string>GPS Status</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelRouteTabGPSUpdateTime">
- <property name="text">
- <string>GPS Update time</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelRouteTabGPSTime">
- <property name="text">
- <string>GPS Time</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelRouteTabLatitude">
- <property name="text">
- <string>Latitude</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelRouteTabLongitude">
- <property name="text">
- <string>Longitude</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelRouteTabSpeed">
- <property name="text">
- <string>Speed</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelRouteTabAcceleration">
- <property name="text">
- <string>Acceleration</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelRouteTabRecStatus">
- <property name="text">
- <string>Rec status</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QPushButton" name="sendRoutePushButton">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>240</y>
- <width>201</width>
- <height>61</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <family>Bitstream Charter</family>
- <pointsize>16</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Send route</string>
- </property>
- </widget>
- </widget>
- </widget>
- <widget class="QPushButton" name="registratePushButton">
- <property name="geometry">
- <rect>
- <x>520</x>
- <y>370</y>
- <width>231</width>
- <height>41</height>
- </rect>
- </property>
- <property name="text">
- <string>Registrate</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelInfoToUser">
- <property name="geometry">
- <rect>
- <x>20</x>
- <y>370</y>
- <width>461</width>
- <height>41</height>
- </rect>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </widget>
- <widget class="QMenuBar" name="menuBar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>25</height>
- </rect>
- </property>
- </widget>
- <widget class="QToolBar" name="mainToolBar">
- <attribute name="toolBarArea">
- <enum>TopToolBarArea</enum>
- </attribute>
- <attribute name="toolBarBreak">
- <bool>false</bool>
- </attribute>
- </widget>
- <widget class="QStatusBar" name="statusBar"/>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- * Categorylist
- *
- * @author Olavi Pulkkinen <olavi.pulkkinena@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include <QDebug>
-#include "categorylist.h"
-
-/**
- *Constructor of this class.
- */
-CategoryList::CategoryList()
-{
-
-}
-
-/**
- *Destructor of this class. Should be used to release all allocated resources.
- */
-CategoryList::~CategoryList()
-{
-}
-
-/**
- *This is return function.
- *@return QStringList categoryList
- */
-QStringList CategoryList::getCategoryList()
-{
- qDebug() << "_getCategoryList" ;
- return categoryList;
-}
-
-/**
- *Append an item in the end of the categorylist.
- *@param Item.
- */
-void CategoryList::appendCategoryList(QString item)
-{
- categoryList.append(item);
-}
-
-/**
- *Input an item into the categorylist.
- *@param Index.
- *@param Item to be appended.
- */
-void CategoryList::fillCategoryList(int index, QString item)
-{
- categoryList.insert(index, item);
-}
-
-/**
- *Show an item of the categorylist.
- *@param Index.
- */
-QString CategoryList::itemOfCategoryList(int index)
-{
- return categoryList.at(index);
-}
-
-/**
- *Clear categorylist.
- */
-void CategoryList::clearCategoryList()
-{
- categoryList.clear();
-}
-
-/**
- *Read size of categorylist.
- */
-int CategoryList::sizeOfCategoryList()
-{
- return categoryList.size();
-}
-
-/**
- *Append an item in the end of the categoryelementable.
- *@param Index.
- *@param Description of category.
- *@param Unit.
- *@param Category.
- */
-void CategoryList::appendCats(int ind, QString des, QString uni, QString cat)
-{
- cats[ind].description = des;
- cats[ind].unit = uni;
- cats[ind].category = cat;
-}
-
-/**
- *Clear categs.
- */
-QString CategoryList::desOfCats(int ind)
-{
- return cats[ind].description;
-}
-
-/**
- *Clear cats.
- */
-void CategoryList::clearCats()
-{
- for(int i = 0; i < 10; i++)
- {
- cats[i].description.clear();
- cats[i].unit.clear();
- cats[i].category.clear();
- }
-}
-
-/**
- *This function is used to get items to top list of the category that is chosen from combobox.
- *@param QString category
- *@param int size
- */
-QString CategoryList::getTopList( QString category, int size)
-{
- qDebug() << "_getTopList";
-
- if(!(top10List.isEmpty()))
- {
- return top10List;
- }
- else
- {
- QString emptyStr("");
- qDebug() << "_getTopList: Category not found";
- return emptyStr;
- }
-}
-
+++ /dev/null
-/*
- * Categorylist
- *
- * @author Olavi Pulkkinen <olavi.pulkkinena@fudeco.com>
- * @author Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef CATEGORYLIST_H
-#define CATEGORYLIST_H
-
-#include <QStringList>
-
-class CategoryList : public QObject
-{
-public:
- CategoryList();
- ~CategoryList();
- QString top10List;
-
- QStringList getCategoryList();
- void fillCategoryList(int index, QString item);
- void appendCategoryList(QString item);
- QString itemOfCategoryList(int index);
- QString getTopList( QString category, int size);
- void clearCategoryList();
- int sizeOfCategoryList();
- void appendCats(int ind, QString des, QString uni, QString cat);
- void clearCats();
- QString desOfCats(int i);
-
-private:
- QStringList categoryList; //Stores categories. categoryList is routed to UI.
- typedef struct {
- QString category; //name of category variable
- QString description; //verbal description of category
- QString unit; //km/h, miles/h
- } categoryElements;
- categoryElements cats[10];
-
-};
-
-#endif // CATEGORYLIST_H
--- /dev/null
+#include "creditsdialog.h"
+#include "ui_creditsdialog.h"
+
+#include <QDesktopServices>
+#include <QUrl>
+
+CreditsDialog::CreditsDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::CreditsDialog)
+{
+ ui->setupUi(this);
+ this->setWindowTitle("Credits");
+}
+
+CreditsDialog::~CreditsDialog()
+{
+ delete ui;
+}
+
+void CreditsDialog::changeEvent(QEvent *e)
+{
+ QDialog::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
--- /dev/null
+#ifndef CREDITSDIALOG_H
+#define CREDITSDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+ class CreditsDialog;
+}
+
+class CreditsDialog : public QDialog {
+ Q_OBJECT
+public:
+ CreditsDialog(QWidget *parent = 0);
+ ~CreditsDialog();
+
+protected:
+ void changeEvent(QEvent *e);
+
+private:
+ Ui::CreditsDialog *ui;
+
+private slots:
+};
+
+#endif // CREDITSDIALOG_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CreditsDialog</class>
+ <widget class="QDialog" name="CreditsDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>480</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>20</y>
+ <width>761</width>
+ <height>61</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>40</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>SpeedFreak</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_10">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>90</y>
+ <width>661</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>The following people have contributed to this project:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QWidget" name="layoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>150</y>
+ <width>741</width>
+ <height>201</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Kai Rasilainen</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_6">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Artem Daniliants</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Rikhard Kuutti</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_7">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Toni Jussila</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Jukka Kurttila</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="label_8">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Tiina Kivilinna-Korhola</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Janne Änäkkälä</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLabel" name="label_9">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Olavi Pulkkinen</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
+++ /dev/null
-/*
- * GPS data
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "gpsdata.h"
-
-/**
- *Default constructor of this class.
- */
-GPSData::GPSData(Maemo5Location *maemo5location)
-{
- location = maemo5location;
-
- connect(location,SIGNAL(agnss()),this,SLOT(agnss()));
- connect(location,SIGNAL(awcp()),this,SLOT(awcp()));
- connect(location,SIGNAL(locationUpdated()),this,SLOT(locationUpdated()));
- connect(location,SIGNAL(gps_connected()),this,SLOT(gpsConnected()));
- connect(location,SIGNAL(gps_disconnected()),this,SLOT(gpsDisconnected()));
- connect(location,SIGNAL(gps_error(int)),this,SLOT(gpsError()));
- connect(location,SIGNAL(gpsd_running()),this,SLOT(gpsdRunning()));
- connect(location,SIGNAL(gpsd_stopped()),this,SLOT(gpsdStopped()));
-
- gpsTimer = new QTimer();
- gpsTimeMS = 0;
- connect(gpsTimer, SIGNAL(timeout()),this, SLOT(gpsTimerTimeout()));
-
- resetAll();
-}
-
-/**
- *Destructor of this class. Deletes all dynamic objects and sets them to NULL.
- */
-GPSData::~GPSData()
-{
- delete location;
- location = NULL;
-}
-
-void GPSData::resetAll()
-{
- satellitesInUse = 0;
- satellitesInView = 0;
- signalStrength = 0;
- latitude = 0;
- longitude = 0;
- time = 0;
- ept = 0;
- eph = 0;
- altitude = 0;
- epv = 0;
- track = 0;
- epd = 0;
- speed = 0;
- eps = 0;
- climb = 0;
- epc = 0;
-
- recordingStatus = false;
- roundCounter = 0;
-}
-
-/**
- *This slot function is called when GPS update location.
- */
-void GPSData::agnss()
-{
- //satellitesInUse = QString::number(location->getSatellitesInUse()); //Returns number of satellites in use.
- //satellitesInView = QString::number(location->getSatellitesInView());//Returns number of satellites in view.
- //signalStrength = QString::number(location->getSignalStrength()); //Returns average signal strength of satellites which are in use.
- //gpsOnline = QString::number(location->getGpsOnline()); //Returns gsp online
- //ept = QString::number(location->getEpt()); //Returns time accuracy in seconds.
- //eph = QString::number(location->getEph()); //Returns horizontal position accuracy in cm.
- //track = QString::number(location->getTrack()); //Returns direction of motion in degrees(0-359).
- //epd = QString::number(location->getEpd()); //Returns track accuracy in degrees.
- //climb = QString::number(location->getClimb()); //Returns current rate of climb in m/s.
- //epc = QString::number(location->getEpc()); //Returns climb accuracy in m/s.
- //location->distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f);
- //time = location->getTime();//Returns timestamp of the update in seconds.
-
- //If route recording true
- if ( recordingStatus == true )
- {
- latitude = location->getLatitude(); //Returns latitude.
- longitude = location->getLongitude(); //Returns longitude.
- altitude = location->getAltitude(); //Returns fix altitude in meters.
- epv = location->getEpv(); //Returns altitude accuracy in meters.
- speed = location->getSpeed(); //Returns current speed in km/h.
- eps = location->getEps(); //Returns speed accuracy in km/h.
-
- gpsTimer->start(1);
-
- //If first round
- if (roundCounter == 0)
- {
- saveRoute();
- }
-
- else
- {
- latitudeNow.sprintf("%.4f", latitude); //Latitude now to string
- longitudeNow.sprintf("%.4f", longitude);//Longitude now to string
- latitudePrevious.sprintf("%.4f", gpsDataArray[0]); //Previous latitude to string
- longitudePrevious.sprintf("%.4f", gpsDataArray[1]); //Previous longitude to string
-
- //If latitude or longitude change
- if ( latitudeNow != latitudePrevious || longitudeNow != longitudePrevious )
- {
- saveRoute();
- }
- }
- }
-}
-
-/**
- *This slot function is called when gprs update location.
- */
-void GPSData::awcp()
-{
-
-}
-
-/**
- *This slot function is called when .
- */
-void GPSData::locationUpdated()
-{
-
-}
-
-/**
- *This slot function is called when .
- */
-void GPSData::gpsConnected()
-{
-
-}
-
-/**
- *This slot function is called when .
- */
-void GPSData::gpsDisconnected()
-{
-
-}
-
-/**
- *This slot function is called when .
- */
-void GPSData::gpsError()
-{
-
-}
-
-/**
- *This slot function is called when .
- */
-void GPSData::gpsdRunning()
-{
-
-}
-
-/**
- *This slot function is called when .
- */
-void GPSData::gpsdStopped()
-{
-
-}
-
-/**
- *This function start route recording.
- *@param QString time recording start time.
- */
-void GPSData::startRouteRecording(QString time)
-{
- if (recordingStatus == false)
- {
- routeStartTime = time;
- recordingStatus = true;
- roundCounter = 0;
- }
-}
-
-/**
- *This function stop route recording.
- *@param QString time recording stop time.
- */
-void GPSData::stopRouteRecording(QString time)
-{
- if (recordingStatus == true)
- {
- routeStopTime = time;
- recordingStatus = false;
- roundCounter = 0;
- saveRoute();
- }
-}
-
-/**
- *This slot function is called when gps timer timeout(10s).
- */
-void GPSData::gpsTimerTimeout()
-{
- gpsTimeMS++;
-}
-
-/**
- *This function save route to .txt file.
- */
-void GPSData::saveRoute()
-{
- QFile file("route" + routeStartTime + ".txt");
- QTextStream route(&file);
-
- if ( recordingStatus == true )
- {
- //First round.
- if ( roundCounter == 0 )
- {
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
- return;
-
- route << "Start: " << routeStartTime << "\n";
- }
-
- else
- {
- if (!file.open(QIODevice::Append | QIODevice::Text))
- return;
- }
-
- gpsDataArray[0] = latitude;
- gpsDataArray[1] = longitude;
- gpsDataArray[2] = altitude;
- gpsDataArray[3] = speed;
- roundCounter ++;
-
- route << " la: " << latitude
- << " \t lo: " << longitude
- << " \t al: " << altitude
- << " \t epv: " << epv
- << " \t sp: " << speed
- << " \t eps: " << eps
- << " \t ms: " << gpsTimeMS
- << "\n";
-
- gpsTimeMS = 0;
- file.close();
- }
-
- //Final round.
- else
- {
- if (!file.open(QIODevice::Append | QIODevice::Text))
- return;
- route << "Stop: " << routeStopTime << "\n";
- file.close();
- }
-}
-
-
-/**
- *@return RoundCounter, the number of gpsDataArray[][] rows.
- */
-int GPSData::getRoundCounter()
-{
- return roundCounter;
-}
+++ /dev/null
-/*
- * GPS data
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef GPSDATA_H
-#define GPSDATA_H
-
-#include <QObject>
-#include <maemo5location.h>
-#include <QFile>
-#include <QTextStream>
-#include <QTimer>
-
-class GPSData : public QObject
-{
- Q_OBJECT
-public:
- GPSData(Maemo5Location *maemo5location);
- ~GPSData();
- void startRouteRecording(QString time);
- void stopRouteRecording(QString time);
- int roundCounter; //testing, move private!!!
- int getRoundCounter();
-
-private:
- Maemo5Location *location;
- void resetAll();
- void saveRoute();
-
- int satellitesInUse; //Number of satellites in use.
- int satellitesInView;//Number of satellites in view.
- int signalStrength; //Average signal strength of satellites which are in use.
- double latitude; //Latitude.
- double longitude; //Longitude.
- double time; //Timestamp of the update in seconds.
- double ept; //Time accuracy in seconds.
- double eph; //Horizontal position accuracy in cm.
- double altitude; //Fix altitude in meters.
- double epv; //Altitude accuracy in meters.
- double track; //Direction of motion in degrees(0-359).
- double epd; //Track accuracy in degrees.
- double speed; //Current speed in km/h.
- double eps; //Speed accuracy in km/h.
- double climb; //Current rate of climb in m/s.
- double epc; //Climb accuracy in m/s.
- QString routeStartTime;
- QString routeStopTime;
- QString latitudeNow;
- QString longitudeNow;
- QString latitudePrevious;
- QString longitudePrevious;
-
- bool recordingStatus;
- //int roundCounter;
- double gpsDataArray[4];
- QTimer *gpsTimer;
- int gpsTimeMS;
-
-private slots:
- void agnss();
- void awcp();
- void locationUpdated();
- void gpsConnected();
- void gpsDisconnected();
- void gpsError();
- void gpsdRunning();
- void gpsdStopped();
- void gpsTimerTimeout();
-
-};
-
-#endif // GPSDATA_H
+++ /dev/null
-#include <QString>
-#include <QMessageBox>
-#include "httpclient.h"
-#include "carmainwindow.h"
-
-
-/**
- *@brief Constructor, connects object to GUI
- *@param Pointer to carmainwindow, which is temporarily used during development
- */
-HttpClient::HttpClient(CarMainWindow *myCarw)
-{
- myMainw = myCarw;
- netManager = new QNetworkAccessManager();
- myXmlwriter = new XmlWriter();
- myXmlreader = new XmlReader();
-}
-
-/**
- *@brief Destructor
- */
-HttpClient::~HttpClient()
-{
-
-}
-
-/**
- *@brief Sends registration information to the server in xml format.
- *Reads user name, password and emaol address from resuldialogs internal variables.
- */
-void HttpClient::requestRegistration()
-{
- qDebug() << "_requestRegistration" ;
- qDebug() << myMainw->myRegistration->getUserName() << "+" << myMainw->myRegistration->getPassword() << "+" << myMainw->myRegistration->getEmail();
-
- QBuffer *regbuffer = new QBuffer();
- QUrl qurl("http://api.speedfreak-app.com/api/register");
- QNetworkRequest request(qurl);
- qDebug() << qurl.toString();
- QNetworkReply *currentDownload;
-
- regbuffer->open(QBuffer::ReadWrite);
- myXmlwriter->writeRegistering(regbuffer,
- myMainw->myRegistration->getUserName(),
- myMainw->myRegistration->getPassword(),
- myMainw->myRegistration->getEmail());
- qDebug() << "carmainwindow: regbuffer->data(): " << regbuffer->data();
-
- currentDownload = netManager->post(request, ("xml=" + regbuffer->data()));
- connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRegistration()));
- //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- myMainw->setLabelInfoToUser("Reguesting registration from server");
-
- regbuffer->close();
-}
-
-/**
- *@brief Sends result(s) to the server in xml format.
- *Send authentication information in the header.
- */
-void HttpClient::sendResultXml(QString category)
-{
- qDebug() << "_sendResultXml";
-
- QBuffer *xmlbuffer = new QBuffer();
-
- QUrl qurl("http://api.speedfreak-app.com/api/update/" + category);
- qDebug() << qurl.toString();
- QNetworkRequest request(qurl);
- QNetworkReply *currentDownload;
-
- xmlbuffer->open(QBuffer::ReadWrite);
- myXmlwriter->writeResult(xmlbuffer);
- qDebug() << "carmainwindow: xmlbuffer->data(): " << xmlbuffer->data();
-
- QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
- credentials = "Basic " + credentials.toAscii().toBase64();
- request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
-
- currentDownload = netManager->post(request, ("xml=" + xmlbuffer->data()));
- connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfResult()));
- //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- myMainw->setLabelInfoToUser("Sending result to server");
-
- xmlbuffer->close();
-}
-
-/**
- *@brief Sends route to the server in xml format.
- *Send authentication information in the header.
- *@todo Check destination URL.
- */
-void HttpClient::sendRouteXml()
-{
- qDebug() << "_sendRouteXml";
-
- QString filename = "route.xml";
- QFile file(filename);
- if (!file.open(QFile::ReadOnly)) {
- qDebug() << "_sendRouteXml file.open() fail";
- return;
- }
-
- QUrl qurl("http://api.speedfreak-app.com/api/update/route");
- qDebug() << qurl.toString();
- QNetworkRequest request(qurl);
- QNetworkReply *currentDownload;
-
- QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
- credentials = "Basic " + credentials.toAscii().toBase64();
- request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
-
- currentDownload = netManager->post(request, ("xml=" + file.readAll()));
- connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRoute()));
- //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- myMainw->setLabelInfoToUser("Sending route to server");
-
- file.close();
-}
-
-/**
- *@brief Request the Top10List of certain category from the server.
- *Send authentication information in the header.
- *@param Category of results.
- *@param Limit, the number of results.
- */
-void HttpClient::requestTopList(QString category, QString limit)
-{
- qDebug() << "_requestTopList" ;
-
- QString urlBase = "http://api.speedfreak-app.com/api/results/";
- QUrl qurl(urlBase + category + "/" + limit);
- qDebug() << qurl.toString();
- QNetworkRequest request(qurl);
- QNetworkReply *currentDownload;
-
- QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
- credentials = "Basic " + credentials.toAscii().toBase64();
- request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
-
- currentDownload = netManager->post(request, ("data=" ));
- connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfToplist()));
- //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- myMainw->setLabelInfoToUser("Reguesting top10 list from server");
-}
-
-
-/**
- *@brief Request categories list from the server.
- *Send authentication information in the header.
- */
-void HttpClient::requestCategories()
-{
- qDebug() << "_requestCategories" ;
-
- QUrl qurl("http://api.speedfreak-app.com/api/categories/");
- qDebug() << qurl.toString();
- QNetworkRequest request(qurl);
- QNetworkReply *currentDownload;
-
- QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
- credentials = "Basic " + credentials.toAscii().toBase64();
- request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
-
- currentDownload = netManager->post(request, ("data=" ));
- connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfCategories()));
- //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- myMainw->setLabelInfoToUser("Reguesting categories from server");
-}
-
-
-/**
- *@brief Check that username and password exist on the server.
- *Send authentication information in the header.
- */
-void HttpClient::checkLogin()
-{
- qDebug() << "_checkLogin";
-
- QUrl qurl("http://api.speedfreak-app.com/api/login/");
- qDebug() << qurl.toString();
- QNetworkRequest request(qurl);
- QNetworkReply *currentDownload;
-
- QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
- credentials = "Basic " + credentials.toAscii().toBase64();
- request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
-
- currentDownload = netManager->post(request, ("data=" ));
- connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfLogin()));
- //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- myMainw->setLabelInfoToUser("Checking login validity from server");
-}
-
-
-/**
- *@brief React to servers responce after result has been sent.
- */
-void HttpClient::ackOfResult()
-{
- qDebug() << "_ackOfResult";
-
- myMainw->setLabelInfoToUser("");
-
- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
-
- QNetworkReply::NetworkError errorcode;
- errorcode = reply->error();
- if(errorcode != 0) {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to result sending ",reply->errorString());
- }
- else {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to result sending", "Result received " + reply->readAll());
- }
-}
-
-/**
- *@brief React to servers responce after route has been sent.
- */
-void HttpClient::ackOfRoute()
-{
- qDebug() << "_ackOfRoute";
-
- myMainw->setLabelInfoToUser("");
-
- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
-
- QNetworkReply::NetworkError errorcode;
- errorcode = reply->error();
- if(errorcode != 0) {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to route sending ",reply->errorString());
- }
- else {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to route sending", "Route received " + reply->readAll());
- }
-}
-
-/**
- *@brief React to servers responce after registration has been sent.
- *@todo Implement consequencies of reply.
- */
-void HttpClient::ackOfRegistration()
-{
- qDebug() << "_ackOfRegistration";
-
- myMainw->setLabelInfoToUser("");
-
- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
-
- QNetworkReply::NetworkError errorcode;
- errorcode = reply->error();
- if(errorcode != 0) {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to registration",reply->readAll());
- }
- else {
- qDebug() << "errorcode=0" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to registration", "User registration " + reply->readAll());
- }
-}
-
-
-/**
- *@brief React to servers responce after request for categories has been sent.
- */
-void HttpClient::ackOfCategories()
-{
- qDebug() << "_ackOfCategories";
-
- myMainw->setLabelInfoToUser("");
-
- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
- myXmlreader->xmlReadCategories(reply);
-
- QNetworkReply::NetworkError errorcode;
- errorcode = reply->error();
- if(errorcode != 0) {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to requesting categories",reply->errorString());
- }
- else {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to requesting categories ", "OK");
- }
-}
-
-
-/**
- *@brief React to servers responce after request of TopList in certain category has been sent.
- */
-void HttpClient::ackOfLogin()
-{
- qDebug() << "_ackOffLogin";
-
- myMainw->setLabelInfoToUser("");
-
- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
-
- QNetworkReply::NetworkError errorcode;
- errorcode = reply->error();
- if(errorcode != 0) {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server does not recognize your username. Please registrate.",reply->errorString());
- }
- else {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to login", "User login " + reply->readAll());
- }
-}
-
-
-/**
- *@brief Reports errors, when server has sent error signal.
- */
-void HttpClient::errorFromServer(QNetworkReply::NetworkError errorcode)
-{
- qDebug() << "_errorFromServer";
-
- myMainw->setLabelInfoToUser("");
-
- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
-
- if(errorcode != 0) {
- qDebug() << "errorcode:" << errorcode;
- //Note that errors are already reported on other each functions for server communication
- //QMessageBox::about(myMainw, "Server reported an error", reply->errorString());
- }
- else {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- qDebug() << reply->readAll();
- }
-}
-
-
-/**
- *@brief React to servers responce after request of TopList in certain category has been sent.
- */
-void HttpClient::ackOfToplist()
-{
- qDebug() << "_ackOfToplist";
-
- myMainw->setLabelInfoToUser("");
-
- QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
- myXmlreader->xmlReadTop10Results(reply);
-
- QNetworkReply::NetworkError errorcode;
- errorcode = reply->error();
- if(errorcode != 0) {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to requesting top 10 list",reply->errorString());
- }
- else {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to requesting top 10 list", "OK " + reply->readAll());
- }
-}
-
+++ /dev/null
-/*
- * Http client Connects application to server.
- *
- * @author Tiina Kivilinna-Korhola
- * @copyright (c) 2010 Speed Freak team
- * license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef HTTPCLIENT_H
-#define HTTPCLIENT_H
-
-#include <QNetworkAccessManager>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include "xmlwriter.h"
-#include "xmlreader.h"
-class CarMainWindow;
-
-
-
-class HttpClient : public QObject {
- Q_OBJECT
-public:
- HttpClient(CarMainWindow *myCarw);
- ~HttpClient();
- XmlWriter *myXmlwriter;
- XmlReader *myXmlreader;
-
-private:
- CarMainWindow *myMainw;
- QNetworkAccessManager *netManager;
-
-public slots:
- void requestRegistration();
- void checkLogin();
- void sendResultXml(QString category);
- void sendRouteXml();
- void requestTopList(QString category, QString limit);
- void requestCategories();
- void ackOfResult();
- void ackOfRoute();
- void ackOfRegistration();
- void ackOfCategories();
- void ackOfToplist();
- void ackOfLogin();
- void errorFromServer(QNetworkReply::NetworkError);
-
-};
-
-#endif // HTTPCLIENT_H
+++ /dev/null
-/*
- * Loginwindow class to maintain username for user
- *
- * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
- * @author
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "loginwindow.h"
-#include "ui_loginwindow.h"
-
-LoginWindow::LoginWindow(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::LoginWindow)
-{
- ui->setupUi(this);
- this->setWindowTitle("Setting username");
-}
-
-LoginWindow::~LoginWindow()
-{
- delete ui;
-}
-
-void LoginWindow::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-void LoginWindow::on_cancelPushButton_clicked()
-{
- close();
-}
-
-void setUser(QString uN, QString pW);
-
-void LoginWindow::on_loginPushButton_clicked()
-{
- this->username = ui->userNameLineEdit->text();
- this->password = ui->passwordLineEdit->text();
-
- emit userNameChanged();
- close();
-}
-
-void LoginWindow::setUserName(QString username)
-{
- this->username = username;
-}
-
-void LoginWindow::setPassword(QString password)
-{
- this->password = password;
-}
-
-QString LoginWindow::getUserName()
-{
- return this->username;
-}
-
-QString LoginWindow::getPassword()
-{
- return this->password;
-}
-
-
-
-
-
+++ /dev/null
-/*
- * LoginWindow class
- *
- * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef LOGINWINDOW_H
-#define LOGINWINDOW_H
-
-#include <QDialog>
-
-namespace Ui {
- class LoginWindow;
-}
-
-class LoginWindow : public QDialog {
- Q_OBJECT
-public:
- LoginWindow(QWidget *parent = 0);
- ~LoginWindow();
- void setUserName(QString username);
- void setPassword(QString password);
- QString getUserName();
- QString getPassword();
-
-protected:
- void changeEvent(QEvent *e);
-
-private:
- Ui::LoginWindow *ui;
- QString username;
- QString password;
-
-private slots:
- void on_loginPushButton_clicked();
- void on_cancelPushButton_clicked();
-signals:
- void userNameChanged();
-};
-
-#endif // LOGINWINDOW_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>LoginWindow</class>
- <widget class="QDialog" name="LoginWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>600</width>
- <height>400</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>LoginWindow</string>
- </property>
- <widget class="QPushButton" name="loginPushButton">
- <property name="geometry">
- <rect>
- <x>170</x>
- <y>230</y>
- <width>91</width>
- <height>41</height>
- </rect>
- </property>
- <property name="text">
- <string>Set</string>
- </property>
- </widget>
- <widget class="QPushButton" name="cancelPushButton">
- <property name="geometry">
- <rect>
- <x>330</x>
- <y>230</y>
- <width>91</width>
- <height>41</height>
- </rect>
- </property>
- <property name="text">
- <string>Cancel</string>
- </property>
- </widget>
- <widget class="QLineEdit" name="userNameLineEdit">
- <property name="geometry">
- <rect>
- <x>220</x>
- <y>60</y>
- <width>311</width>
- <height>51</height>
- </rect>
- </property>
- <property name="maxLength">
- <number>12</number>
- </property>
- </widget>
- <widget class="QLabel" name="passwordLabel">
- <property name="geometry">
- <rect>
- <x>70</x>
- <y>140</y>
- <width>141</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>Password:</string>
- </property>
- </widget>
- <widget class="QLabel" name="userNameLabel">
- <property name="geometry">
- <rect>
- <x>70</x>
- <y>70</y>
- <width>141</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>Username:</string>
- </property>
- </widget>
- <widget class="QLineEdit" name="passwordLineEdit">
- <property name="geometry">
- <rect>
- <x>220</x>
- <y>130</y>
- <width>311</width>
- <height>51</height>
- </rect>
- </property>
- <property name="maxLength">
- <number>255</number>
- </property>
- <property name="echoMode">
- <enum>QLineEdit::Password</enum>
- </property>
- </widget>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- * Maemo5Location
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-//#ifdef Q_WS_MAEMO_5
-#include "maemo5locationprivate.h"
-#include "maemo5location.h"
-
-/**
- *Default constructor of this class.
- *@param QObject pointer to parent object. By default the value is NULL.
- */
-Maemo5Location::Maemo5Location(QObject* parent):QObject(parent)
-{
- ptr = new Maemo5LocationPrivate(this);
-
- connect(ptr, SIGNAL(agnss()), this, SIGNAL(agnss()));
- connect(ptr, SIGNAL(awcp()), this, SIGNAL(awcp()));
- connect(ptr, SIGNAL(locationUpdated()), this, SIGNAL(locationUpdated()));
- connect(ptr, SIGNAL(gps_connected()), this, SIGNAL(gps_connected()));
- connect(ptr, SIGNAL(gps_disconnected()), this, SIGNAL(gps_disconnected()));
- connect(ptr, SIGNAL(gps_error(int)), this, SIGNAL(gps_error(int)));
- connect(ptr, SIGNAL(gpsd_running()), this, SIGNAL(gpsd_running()));
- connect(ptr, SIGNAL(gpsd_stopped()), this, SIGNAL(gpsd_stopped()));
-}
-
-/**
- *Destructor of this class. Should be used to release all allocated resources.
- */
-Maemo5Location::~Maemo5Location()
-{
- delete ptr;
-}
-
-/**
- *Start polling gps.
- */
-void Maemo5Location::startPollingGPS()
-{
- ptr->get_agnss();
-}
-
-/**
- *Stop polling gps.
- */
-void Maemo5Location::stopPollingGPS()
-{
- ptr->stop();
-}
-
-/**
- *Returns number of satellites in use.
- */
-int Maemo5Location::getSatellitesInUse()
-{
- return ptr->get_satellites_in_use();
-}
-
-/**
- *Returns number of satellites in view.
- */
-int Maemo5Location::getSatellitesInView()
-{
- return ptr->get_satellites_in_view();
-}
-
-/**
- *Returns average signal strength of satellites which are in use.
- */
-int Maemo5Location::getSignalStrength()
-{
- return ptr->get_signal_strength();
-}
-
-/**
- *Returns gps online.
- */
-bool Maemo5Location::getGpsOnline()
-{
- return ptr->get_gps_online();
-}
-
-/**
- *Returns latitude.
- */
-double Maemo5Location::getLatitude()
-{
- return ptr->get_lat();
-}
-
-/**
- *Returns longitude.
- */
-double Maemo5Location::getLongitude()
-{
- return ptr->get_lon();
-}
-
-/**
- *Returns timestamp of the update in seconds.
- */
-double Maemo5Location::getTime()
-{
- return ptr->get_time();
-}
-
-/**
- *Returns time accuracy in seconds.
- */
-double Maemo5Location::getEpt()
-{
- return ptr->get_ept();
-}
-
-/**
- *Returns horizontal position accuracy in cm.
- */
-double Maemo5Location::getEph()
-{
- return ptr->get_eph();
-}
-
-/**
- *Returns fix altitude in meters.
- */
-double Maemo5Location::getAltitude()
-{
- return ptr->get_altitude();
-}
-
-/**
- *Returns altitude accuracy in meters.
- */
-double Maemo5Location::getEpv()
-{
- return ptr->get_epv();
-}
-
-/**
- *Returns direction of motion in degrees(0-359).
- */
-double Maemo5Location::getTrack()
-{
- return ptr->get_track();
-}
-
-/**
- *Returns track accuracy in degrees.
- */
-double Maemo5Location::getEpd()
-{
- return ptr->get_epd();
-}
-
-/**
- *Returns current speed in km/h.
- */
-double Maemo5Location::getSpeed()
-{
- return ptr->get_speed();
-}
-
-/**
- *Returns speed accuracy in km/h.
- */
-double Maemo5Location::getEps()
-{
- return ptr->get_eps();
-}
-
-/**
- *Returns current rate of climb in m/s.
- */
-double Maemo5Location::getClimb()
-{
- return ptr->get_climb();
-}
-
-/**
- *Returns climb accuracy in m/s.
- */
-double Maemo5Location::getEpc()
-{
- return ptr->get_epc();
-}
-
-/**
- *Returns distance between two points in kilometers.
- *@param latitude of first point
- *@param longitude of first point
- *@param latitude of second point
- *@param longitude of second point
- */
-double Maemo5Location::distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f)
-{
- return ptr->distance_between_two_points(latitude_s, longitude_s, latitude_f, longitude_f);
-}
+++ /dev/null
-/*
- * Maemo5Location
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef MAEMO5LOCATION_H
-#define MAEMO5LOCATION_H
-
-#include <QObject>
-
-class Maemo5LocationPrivate;
-
-class Maemo5Location : public QObject
-{
- Q_OBJECT
-public:
- Maemo5Location(QObject* parent = 0);
- ~Maemo5Location();
-
- void startPollingGPS();
- void stopPollingGPS();
- int getSatellitesInUse();
- int getSatellitesInView();
- int getSignalStrength();
- bool getGpsOnline();
- double getLatitude();
- double getLongitude();
- double getTime();
- double getEpt();
- double getEph();
- double getAltitude();
- double getEpv();
- double getTrack();
- double getEpd();
- double getSpeed();
- double getEps();
- double getClimb();
- double getEpc();
- double distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f);
-
-signals:
- void awcp();
- void agnss();
- void locationUpdated();
- void gps_connected();
- void gps_disconnected();
- void gps_error(int);
- void gpsd_running();
- void gpsd_stopped();
-
-private:
- Maemo5LocationPrivate* ptr;
-};
-
-#endif // MAEMO5LOCATION_H
+++ /dev/null
-/*
- * Maemo5LocationPrivate
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "maemo5locationprivate.h"
-
-/**
- *Default constructor of this class.
- *@param Maemo5Location pointer to public interface.
- */
-Maemo5LocationPrivate::Maemo5LocationPrivate(Maemo5Location* location):QObject(location)
-{
- //Initialize variables
- gps_online = false;
- usegps = -1;
- resetAll();
- //Get gps control object
- control = location_gpsd_control_get_default();
- //create gps device
- device = (LocationGPSDevice*) g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
-
- g_signal_connect(device, "changed", G_CALLBACK(gps_data_changed), this);
- g_signal_connect(device, "connected", G_CALLBACK(gps_connected_func), this);
- g_signal_connect(device, "disconnected", G_CALLBACK(gps_disconnected_func), this);
-
- g_signal_connect(control, "error-verbose", G_CALLBACK(gps_error_func), this);
- g_signal_connect(control, "gpsd_running", G_CALLBACK(gpsd_running_func), this);
- g_signal_connect(control, "gpsd_stopped", G_CALLBACK(gpsd_running_func), this);
-
-}
-/**
- *Destructor of this class. Should be used to release all allocated resources.
- */
-Maemo5LocationPrivate::~Maemo5LocationPrivate()
-{
- delete device;
- delete control;
-}
-
-/**
- *This function is used to start to poll with gprs
- */
-void Maemo5LocationPrivate::get_acwp()
-{
- g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
- usegps = 0;
- restart();
-}
-
-/**
- *This function starts to poll via gps interface
- */
-void Maemo5LocationPrivate::get_agnss()
-{
- g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_AGNSS, NULL);
- usegps = 1;
- restart();
-}
-
-/**
- *Stop polling gps
- */
-void Maemo5LocationPrivate::stop()
-{
- location_gpsd_control_stop(control);
-}
-
-/**
- *Stop and restart polling
- */
-void Maemo5LocationPrivate::restart()
-{
- location_gpsd_control_stop(control);
- location_gpsd_control_start(control);
-}
-
-/**
- *This function is called when device managed to connect to the lcoation server.
- *Function emits gps_connected signal.
- *@param Pointer to LocationGPSDevice class
- *@param Pointer to Maemo5LocationPrivate class
- */
-void gps_connected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps)
-{
- emit gps->gps_connected();
-}
-
-/**
- *This function is called when device is disconnected from the location server.
- *Function emits gps_disconnected signal.
- *Also this function resets all arguments of Maemo5LcoationPrivate class.
- *@param Pointer to LocationGPSDevice class
- *@param Pointer to Maemo5LocationPrivate class
- */
-void gps_disconnected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps)
-{
- gps->resetAll();
- emit gps->gps_disconnected();
-}
-
-/**
- *This function is called after the location_gpsd_control_stop has been called.
- *@param Pointer to LocationGPSDControl class
- *@param Pointer to Maemo5LocationPrivate class
- */
-void gpsd_stopped_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps)
-{
- emit gps->gpsd_stopped();
-}
-
-/**
- *This function is called when an error has occurred.
- *@param Pointer to LocationGPSDControl class
- *@param error code
- *@param Pointer to Maemo5LocationPrivate class
- */
-void gps_error_func(LocationGPSDControl *control, gint error, Maemo5LocationPrivate *gps)
-{
-
- switch (error) {
- case LOCATION_ERROR_USER_REJECTED_DIALOG:
- emit gps->gps_error(0);
- g_debug("User didn't enable requested methods");
- break;
- case LOCATION_ERROR_USER_REJECTED_SETTINGS:
- emit gps->gps_error(1);
- g_debug("User changed settings, which disabled location");
- break;
- case LOCATION_ERROR_BT_GPS_NOT_AVAILABLE:
- emit gps->gps_error(2);
- g_debug("Problems with BT GPS");
- break;
- case LOCATION_ERROR_METHOD_NOT_ALLOWED_IN_OFFLINE_MODE:
- emit gps->gps_error(3);
- g_debug("Requested method is not allowed in offline mode");
- break;
- case LOCATION_ERROR_SYSTEM:
- emit gps->gps_error(4);
- g_debug("System error");
- break;
- }
-}
-
-/**
- *This function is called after the location_gpsd_control_start has been called.
- *@param Pointer to LocationGPSDControl class
- *@param Pointer to Maemo5LocationPrivate class
- */
-void gpsd_running_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps)
-{
- emit gps->gpsd_running();
-}
-
-/**
- *Callback function to catch gps signals.
- *@param Pointer to LocationGPSDControl class
- *@param Pointer to Maemo5LocationPrivate class
- */
-void gps_data_changed(LocationGPSDevice *device, Maemo5LocationPrivate *gps)
-{
- //First check that LocationGpsDeviceFix can be found...this data structure contains the location info.
- if(gps->device->fix)
- {
- //Check that there are fields
- if(gps->device->fix->fields)
- {
- //Store values and emit signal
- if(gps->device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET)
- {
- gps->latitude = gps->device->fix->latitude;
- gps->longitude = gps->device->fix->longitude;
- gps->eph = gps->device->fix->eph;
- }
-
-
- gps->satellites_in_use = gps->device->satellites_in_use;
- gps->satellites_in_view = gps->device->satellites_in_view;
-
- if(gps->device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET)
- {
- gps->time = gps->device->fix->time;
- gps->ept = gps->device->fix->ept;
- }
-
- if(gps->device->fix->fields & LOCATION_GPS_DEVICE_ALTITUDE_SET)
- {
- gps->altitude = gps->device->fix->altitude;
- gps->epv = gps->device->fix->epv;
- }
-
- if(gps->device->fix->fields & LOCATION_GPS_DEVICE_TRACK_SET)
- {
- gps->track = gps->device->fix->track;
- gps->epd = gps->device->fix->epd;
- }
-
- if(gps->device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET)
- {
- gps->speed = gps->device->fix->speed;
- gps->eps = gps->device->fix->eps;
- }
-
- if(gps->device->fix->fields & LOCATION_GPS_DEVICE_CLIMB_SET)
- {
- gps->climb = gps->device->fix->climb;
- gps->epc = gps->device->fix->epc;
- }
-
-
- // Calculate average signal strength of satellites in use
- int temp = 0;
- if(gps->satellites_in_use != 0)
- {
- for(int i=0 ; i < gps->satellites_in_use ; i++)
- {
- LocationGPSDeviceSatellite *view = (LocationGPSDeviceSatellite*) g_ptr_array_index (gps->device->satellites, i);
- temp = temp + view->signal_strength;
- }
- gps->signal_strength = (temp / gps->satellites_in_use);
- }
-
-
- if(gps->usegps == 0)
- {
- emit gps->awcp();
- }
- else if(gps->usegps == 1)
- {
- emit gps->agnss();
- }
- else
- {
- emit gps->locationUpdated();
- }
- }
- }
-
-}
-
-/**
- *Resets all arguments of Maemo5LocationPrivate class.
- */
-void Maemo5LocationPrivate::resetAll()
-{
- time = 0;
- latitude = 0;
- longitude = 0;
- satellites_in_view = 0;
- satellites_in_use = 0;
- ept = 0;
- eph = 0;
- altitude = 0;
- epv = 0;
- track = 0;
- epd = 0;
- speed = 0;
- eps = 0;
- climb = 0;
- epc = 0;
-}
-
-/**
- *Returns distance between two points in kilometers.
- *@param latitude of first point
- *@param longitude of first point
- *@param latitude of second point
- *@param longitude of second point
- */
-double Maemo5LocationPrivate::distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f)
-{
- double distance = 0;
- return distance = location_distance_between(latitude_s, longitude_s, latitude_f, longitude_f);
-}
+++ /dev/null
-/*
- * Maemo5LocationPrivate
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef MAEMO5LOCATIONPRIVATE_H
-#define MAEMO5LOCATIONPRIVATE_H
-
-//We have to declare these header file inside extern, since these modules are actually c modules not c++
-extern "C"
-{
-#include <location/location-gps-device.h>
-#include <location/location-gpsd-control.h>
-#include <location/location-distance-utils.h>
-}
-
-#include <QObject>
-#include "maemo5location.h"
-
-class Maemo5LocationPrivate : public QObject
-{
- Q_OBJECT
-
-public:
- Maemo5LocationPrivate(Maemo5Location* location);
- ~Maemo5LocationPrivate();
-
- void get_acwp();
- void get_agnss();
-
- friend void gps_data_changed(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
- friend void gps_connected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
- friend void gps_disconnected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
- friend void gps_error_func(LocationGPSDControl *control, gint error, Maemo5LocationPrivate *gps);
- friend void gpsd_running_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps);
- friend void gpsd_stopped_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps);
-
- static void handleStatus( LocationGPSDeviceStatus status );
-
- int get_satellites_in_view() { return satellites_in_view; }
- int get_satellites_in_use() { return satellites_in_use; }
- int get_signal_strength() { return signal_strength; }
- gboolean get_gps_online() { return gps_online; }
- double get_lat() { return latitude; }
- double get_lon() { return longitude; }
- double get_time() { return time; }
- double get_ept() { return ept; }
- double get_eph() { return eph; }
- double get_altitude() { return altitude; }
- double get_epv() { return epv; }
- double get_track() { return track; }
- double get_epd() { return epd; }
- double get_speed() { return speed; }
- double get_eps() { return eps; }
- double get_climb() { return climb; }
- double get_epc() { return epc; }
- double distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f);
- void stop();
-
-signals:
- void awcp();
- void agnss();
- void locationUpdated();
- void gps_connected();
- void gps_disconnected();
- void gps_error(int);
- void gpsd_running();
- void gpsd_stopped();
-
-private:
- void resetAll();
- //void stop();
- void restart();
-
- int satellites_in_view;
- int satellites_in_use;
- int signal_strength;
- gboolean gps_online;
- double latitude;
- double longitude;
- double time;
- double ept;
- double eph;
- double altitude;
- double epv;
- double track;
- double epd;
- double speed;
- double eps;
- double climb;
- double epc;
-
- Maemo5Location* d_ptr;
- int usegps;
- LocationGPSDControl *control;
- LocationGPSDevice *device;
-};
-
-void gps_data_changed(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
-void gps_connected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
-void gps_disconnected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
-void gps_error_func(LocationGPSDControl *control, gint error, Maemo5LocationPrivate *gps);
-void gpsd_running_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps);
-void gpsd_stopped_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps);
-
-#endif // MAEMO5LOCATIONPRIVATE_H
-/*
- * CarMainWindow main class
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
#include <QtGui/QApplication>
-#include "carmainwindow.h"
+#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- CarMainWindow w;
+ MainWindow w;
w.show();
return a.exec();
}
--- /dev/null
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QDesktopServices>
+#include <QUrl>
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+
+ creditsDialog = new CreditsDialog;
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::changeEvent(QEvent *e)
+{
+ QMainWindow::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void MainWindow::on_pushButtonWWW_clicked()
+{
+ QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/"));
+}
+
+void MainWindow::on_pushButtonCredits_clicked()
+{
+ creditsDialog->show();
+}
--- /dev/null
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include "creditsdialog.h"
+
+namespace Ui {
+ class MainWindow;
+}
+
+class MainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+ CreditsDialog *creditsDialog;
+
+protected:
+ void changeEvent(QEvent *e);
+
+private:
+ Ui::MainWindow *ui;
+
+private slots:
+ void on_pushButtonCredits_clicked();
+ void on_pushButtonWWW_clicked();
+};
+
+#endif // MAINWINDOW_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>480</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <widget class="QPushButton" name="pushButtonAccelerate">
+ <property name="geometry">
+ <rect>
+ <x>50</x>
+ <y>150</y>
+ <width>130</width>
+ <height>130</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Accelerate</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButtonRoute">
+ <property name="geometry">
+ <rect>
+ <x>190</x>
+ <y>150</y>
+ <width>130</width>
+ <height>130</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Route</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButtonResults">
+ <property name="geometry">
+ <rect>
+ <x>330</x>
+ <y>150</y>
+ <width>130</width>
+ <height>130</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Results</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButtonSettings">
+ <property name="geometry">
+ <rect>
+ <x>470</x>
+ <y>150</y>
+ <width>130</width>
+ <height>130</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Settings</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButtonWWW">
+ <property name="geometry">
+ <rect>
+ <x>610</x>
+ <y>150</y>
+ <width>130</width>
+ <height>130</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>WWW</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButtonCredits">
+ <property name="geometry">
+ <rect>
+ <x>640</x>
+ <y>10</y>
+ <width>151</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Credits</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>25</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
+++ /dev/null
-/*
- * CarMainWindow main class
- *
- * @author Janne Änäkkälä <janne.anakkala@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "measuredialog.h"
-#include "ui_measuredialog.h"
-#include "math.h"
-
-/**
- * Constructor of this class.
- * @param QWidget pointer to parent object. By default the value is NULL.
- */
-MeasureDialog::MeasureDialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::MeasureDialog)
-{
- ui->setupUi(this);
- ui->labelInfo->setText("Accelerate to 100 km/h");
- time = 0;
- speed = 0;
- timer = new QTimer();
-
- accelerometer = new Accelerometer();
-
- measures = new Measures();
- this->initializeMeasures();
-
- timer->setInterval(100);
- timer->start();
- connect(this->timer, SIGNAL(timeout()), this, SLOT(after_timeout()));
-}
-
-/**
- *Destructor of this class. Should be used to release all allocated resources.
- */
-MeasureDialog::~MeasureDialog()
-{
- delete ui;
-}
-
-void MeasureDialog::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-/**
- * This slot function is called when timer gives timeout signal. Checks current speed
- * and stores times in measure class.
- */
-void MeasureDialog::after_timeout()
-{
- QString timeString, speedString;
- time++;
- speed = speed +10;
-
- if (floor(speed) == 10)
- {
- measures->setTime10kmh(time);
- }
-
- else if (floor(speed) == 20)
- {
- measures->setTime20kmh(time);
- }
-
- else if (floor(speed) == 30)
- {
- measures->setTime30kmh(time);
- }
-
- else if (floor(speed) == 40)
- {
- measures->setTime40kmh(time);
- }
-
- else if (floor(speed) == 50)
- {
- measures->setTime50kmh(time);
- }
-
- else if (floor(speed) == 60)
- {
- measures->setTime60kmh(time);
- }
-
- else if (floor(speed) == 70)
- {
- measures->setTime70kmh(time);
- }
-
- else if (floor(speed) == 80)
- {
- measures->setTime80kmh(time);
- }
-
- else if (floor(speed) == 90)
- {
- measures->setTime90kmh(time);
- }
-
- else if (floor(speed) == 100)
- {
- measures->setTime100kmh(time);
- }
-
- else
- {
-
- }
-
- // If speed is over 100 km/h emits speedAchieved() signal and close this dialog.
- if (speed >= 40.0)
- {
- timer->stop();
- time = 0;
- speed = 0;
- emit this->speedAchieved();
- this->close();
-
- }
-
- // Updates speed and time.
- else
- {
- timeString.setNum(time);
- speedString.setNum(speed);
- ui->labelSpeed->setText(speedString);
- ui->labelTime->setText(timeString);
- timer->start();
- }
-
-}
-
-/**
- * This slot function is called when Abort button is clicked.
- */
-void MeasureDialog::on_pushButtonAbort_clicked()
-{
- measures->setTime10kmh(0);
- measures->setTime20kmh(0);
- measures->setTime30kmh(0);
- measures->setTime40kmh(0);
- measures->setTime50kmh(0);
- measures->setTime60kmh(0);
- measures->setTime70kmh(0);
- measures->setTime80kmh(0);
- measures->setTime90kmh(0);
- measures->setTime100kmh(0);
- timer->stop();
- time = 0;
- speed = 0;
- this->close();
-}
-
-/**
- * Initializes measures class's member variables.
- */
-void MeasureDialog::initializeMeasures()
-{
- measures->setTime10kmh(0);
- measures->setTime20kmh(0);
- measures->setTime30kmh(0);
- measures->setTime40kmh(0);
- measures->setTime50kmh(0);
- measures->setTime60kmh(0);
- measures->setTime70kmh(0);
- measures->setTime80kmh(0);
- measures->setTime90kmh(0);
- measures->setTime100kmh(0);
-}
+++ /dev/null
-/*
- * CarMainWindow main class
- *
- * @author Janne Änäkkälä <janne.anakkala@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef MEASUREDIALOG_H
-#define MEASUREDIALOG_H
-
-#include "accelerometer.h"
-#include "measures.h"
-#include <QDialog>
-#include <QTimer>
-
-namespace Ui {
- class MeasureDialog;
-}
-
-class MeasureDialog : public QDialog {
- Q_OBJECT
-public:
- MeasureDialog(QWidget *parent = 0);
- ~MeasureDialog();
- Measures *measures;
- void initializeMeasures();
-protected:
- void changeEvent(QEvent *e);
-
-private:
- Ui::MeasureDialog *ui;
-
- QTimer *timer;
- Accelerometer *accelerometer;
-
- double time;
- double speed;
-
- signals:
- void speedAchieved();
-
-private slots:
- void on_pushButtonAbort_clicked();
- void after_timeout();
-};
-
-#endif // MEASUREDIALOG_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MeasureDialog</class>
- <widget class="QDialog" name="MeasureDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>480</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Dialog</string>
- </property>
- <widget class="QLabel" name="labelInfo">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>40</y>
- <width>361</width>
- <height>51</height>
- </rect>
- </property>
- <property name="text">
- <string>Selected measurement: 0 - 100 km/h</string>
- </property>
- </widget>
- <widget class="QWidget" name="layoutWidget">
- <property name="geometry">
- <rect>
- <x>110</x>
- <y>120</y>
- <width>271</width>
- <height>151</height>
- </rect>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="labelTimeHeader">
- <property name="text">
- <string>Time:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelSpeedHeader">
- <property name="text">
- <string>Speed:</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QLabel" name="labelTime">
- <property name="text">
- <string>0</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelSpeed">
- <property name="text">
- <string>86 km/h</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QPushButton" name="pushButtonAbort">
- <property name="geometry">
- <rect>
- <x>200</x>
- <y>300</y>
- <width>93</width>
- <height>27</height>
- </rect>
- </property>
- <property name="text">
- <string>Abort</string>
- </property>
- </widget>
- </widget>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- * CarMainWindow main class
- *
- * @author Janne Änäkkälä <janne.anakkala@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "measures.h"
-
-Measures::Measures()
-{
-}
-
-/**
- * Initializes measures class's member variables.
- */
-void Measures::initializeMembers()
-{
- this->setTime10kmh(0);
- this->setTime20kmh(0);
- this->setTime30kmh(0);
- this->setTime40kmh(0);
- this->setTime50kmh(0);
- this->setTime60kmh(0);
- this->setTime70kmh(0);
- this->setTime80kmh(0);
- this->setTime90kmh(0);
- this->setTime100kmh(0);
-}
-
-/**
- * Get the value of time10kmh
- * @return time10kmh the time in qreal when speed has been 10 km/h
- */
-qreal Measures::getTime10kmh()
-{
- return time10kmh;
-}
-
-qreal Measures::getTime20kmh()
-{
- return time20kmh;
-}
-
-qreal Measures::getTime30kmh()
-{
- return time30kmh;
-}
-
-qreal Measures::getTime40kmh()
-{
- return time40kmh;
-}
-
-qreal Measures::getTime50kmh()
-{
- return time50kmh;
-}
-
-qreal Measures::getTime60kmh()
-{
- return time60kmh;
-}
-
-qreal Measures::getTime70kmh()
-{
- return time70kmh;
-}
-
-qreal Measures::getTime80kmh()
-{
- return time80kmh;
-}
-
-qreal Measures::getTime90kmh()
-{
- return time90kmh;
-}
-
-qreal Measures::getTime100kmh()
-{
- return time100kmh;
-}
-
-/**
- * Set the given time in to the time10kmh
- * @param pTime is time in qreal
- */
-void Measures::setTime10kmh(qreal pTime)
-{
- time10kmh = pTime;
-}
-
-void Measures::setTime20kmh(qreal pTime)
-{
- time20kmh = pTime;
-}
-
-void Measures::setTime30kmh(qreal pTime)
-{
- time30kmh = pTime;
-}
-
-void Measures::setTime40kmh(qreal pTime)
-{
- time40kmh = pTime;
-}
-
-void Measures::setTime50kmh(qreal pTime)
-{
- time50kmh = pTime;
-}
-
-void Measures::setTime60kmh(qreal pTime)
-{
- time60kmh = pTime;
-}
-
-void Measures::setTime70kmh(qreal pTime)
-{
- time70kmh = pTime;
-}
-
-void Measures::setTime80kmh(qreal pTime)
-{
- time80kmh = pTime;
-}
-
-void Measures::setTime90kmh(qreal pTime)
-{
- time90kmh = pTime;
-}
-
-void Measures::setTime100kmh(qreal pTime)
-{
- time100kmh = pTime;
-}
+++ /dev/null
-/*
- * CarMainWindow main class
- *
- * @author Janne Änäkkälä <janne.anakkala@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef MEASURES_H
-#define MEASURES_H
-
-#include <QObject>
-
-class Measures
-{
-public:
- Measures();
- qreal getTime10kmh();
- qreal getTime20kmh();
- qreal getTime30kmh();
- qreal getTime40kmh();
- qreal getTime50kmh();
- qreal getTime60kmh();
- qreal getTime70kmh();
- qreal getTime80kmh();
- qreal getTime90kmh();
- qreal getTime100kmh();
-
- void setTime10kmh(qreal pTime);
- void setTime20kmh(qreal pTime);
- void setTime30kmh(qreal pTime);
- void setTime40kmh(qreal pTime);
- void setTime50kmh(qreal pTime);
- void setTime60kmh(qreal pTime);
- void setTime70kmh(qreal pTime);
- void setTime80kmh(qreal pTime);
- void setTime90kmh(qreal pTime);
- void setTime100kmh(qreal pTime);
-
- void initializeMembers();
-
-
-private:
- qreal time10kmh;
- qreal time20kmh;
- qreal time30kmh;
- qreal time40kmh;
- qreal time50kmh;
- qreal time60kmh;
- qreal time70kmh;
- qreal time80kmh;
- qreal time90kmh;
- qreal time100kmh;
-};
-
-#endif // MEASURES_H
+++ /dev/null
-/*
- * Class for moving average of acceleration data.
- *
- * @author Kai Rasilainen
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "movingaverage.h"
-#include <QList>
-
-MovingAverage::MovingAverage(int sizeLimit)
-{
- SizeLimit = sizeLimit;
-}
-
-double MovingAverage::Average()
-{
- double sum = 0;
-
- if (queue.count() == 0)
- return 0;
-
- QList<double> temp = queue;
- foreach (double value, temp)
- {
- sum += value;
- }
-
- return sum / queue.count();
-}
-
-void MovingAverage::Resize(int sizeLimit)
-{
- SizeLimit = sizeLimit;
- while (queue.count() > SizeLimit)
- {
- queue.dequeue();
- }
-}
-
-void MovingAverage::Enqueue(double item)
-{
- queue.enqueue(item);
- if (queue.count() > SizeLimit)
- queue.dequeue();
-}
-
-
+++ /dev/null
-/*
- * Class for moving average of acceleration data.
- *
- * @author Kai Rasilainen
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef MOVINGAVERAGE_H
-#define MOVINGAVERAGE_H
-
-#include <QQueue>
-
-class MovingAverage
-{
-
-public:
- MovingAverage(int sizeLimit);
-
- double Average();
- void Resize(int sizeLimit);
- void Enqueue(double item);
-
-private:
- int SizeLimit;
- QQueue<double> queue;
-};
-
-#endif // MOVINGAVERAGE_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xml>
-<xml version="1.0">
-<top10acceleration rank="1" nick="toyota" acceleration="9" unit="m/s2"/>
-<top10acceleration rank="2" nick="toyota2" acceleration="8" unit="m/s2"/>
-<top10acceleration rank="3" nick="012345678912" acceleration="7" unit="m/s2"/>
-<top10acceleration rank="4" nick="toyota4" acceleration="6" unit="m/s2"/>
-<top10acceleration rank="5" nick="toyota5" acceleration="5" unit="m/s2"/>
-<top10acceleration rank="6" nick="toyota6" acceleration="4" unit="m/s2"/>
-<top10acceleration rank="7" nick="toyota7" acceleration="3" unit="m/s2"/>
-<top10acceleration rank="8" nick="toyota8" acceleration="2" unit="m/s2"/>
-<top10acceleration rank="9" nick="toyota9" acceleration="1" unit="m/s2"/>
-<top10acceleration rank="10" nick="toyota10" acceleration="1" unit="m/s2"/>
-<top10speed rank="1" nick="toyota" speed="100" unit="km/h"/>
-<top10speed rank="2" nick="toyota2" speed="80" unit="km/h"/>
-<top10speed rank="3" nick="toyota3" speed="70" unit="km/h"/>
-<top10speed rank="4" nick="toyota4" speed="60" unit="km/h"/>
-<top10speed rank="5" nick="toyota5" speed="50" unit="km/h"/>
-<top10speed rank="6" nick="toyota6" speed="40" unit="km/h"/>
-<top10speed rank="7" nick="toyota7" speed="30" unit="km/h"/>
-<top10speed rank="8" nick="toyota8" speed="20" unit="km/h"/>
-<top10speed rank="9" nick="toyota9" speed="10" unit="km/h"/>
-<top10speed rank="10" nick="toyota10" speed="1" unit="km/h"/>
-<top10gforce rank="1" nick="toyota" gforce="1.00" unit="g"/>
-<top10gforce rank="2" nick="toyota2" gforce="0.80" unit="g"/>
-<top10gforce rank="3" nick="toyota3" gforce="0.70" unit="g"/>
-<top10gforce rank="4" nick="toyota4" gforce="0.60" unit="g"/>
-<top10gforce rank="5" nick="toyota5" gforce="0.50" unit="g"/>
-<top10gforce rank="6" nick="toyota6" gforce="0.40" unit="g"/>
-<top10gforce rank="7" nick="toyota7" gforce="0.30" unit="g"/>
-<top10gforce rank="8" nick="toyota8" gforce="0.20" unit="g"/>
-<top10gforce rank="9" nick="toyota9" gforce="0.10" unit="g"/>
-<top10gforce rank="10" nick="toyota10" gforce="0.09" unit="g"/>
-</xml>
+++ /dev/null
-/*
- * Registration class to registrate username for user
- *
- * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
- * @author
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "registration.h"
-#include "ui_registration.h"
-#include <QMessageBox>
-
-Registration::Registration(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::Registration)
-{
- ui->setupUi(this);
- this->setWindowTitle("Registration for Speed Freak server");
-
- //Let`s not type it again
- ui->newUsernameLineEdit->setText("user123");
- ui->newPasswordLineEdit->setText("salainen");
- ui->eMailLineEdit->setText("user123@emaili.fi");
-}
-
-Registration::~Registration()
-{
- delete ui;
-}
-
-void Registration::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-void Registration::on_registratePushButton_clicked()
-{
- // Send username, password and email to SpeedFreak server
- this->username = ui->newUsernameLineEdit->text();
- this->password = ui->newPasswordLineEdit->text();
- this->email = ui->eMailLineEdit->text();
-
- emit sendregistration();
-
- close();
-}
-
-void Registration::on_cancelPushButton_clicked()
-{
- close();
-}
-
-void Registration::setUserName(QString username)
-{
- this->username = username;
-}
-
-void Registration::setPassword(QString password)
-{
- this->password = password;
-}
-
-void Registration::setEmail(QString email)
-{
- this->email = email;
-}
-
-QString Registration::getUserName()
-{
- return this->username;
-}
-
-QString Registration::getPassword()
-{
- return this->password;
-}
-
-QString Registration::getEmail()
-{
- return this->email;
-}
+++ /dev/null
-/*
- * Registration class
- *
- * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef REGISTRATION_H
-#define REGISTRATION_H
-
-#include <QDialog>
-
-namespace Ui {
- class Registration;
-}
-
-class Registration : public QDialog {
- Q_OBJECT
-public:
- Registration(QWidget *parent = 0);
- ~Registration();
- void setUserName(QString username);
- void setPassword(QString password);
- void setEmail(QString email);
- QString getUserName();
- QString getPassword();
- QString getEmail();
-
-signals:
- void sendregistration();
-
-protected:
- void changeEvent(QEvent *e);
-
-private:
- Ui::Registration *ui;
- QString username;
- QString password;
- QString email;
-
-private slots:
- void on_cancelPushButton_clicked();
- void on_registratePushButton_clicked();
-};
-
-#endif // REGISTRATION_H
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Registration</class>
- <widget class="QDialog" name="Registration">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>600</width>
- <height>400</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Registration</string>
- </property>
- <widget class="QPushButton" name="registratePushButton">
- <property name="geometry">
- <rect>
- <x>120</x>
- <y>270</y>
- <width>121</width>
- <height>41</height>
- </rect>
- </property>
- <property name="text">
- <string>Registrate</string>
- </property>
- </widget>
- <widget class="QPushButton" name="cancelPushButton">
- <property name="geometry">
- <rect>
- <x>300</x>
- <y>270</y>
- <width>121</width>
- <height>41</height>
- </rect>
- </property>
- <property name="text">
- <string>Cancel</string>
- </property>
- </widget>
- <widget class="QLineEdit" name="eMailLineEdit">
- <property name="geometry">
- <rect>
- <x>270</x>
- <y>180</y>
- <width>301</width>
- <height>51</height>
- </rect>
- </property>
- <property name="maxLength">
- <number>255</number>
- </property>
- </widget>
- <widget class="QLabel" name="eMailLabel">
- <property name="geometry">
- <rect>
- <x>40</x>
- <y>190</y>
- <width>201</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>Your Email:</string>
- </property>
- </widget>
- <widget class="QLabel" name="newUserNameLabel">
- <property name="geometry">
- <rect>
- <x>40</x>
- <y>70</y>
- <width>221</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>Your new username:</string>
- </property>
- </widget>
- <widget class="QLineEdit" name="newPasswordLineEdit">
- <property name="geometry">
- <rect>
- <x>270</x>
- <y>120</y>
- <width>301</width>
- <height>51</height>
- </rect>
- </property>
- <property name="maxLength">
- <number>255</number>
- </property>
- <property name="echoMode">
- <enum>QLineEdit::Password</enum>
- </property>
- </widget>
- <widget class="QLineEdit" name="newUsernameLineEdit">
- <property name="geometry">
- <rect>
- <x>270</x>
- <y>60</y>
- <width>301</width>
- <height>51</height>
- </rect>
- </property>
- <property name="maxLength">
- <number>12</number>
- </property>
- </widget>
- <widget class="QLabel" name="newPasswordLabel">
- <property name="geometry">
- <rect>
- <x>40</x>
- <y>130</y>
- <width>221</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>Your new password:</string>
- </property>
- </widget>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- * CarMainWindow main class
- *
- * @author Janne Änäkkälä <janne.anakkala@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "resultdialog.h"
-#include "ui_resultdialog.h"
-#include <QPainter>
-
-const int DIAGRAM_WIDTH = 400;
-const int DIAGRAM_HEIGHT = 300;
-
-const int DIAGRAMGAP100KMH = 30;
-const int DIAGRAMGAP40KMH = 75;
-const int DIAGRAMGAP60KMH = 50;
-const int DIAGRAMGAP50KMH = 60;
-const double DIAGRAMGAP80KMH = 37.5;
-
-const QPoint diagramStemStart(70, 330);
-const QPoint diagramStemEnd(70, 30);
-
-const QPoint diagramHorizontalStart(70, 330);
-const QPoint diagramHorizontalEnd(470, 330);
-
-const int diagramGap = 30;
-
-// Test arrays for changing speeds and times to the points in diagram
-static const int speedArray[11] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
-//static const int timeArray[10] = {1, 2, 3, 4, 5, 6, 7, 8, 10, 12};
-
-// Test point array for the diagram.
-QPoint points[11];
-
-/**
- * Constructor of this class.
- * @param QWidget pointer to parent object. By default the value is NULL.
- */
-ResultDialog::ResultDialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::ResultDialog)
-{
- ui->setupUi(this);
- timeAxelLength = 10;
- speedList << "0" << "10" << "20" << "30" << "40" << "50" << "60" << "70" << "80" << "90" << "100" ;
- timeList << "0" << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" << "9" << "10" << "11"
- << "12" << "13" << "14" << "15" << "16" << "17" << "18" << "19" << "20";
-}
-
-/**
- * Destructor of this class. Should be used to release all allocated resources.
- */
-ResultDialog::~ResultDialog()
-{
- delete ui;
-}
-
-void ResultDialog::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-/**
- * Draws speed diagram to the UI
- * @param QPaintEvent
- */
-void ResultDialog::paintEvent(QPaintEvent *)
-{
- QPainter painter(this);
-
- painter.setRenderHint(QPainter::Antialiasing, true);
- painter.setPen(QPen((Qt::red),2));
- QFont font;
- font.setPixelSize(12);
- painter.setFont(font);
- painter.setBrush(QBrush((Qt::yellow), Qt::SolidPattern));
- painter.drawLine(diagramStemStart, diagramStemEnd);
- painter.drawLine(diagramHorizontalStart, diagramHorizontalEnd);
-
- int currentX = 0;
- int currentY = diagramStemStart.y();
-
- painter.setPen(QPen((Qt::blue),1));
- // Draws diagram's X-axel
- int i = 0;
- while (currentX <= DIAGRAM_WIDTH)
- {
- painter.drawLine(currentX + diagramStemStart.x(), currentY, currentX + diagramStemStart.x(), currentY - 300);
- painter.drawText(currentX + diagramStemStart.x(), currentY + 20, timeList[i]);
- currentX += this->diagramGapHorizontal;
- i++;
- }
-
- currentX = diagramStemStart.x();
- currentY = 0;
-
- i = 0;
- // Draws diagram's Y-axel
- while (currentY >= -(DIAGRAM_HEIGHT))
- {
- painter.drawLine(currentX, diagramStemStart.y() + currentY, currentX+400, diagramStemStart.y() + currentY);
- painter.drawText(currentX - 25, diagramStemStart.y() + currentY, speedList[i]);
- currentY -= this->diagramGapStem;
- i++;
- }
-
- painter.setPen(QPen((Qt::white),2));
-
- // Draws result line to the diagram
- if (this->diagramGapStem == DIAGRAMGAP100KMH)
- {
- painter.drawPolyline(points, 11);
- }
-
- else if (this->diagramGapStem == DIAGRAMGAP80KMH)
- {
- painter.drawPolyline(points, 9);
- }
-
- else if (this->diagramGapStem == DIAGRAMGAP60KMH)
- {
- painter.drawPolyline(points, 7);
- }
-
- else if (this->diagramGapStem == DIAGRAMGAP50KMH)
- {
- painter.drawPolyline(points, 6);
- }
-
- else
- {
- painter.drawPolyline(points, 5);
- }
-}
-
-/**
- * Change the given speed and time to the point for the diagram.
- * @param aSpeed is speed which need to change, aTime is time in seconds which need to change.
- * @return point is calculated from aSpeed and aTime.
- */
-QPoint ResultDialog::changeMeasuresToDiagramPoint(int aSpeed, qreal aTime)
-{
- QPoint point;
-
- int speedAsPixels;
- int timeAsPixels;
-
- // Calculate speed and time to the point which can be drawn to the diagram
- if (this->diagramGapStem == DIAGRAMGAP100KMH)
- {
- speedAsPixels = DIAGRAM_HEIGHT*aSpeed/100;
- timeAsPixels = DIAGRAM_WIDTH*aTime/timeAxelLength;
- }
-
- else if (this->diagramGapStem == DIAGRAMGAP80KMH)
- {
- speedAsPixels = DIAGRAM_HEIGHT*aSpeed/80;
- timeAsPixels = DIAGRAM_WIDTH*aTime/timeAxelLength;
- }
-
- else if (this->diagramGapStem == DIAGRAMGAP60KMH)
- {
- speedAsPixels = DIAGRAM_HEIGHT*aSpeed/60;
- timeAsPixels = DIAGRAM_WIDTH*aTime/timeAxelLength;
- }
-
- else if (this->diagramGapStem == DIAGRAMGAP50KMH)
- {
- speedAsPixels = DIAGRAM_HEIGHT*aSpeed/50;
- timeAsPixels = DIAGRAM_WIDTH*aTime/timeAxelLength;
- }
-
- else
- {
- speedAsPixels = DIAGRAM_HEIGHT*aSpeed/40;
- timeAsPixels = DIAGRAM_WIDTH*aTime/timeAxelLength;
- }
- point.setY(diagramStemStart.y()-speedAsPixels);
- point.setX(diagramStemStart.x()+timeAsPixels);
-
- return point;
-}
-
-/**
- * Saves the given measures to array.
- * @param pMeasures has information about acceleration.
- */
-void ResultDialog::saveMeasuresToArray(Measures *pMeasures)
-{
- timeArray[0] = 0;
- timeArray[1] = pMeasures->getTime10kmh();
- timeArray[2] = pMeasures->getTime20kmh();
- timeArray[3] = pMeasures->getTime30kmh();
- timeArray[4] = pMeasures->getTime40kmh();
- timeArray[5] = pMeasures->getTime50kmh();
- timeArray[6] = pMeasures->getTime60kmh();
- timeArray[7] = pMeasures->getTime70kmh();
- timeArray[8] = pMeasures->getTime80kmh();
- timeArray[9] = pMeasures->getTime90kmh();
- timeArray[10] = pMeasures->getTime100kmh();
-
- setTimeAxelLength();
-
- for (int i = 0; i < 11; i++)
- {
- points[i] = changeMeasuresToDiagramPoint(speedArray[i], timeArray[i]);
- }
-
- setTimesIntoLabels();
- this->repaint();
-
- for (int i = 0; i < 11; i++)
- {
- timeArray[i] = 0;
- }
-}
-
-void ResultDialog::on_pushButtonSend_clicked()
-{
- emit sendresult();
-}
-
-/**
- * Saves the given diagram gap to the member variable.
- * @param pDiagramGapStem has information about the right gap for diagram stem axel.
- */
-void ResultDialog::setDiagramGapStem(double pDiagramGapStem)
-{
- this->diagramGapStem = pDiagramGapStem;
-}
-
-/**
- * Saves the given diagram gap to the member variable.
- * @param pDiagramGapHorizontal has information about the right gap for diagram horizontal axel.
- */
-void ResultDialog::setDiagramGapHorizontal(double pDiagramGapHorizontal)
-{
- this->diagramGapHorizontal = pDiagramGapHorizontal;
-}
-
-/**
- * Sets result times in to the labels and shows only wanted results and hides
- * unwanted.
- */
-void ResultDialog::setTimesIntoLabels()
-{
- QString time, timeInteger;
- timeInteger.setNum(timeArray[4]);
- time = "0 - 40 km/h: ";
- time.append(timeInteger);
- ui->labelResult40kmh->setText(time);
-
- timeInteger.setNum(timeArray[3]);
- time = "0 - 30 km/h: ";
- time.append(timeInteger);
- ui->labelResult30kmh->setText(time);
-
- timeInteger.setNum(timeArray[2]);
- time = "0 - 20 km/h: ";
- time.append(timeInteger);
- ui->labelResult20kmh->setText(time);
-
- timeInteger.setNum(timeArray[1]);
- time = "0 - 10 km/h: ";
- time.append(timeInteger);
- ui->labelResult10kmh->setText(time);
-
- timeInteger.setNum(timeArray[6]);
- time = "0 - 60 km/h: ";
- time.append(timeInteger);
- ui->labelResult60kmh->setText(time);
-
- timeInteger.setNum(timeArray[5]);
- time = "0 - 50 km/h: ";
- time.append(timeInteger);
- ui->labelResult50kmh->setText(time);
-
- timeInteger.setNum(timeArray[7]);
- time = "0 - 70 km/h: ";
- time.append(timeInteger);
- ui->labelResult70kmh->setText(time);
-
- timeInteger.setNum(timeArray[8]);
- time = "0 - 80 km/h: ";
- time.append(timeInteger);
- ui->labelResult80kmh->setText(time);
-
- timeInteger.setNum(timeArray[9]);
- time = "0 - 90 km/h: ";
- time.append(timeInteger);
- ui->labelResult90kmh->setText(time);
-
- timeInteger.setNum(timeArray[10]);
- time = "0 - 100 km/h: ";
- time.append(timeInteger);
- ui->labelResult100kmh->setText(time);
-
- if (this->diagramGapStem == DIAGRAMGAP40KMH)
- {
- ui->labelResult50kmh->hide();
- ui->labelResult60kmh->hide();
- ui->labelResult70kmh->hide();
- ui->labelResult80kmh->hide();
- ui->labelResult90kmh->hide();
- ui->labelResult100kmh->hide();
- }
-
- else if (this->diagramGapStem == DIAGRAMGAP80KMH)
- {
- ui->labelResult50kmh->show();
- ui->labelResult60kmh->show();
- ui->labelResult70kmh->show();
- ui->labelResult80kmh->show();
- ui->labelResult90kmh->hide();
- ui->labelResult100kmh->hide();
- }
-
- else
- {
- ui->labelResult50kmh->show();
- ui->labelResult60kmh->show();
- ui->labelResult70kmh->show();
- ui->labelResult80kmh->show();
- ui->labelResult90kmh->show();
- ui->labelResult100kmh->show();
- }
-}
-
-/**
- * Sets right timeAxelLength value depending the time which
- * has spent to reach target speed.
- */
-void ResultDialog::setTimeAxelLength()
-{
- if (this->diagramGapStem == DIAGRAMGAP40KMH)
- {
- if (timeArray[4] <= 5)
- {
- timeAxelLength = 5;
- }
-
- else if (timeArray[4] <= 10)
- {
- timeAxelLength = 10;
- }
-
- else if (timeArray[4] <= 15)
- {
- timeAxelLength = 15;
- }
-
- else
- {
- timeAxelLength = 20;
- }
- }
-
- else if (this->diagramGapStem == DIAGRAMGAP80KMH)
- {
- if (timeArray[8] <= 5)
- {
- timeAxelLength = 5;
- }
-
- else if (timeArray[8] <= 10)
- {
- timeAxelLength = 10;
- }
-
- else if (timeArray[8] <= 15)
- {
- timeAxelLength = 15;
- }
-
- else
- {
- timeAxelLength = 20;
- }
- }
-
- else
- {
- if (timeArray[10] <= 5)
- {
- timeAxelLength = 5;
- }
-
- else if (timeArray[10] <= 10)
- {
- timeAxelLength = 10;
- }
-
- else if (timeArray[10] <= 15)
- {
- timeAxelLength = 15;
- }
-
- else
- {
- timeAxelLength = 20;
- }
- }
-}
+++ /dev/null
-/*
- * CarMainWindow main class
- *
- * @author Janne Änäkkälä <janne.anakkala@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef RESULTDIALOG_H
-#define RESULTDIALOG_H
-
-#include <QDialog>
-#include "measures.h"
-
-namespace Ui {
- class ResultDialog;
-}
-
-class ResultDialog : public QDialog {
- Q_OBJECT
-public:
- ResultDialog(QWidget *parent = 0);
- ~ResultDialog();
- void saveMeasuresToArray(Measures *pMeasures);
- void setDiagramGapStem(double pDiagramGapStem);
- void setDiagramGapHorizontal(double pDiagramGapHorizontal);
-
-signals:
- void sendresult();
-
-protected:
- void changeEvent(QEvent *e);
- void paintEvent(QPaintEvent *);
-
-private:
- QPoint changeMeasuresToDiagramPoint(int aSpeed, qreal aTime);
- void setTimesIntoLabels();
- void setTimeAxelLength();
-
-private:
- Ui::ResultDialog *ui;
- qreal timeArray[11];
- double diagramGapStem;
- double diagramGapHorizontal;
- QStringList speedList;
- QStringList timeList;
- int timeAxelLength;
-
-private slots:
- void on_pushButtonSend_clicked();
-};
-
-#endif // RESULTDIALOG_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ResultDialog</class>
- <widget class="QDialog" name="ResultDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>480</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Dialog</string>
- </property>
- <widget class="QLabel" name="labelResult10kmh">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>180</y>
- <width>191</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>0 - 10 km/h: 5,6 s</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelResult40kmh">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>120</y>
- <width>191</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>0 - 40 km/h: 9,8 s</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelResult20kmh">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>160</y>
- <width>191</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>0 - 20 km/h: 6,9 s</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelResult30kmh">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>140</y>
- <width>191</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>0 - 30 km/h: 8,6 s</string>
- </property>
- </widget>
- <widget class="QPushButton" name="pushButtonSend">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>260</y>
- <width>101</width>
- <height>27</height>
- </rect>
- </property>
- <property name="text">
- <string>Send results</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelResult80kmh">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>40</y>
- <width>191</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>0 - 80 km/h: 9,8 s</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelResult70kmh">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>60</y>
- <width>191</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>0 - 70 km/h: 8,6 s</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelResult60kmh">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>80</y>
- <width>191</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>0 - 60 km/h: 6,9 s</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelResult50kmh">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>100</y>
- <width>191</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>0 - 50 km/h: 5,6 s</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelResult90kmh">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>20</y>
- <width>191</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>0 - 90 km/h: 8,6 s</string>
- </property>
- </widget>
- <widget class="QLabel" name="labelResult100kmh">
- <property name="geometry">
- <rect>
- <x>550</x>
- <y>0</y>
- <width>191</width>
- <height>31</height>
- </rect>
- </property>
- <property name="text">
- <string>0 - 100 km/h: 9,8 s</string>
- </property>
- </widget>
- </widget>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<results category="acceleration-0-100" unit="seconds" description="Acceleration from 0 to 100 km/h">
- <result position="1" user="test928" date="12/1/2010" value="13" />
- <result position="2" user="test922" date="15/1/2010" value="12" />
- <result position="3" user="test92a" date="11/1/2010" value="11" />
- <result position="4" user="test92s" date="15/2/2010" value="10" />
- <result position="5" user="test92d" date="1/1/2010" value="9" />
- <result position="6" user="test92f" date="31/1/2010" value="8" />
- <result position="7" user="test92f" date="1/1/2010" value="7" />
- <result position="8" user="test92g" date="2/1/2010" value="6" />
- <result position="9" user="test92w" date="3/1/2010" value="5" />
- <result position="10" user="test92a" date="17/1/2010" value="4" />
-</results>
+++ /dev/null
-/*
- * RouteDialog class
- *
- * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "routedialog.h"
-#include "ui_routedialog.h"
-#include <cmath>
-#include <QPainter>
-#include <QList>
-#include <QMessageBox>
-#include <QFile>
-#include <QFileDialog>
-
-/*
- * Vector class.
- * In starting Qt 4.6 there is QVector3D.
- * Later (updating Qt version) this class can be removed.
- */
-class Vector
-{
- qreal x, y, z;
-public:
- Vector() { x=0.; y=0. ; z=0.; };
- Vector( qreal initX, qreal initY, qreal initZ) { x = initX, y = initY; z = initZ; };
- void setX( qreal newX) { x = newX; };
- void setY( qreal newY) { y = newY; };
- void setZ( qreal newZ) { z = newZ; };
- qreal getX() { return x; };
- qreal getY() { return y; };
- qreal getZ() { return z; };
- qreal length() { return sqrt(x*x+y*y+z*z); };
- Vector operator+(Vector v)
- {
- x = x + v.x; y = y + v.y; z = z + v.z;
- return *this;
- };
- Vector operator-(Vector v)
- {
- x = x - v.x; y = y - v.y; z = z - v.z;
- return *this;
- };
- Vector operator/(qreal c)
- {
- x = x/c; y = y/c; z = z/c;
- return *this;
- };
- Vector crossProduct( Vector a, Vector b)
- {
- x = a.y*b.z - a.z*b.y;
- y = a.z*b.x - a.x*b.z;
- z = a.x*b.y - a.y*b.x;
- return *this;
- };
-};
-
-
-class Viewing
-{
- Vector atPoint, fromPoint, up, a1, a2, a3;
- qreal offsx, offsy, offsz;
- qreal dval;
- qreal angle;
-public:
- qreal getOffsx() { return offsx; };
- qreal getOffsy() { return offsy; };
- qreal getOffsz() { return offsz; };
- qreal getDval() { return dval; };
- void setAngle( qreal newA) { angle = newA; };
- void setUp( qreal newUpX, qreal newUpY, qreal newUpZ)
- {
- up.setX(newUpX); up.setY(newUpY); up.setZ(newUpZ);
- };
- void setAtPoint( qreal newX, qreal newY, qreal newZ)
- {
- atPoint.setX(newX); atPoint.setY(newY); atPoint.setZ(newZ);
- };
- void setFromPoint(qreal newX, qreal newY, qreal newZ)
- {
- fromPoint.setX(newX); fromPoint.setY(newY); fromPoint.setZ(newZ);
- }
- void setEye()
- {
- double amarkmag, tempmag;
- Vector temp, dist;
-
- dval = cos(angle/2.0)/sin(angle/2.0);
- dist = atPoint-fromPoint;
- amarkmag = dist.length();
- a3 = dist/amarkmag;
-
- temp.crossProduct( dist, up);
- tempmag = temp.length();
- a1 = temp/tempmag;
-
- temp.crossProduct( a1, a3);
- tempmag = temp.length();
- a2 = temp/tempmag;
-
- offsx = -a1.getX()*fromPoint.getX() - a1.getY()*fromPoint.getY() - a1.getZ()*fromPoint.getZ();
- offsy = -a2.getX()*fromPoint.getX() - a2.getY()*fromPoint.getY() - a2.getZ()*fromPoint.getZ();
- offsz = -a3.getX()*fromPoint.getX() - a3.getY()*fromPoint.getY() - a3.getZ()*fromPoint.getZ();
- //QString jono2 = QString("offsx %1 offsy %2 offsz %3").arg(offsx).arg(offsy).arg(offsz);
- //QMessageBox::about(0,"offs x y z", jono2);
- } ;
- Vector getAtPoint() { return atPoint; };
- Vector getFromPoint() { return fromPoint; };
- Vector getA1() { return a1; };
- Vector getA2() { return a2; };
- Vector getA3() { return a3; };
- Viewing () {};
-};
-
-qreal xmax, xmin, ymin, ymax; // Limits in world coordinates
-
-QList<Vector> vertexList; // Vertecies of route
-
-qreal objxmin, objxmax, objymin, objymax, objzmin, objzmax; // data ranges
-
-#define maxof(val1,val2) ((val1>val2)?val1:val2)
-#define toradians( degrees) (degrees*0.017453293)
-
-#define WIDTH 1.8 // For 3d viewing only
-qreal a, b,c,d; // Used for 3d viewing to calculate screen coordinates
-
-Viewing view3d; // Viewing settings for 3d
-
-// Function prototypes
-void dataMinMax( void);
-void setAtPoint( Viewing *v);
-void setFromPoint( Viewing *v);
-void transformseg( Viewing *v, Vector *v1, Vector *v2, int *xscreen1, int *yscreen1, int *xscreen2, int *yscreen2 );
-
-#define R 6378.140 // The radius of the earth by kilometers
-/*
- * count distance of two points (defined by longitude & latitude)
- * on the surface of the earth.
- */
-qreal countDistance(Vector *p1, Vector *p2)
-{
- qreal dLon, dLat; // delta of longitude & latitude
- qreal a, c;
-
- dLon = p2->getX() - p1->getX(); // longitude difference
- dLat = p2->getY() - p1->getY(); // latitude difference
- if (dLon <0) dLon = -dLon;
- if (dLat <0) dLat = -dLat;
-
- dLon = dLon*3.14/180;
- dLat = dLat*3.14/180;
- a = (sin(dLat/2.))*(sin(dLat/2.)) +
- (cos(p1->getY())*3.14/180)*(cos(p2->getY())*3.14/180)*(sin(dLon/2.))*(sin(dLon/2.));
- c = 2.*atan(sqrt(a)/sqrt(1-a)); // c is angle between points p1 & p2 with circel by radius 1.
-
- return R*c; // Return distance in kilometers
-}
-
-RouteDialog::RouteDialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::RouteDialog)
-{
- ui->setupUi(this);
- left = 5; top = 5; right = 395; bottom = 195; // Limits in screen coordinates
-}
-
-RouteDialog::~RouteDialog()
-{
- delete ui;
-}
-
-void RouteDialog::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-
-/**
- * Draws route to the route dialog.
- * Type 0 is 2d viewing and type 1 is for 3d viewing
- * @param QPaintEvent
- */
-/* */
-void RouteDialog::paintEvent(QPaintEvent *)
-{
- int type = 0; // 0 for 2d, 1 for 3d
- int startx, starty; // Starting point of the route
- int i, maxi;
- qreal x1, y1, x2, y2;
- int x1Screen, y1Screen, x2Screen, y2Screen;
- Vector v1, v2;
- QPainter painter(this);
-
- painter.setRenderHint(QPainter::Antialiasing, true);
- painter.setPen(QPen((Qt::black),2));
- painter.setBrush(QBrush((Qt::yellow), Qt::SolidPattern));
-
- // Draw route window frame
- /*painter.drawLine(left,top,right,top);
- painter.drawLine(right,top,right,bottom);
- painter.drawLine(left,top,left,bottom);
- painter.drawLine(left,bottom,right,bottom);
- */
- maxi = vertexList.size();
-
- for (i=0; i<maxi-1; i++)
- {
- v1 = vertexList.at(i);
- v2 = vertexList.at(i+1);
-
- if (type == 0)
- { // 2d
- x1 = v1.getX(); y1 = v1.getY();
- x2 = v2.getX(); y2 = v2.getY();
- //QString jono = QString("x: %1 y: %2").arg(x1).arg(y1);
- //QMessageBox::about(0,"Tark",jono);
-
- x1Screen = left + (x1-xmin)/(xmax-xmin)*(right-left);
- y1Screen = top + (ymax-y1)/(ymax-ymin)*(bottom-top);
- x2Screen = left + (x2-xmin)/(xmax-xmin)*(right-left);
- y2Screen = top + (ymax-y2)/(ymax-ymin)*(bottom-top);
- }
- else if (type == 1)
- { // 3d
- transformseg( &view3d, &v1,&v2, &x1Screen, &y1Screen, &x2Screen, &y2Screen);
- }
-
- // Show with circle if starting point
- if (i==0)
- {
- // Starting point
- startx = x1Screen; starty = y1Screen;
- painter.drawEllipse( x1Screen-5, y1Screen-5, 10, 10);
- }
- painter.drawLine( x1Screen, y1Screen, x2Screen, y2Screen);
- }
- // Show the endig point if different than the starting point
- if (x2Screen != startx || y2Screen != starty)
- {
- painter.drawEllipse( x2Screen-5, y2Screen-5, 10, 10);
- }
-}
-
-void RouteDialog::on_closePushButton_clicked()
-{
- close();
-}
-
-/*
- * Read route coordinates (latitude, longitude, altitude) from file.
- */
-bool RouteDialog::readRouteFromFile( QString &filename)
-{
- Vector temp;
- QString rivi;
- QFile file;
-
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Read Route"), "./", tr("Route Files (*.txt)"));
-
- file.setFileName( fileName);
- if (!file.open(QIODevice::ReadOnly))
- {
- QMessageBox::about(0, "Error", "File not found");
- return false;
- }
-
- vertexList.clear();
- while(!file.atEnd())
- {
- QString str1, str2, str3;
- rivi = file.readLine();
-
- str1 = rivi.section(" ", 0, 0);
- if (str1.compare("Start:") != 0 && str1.compare("Stop:") != 0)
- {
- str1 = rivi.section(" ", 2, 2); // latitude y-value
- str2 = rivi.section(" ", 4, 4); // longitude x-value
- str3 = rivi.section(" ", 6, 6); // altitude z-value
- //QString str = QString("la: %1 lo: %2 al: %3").arg(str1).arg(str2).arg(str3);
- //QMessageBox::about(0, "LUKEE", str);
-
- if (str1.length() > 0)
- {
- double x, y, z;
- x = str2.toDouble();
- y = str1.toDouble();
- z = str3.toDouble();
- temp.setX( x); // Longitude
- temp.setY( y); // Latitude
- temp.setZ( z); // altitude
-
- vertexList.append(temp);
- }
- }
- }
-
- file.close();
-
- /******** in 3d use only */
- a = 400/2.;
- b = 1 - a*(-1);
- c = -300/2.;
- d = 300 - c*(-1);
- //angle = toradians(60);
-
- view3d.setUp( 1.0, 0.0, 0.0);
- view3d.setAngle(toradians(60));
- setAtPoint( &view3d);
- xmin = objxmin; xmax = objxmax; ymin = objymin; ymax = objymax; // 2d viewing needs this !!!!
- setFromPoint( &view3d);
- view3d.setEye();
- /****** end of 3d *****/
-
- /*
- //Testing distance counting
- Vector a1, a2;
- qreal dist;
- //a1.setX( xmin); a1.setY( ymin);
- //a2.setX( xmax); a2.setY( ymax);
- a1.setX( 25.483); a1.setY( 65.017); // Oulu
- a2.setX( 27.767); a2.setY( 64.283); // Kajaani
- dist = countDistance( &a1, &a2);
- QString str = QString("Min & Max datan välimatka %1").arg(dist);
- QMessageBox::about( 0, "Testi", str);
- */
-
- return true;
-}
-
-/*
- * Find out data range for x-, y- and z-coordinates
- */
-void dataMinMax( void)
-{
- int i, maxi;
- qreal x,y,z;
- Vector temp;
-
- temp = vertexList.at(0);
- objxmax = objxmin = temp.getX();
- objymax = objymin = temp.getY();
- objzmax = objzmin = temp.getZ();
-
- maxi = vertexList.size();
- for (i=1; i<maxi; i++)
- {
- temp = vertexList.at(i);
- x = temp.getX();
- y = temp.getY();
- z = temp.getZ();
-
- if (x < objxmin)
- {
- objxmin = x;
- }
- else if (x > objxmax)
- {
- objxmax = x;
- }
-
- if (y < objymin)
- {
- objymin = y;
- }
- else if (y > objymax)
- {
- objymax = y;
- }
-
- if (z < objzmin)
- {
- objzmin = z;
- }
- else if (z > objzmax)
- {
- objzmax = z;
- }
- }
- //QString jono = QString("ojxmin %1 objxmax %2").arg(objxmin).arg(objxmax);
- //QString jono = QString("ojymin %1 objymax %2").arg(objymin).arg(objymax);
- //QString jono = QString("ojzmin %1 objzmax %2").arg(objzmin).arg(objzmax);
- //QMessageBox::about(0,"Tark", jono);
-}
-
-/*
- * Setting the point where the viewed object is. In the middle of datapoints.
- */
-void setAtPoint( Viewing *v)
-{
- qreal x, y, z;
- dataMinMax();
- //Vector test;
-
- x = (objxmax+objxmin)/2.0;
- y= (objymax+objymin)/2.0;
- z= (objzmax+objzmin)/2.0;
-
- v->setAtPoint( x, y, z);
- //QString jono = QString("AtX %1 Aty %2 AtZ %3").arg(atPoint.x()).arg(atPoint.y()).arg(atPoint.z());
- //QString jono = QString("AtX %1 Aty %2 AtZ %3").arg(atPoint.x).arg(atPoint.y).arg(atPoint.z);
-
- /* *
- test = v->getAtPoint();
- QString jono = QString("AtX %1 Aty %2 AtZ %3").arg(test.getX()).arg(test.getY()).arg(test.getZ());
- QMessageBox::about(0,"At point", jono);
- * */
-}
-
-/*
- * Setting the point where the object is viewed by eye.
- */
-void setFromPoint( Viewing *v)
-{
- qreal x, y, z;
- Vector point;
- point = v->getAtPoint();
- //Vector test;
- //fromPoint.setX( atPoint.getX() + (objxmax-objxmin)/2.0 + WIDTH*maxof((objzmax-objzmin)/2.0,(objymax-objymin)/2.0));
- //x = 3.0;
- //x = point.getX() + (objxmax-objxmin)/2.0 + WIDTH*maxof((objzmax-objzmin)/2.0,(objymax-objymin)/2.0);
- x = point.getX();
- //y = point.getY();
- y = point.getY() + 40; // + (objymax-objymin)/2.0 + WIDTH*maxof((objzmax-objzmin)/2.0,(objxmax-objxmin)/2.0);
- z = point.getZ();
-
- v->setFromPoint(x,y,z);
- //QString jono = QString("FromX %1 FromY %2 FromZ %3").arg(fromPoint.x()).arg(fromPoint.y()).arg(fromPoint.z());
- //QString jono = QString("FromX %1 FromY %2 FromZ %3").arg(fromPoint.x).arg(fromPoint.y).arg(fromPoint.z);
- /* *
- test = v->getFromPoint();
- QString jono = QString("FromX %1 FromY %2 FromZ %3").arg(test.getX()).arg(test.getY()).arg(test.getZ());
- QMessageBox::about(0,"From point", jono); // (1.9, 0.5, 0.5)
- * */
-}
-
-
-#define NOEDGE 0x00
-#define LEFTEDGE 0x01
-#define RIGHTEDGE 0x02
-#define BOTTOMEDGE 0x04
-#define TOPEDGE 0x08
-/*
- * Returns a code specifying which edge in the viewing pyramid was crossed.
- * There may be more than one.
- */
-int code( qreal x, qreal y, qreal z)
-{
- int c;
-
- c = NOEDGE;
- if (x<-z) c |= LEFTEDGE;
- if (x>z) c |= RIGHTEDGE;
- if (y<-z) c |= BOTTOMEDGE;
- if (y>z) c |= TOPEDGE;
-
- return c;
-}
-
-/*
- * Converts clipped world coordinates to screen coordinates.
- */
-void WORLDtoSCREEN( qreal xWorld, qreal yWorld, int *xScreen, int *yScreen)
-{
- *xScreen = (int) (a*xWorld+b);
- *yScreen = (int) (c*yWorld+d);
-}
-
-/*
- * Clips the line segment in three-dimensional coordinates to the
- * viewing pyramid.
- */
-void clip3d( qreal x1, qreal y1, qreal z1, qreal x2, qreal y2, qreal z2, int *xscreen1, int *yscreen1, int *xscreen2, int *yscreen2)
-{
- int c,c1,c2;
- qreal x,y,z,t;
-
- c1 = code(x1,y1,z1);
- c2 = code(x2,y2,z2);
-
- while (c1!= NOEDGE || c2 != NOEDGE)
- {
- if ((c1 & c2 ) != NOEDGE) return;
- c = c1;
- if (c == NOEDGE) c = c2;
- if ((c&LEFTEDGE) == LEFTEDGE)
- {
- // Crosses left edge
- t = (z1+x1)/((x1-x2)-(z2-z1));
- z = t*(z2-z1)+z1;
- x = -z;
- y = t*(y2-y1)+y1;
- }
- else if ((c&RIGHTEDGE) == RIGHTEDGE)
- {
- // Crosses right edge
- t = (z1-x1)/((x2-x1)-(z2-z1));
- z = t*(z2-z1)+z1;
- x = z;
- y = t*(y2-y1)+y1;
- }
- else if ((c&BOTTOMEDGE) == BOTTOMEDGE)
- {
- // Crosses bottom edge
- t = (z1+y1)/((y1-y2)-(z2-z1));
- z = t*(z2-z1)+z1;
- x = t*(x2-x1)+x1;
- y = -z;
- }
- else if ((c&TOPEDGE) == TOPEDGE)
- {
- // Crosses top edge
- t = (z1-y1)/((y2-y1)-(z2-z1));
- z = t*(z2-z1)+z1;
- x = t*(x2-x1)+x1;
- y = z;
- }
-
- if (c == c1)
- {
- x1=x; y1=y; z1=z;
- c1 = code(x,y,z);
- }
- else
- {
- x2=x; y2=y; z2=z;
- c2 = code(x,y,z);
- }
- }
-
- if (z1 != 0)
- {
- WORLDtoSCREEN(x1/z1,y1/z1,xscreen1, yscreen1);
- WORLDtoSCREEN(x2/z2,y2/z2,xscreen2, yscreen2);
- }
- else
- {
- WORLDtoSCREEN(x1,y1,xscreen1, yscreen1);
- WORLDtoSCREEN(x2,y2,xscreen2, yscreen2);
- }
- //Now ready to draw line( xscreen1, yscreen1, xscreen2, yscreen2);
-}
-
-/*
- * Transform the segment connecting the two vectors into the viewing plane.
- * clip3d() clips the line if needed.
- */
-void transformseg( Viewing *v, Vector *v1, Vector *v2, int *xscreen1, int *yscreen1, int *xscreen2, int *yscreen2)
-
-{
- qreal x1, y1, z1, x2, y2, z2;
- Vector a1, a2, a3;
-
- a1 = v->getA1();
- a2 = v->getA2();
- a3 = v->getA3();
-
- x1 = (a1.getX()*v1->getX() + a1.getY()*v1->getY() + a1.getZ()*v1->getZ() + v->getOffsx())*v->getDval();
- y1 = (a2.getX()*v1->getX() + a2.getY()*v1->getY() + a2.getZ()*v1->getZ() + v->getOffsy())*v->getDval();
- z1 = a3.getX()*v1->getX() + a3.getY()*v1->getY() + a3.getZ()*v1->getZ() + v->getOffsz();
-
- x2 = (a1.getX()*v2->getX() + a1.getY()*v2->getY() + a1.getZ()*v2->getZ() + v->getOffsx())*v->getDval();
- y2 = (a2.getX()*v2->getX() + a2.getY()*v2->getY() + a2.getZ()*v2->getZ() + v->getOffsy())*v->getDval();
- z2 = a3.getX()*v2->getX() + a3.getY()*v2->getY() + a3.getZ()*v2->getZ() + v->getOffsz();
-
- clip3d(x1,y1,z1,x2,y2,z2, xscreen1, yscreen1, xscreen2, yscreen2 );
-}
+++ /dev/null
-#ifndef ROUTEDIALOG_H
-#define ROUTEDIALOG_H
-
-#include <QDialog>
-
-namespace Ui {
- class RouteDialog;
-}
-
-class RouteDialog : public QDialog {
- Q_OBJECT
-public:
- RouteDialog(QWidget *parent = 0);
- ~RouteDialog();
- bool readRouteFromFile( QString &routeFile);
-
-protected:
- void changeEvent(QEvent *e);
- void paintEvent(QPaintEvent *);
-
-private:
- Ui::RouteDialog *ui;
- int left, top, right, bottom; // Limits in screen coordinates in route dialog
-
-private slots:
- void on_closePushButton_clicked();
-};
-
-#endif // ROUTEDIALOG_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>RouteDialog</class>
- <widget class="QDialog" name="RouteDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Dialog</string>
- </property>
- <widget class="QPushButton" name="closePushButton">
- <property name="geometry">
- <rect>
- <x>140</x>
- <y>226</y>
- <width>121</width>
- <height>41</height>
- </rect>
- </property>
- <property name="text">
- <string>Close</string>
- </property>
- </widget>
- </widget>
- <resources/>
- <connections/>
-</ui>
--- /dev/null
+# -------------------------------------------------
+# Project created by QtCreator 2010-03-29T09:21:42
+# -------------------------------------------------
+TARGET = speedfreak
+TEMPLATE = app
+SOURCES += main.cpp \
+ mainwindow.cpp \
+ creditsdialog.cpp
+HEADERS += mainwindow.h \
+ creditsdialog.h
+FORMS += mainwindow.ui \
+ creditsdialog.ui
--- /dev/null
+<!DOCTYPE QtCreatorProject>
+<qtcreator>
+ <data>
+ <variable>RunConfiguration0-BaseEnvironmentBase</variable>
+ <value type="int">2</value>
+ </data>
+ <data>
+ <variable>RunConfiguration0-CommandLineArguments</variable>
+ <valuelist type="QVariantList"/>
+ </data>
+ <data>
+ <variable>RunConfiguration0-ProFile</variable>
+ <value type="QString">speedfreak.pro</value>
+ </data>
+ <data>
+ <variable>RunConfiguration0-RunConfiguration.name</variable>
+ <value type="QString">speedfreak</value>
+ </data>
+ <data>
+ <variable>RunConfiguration0-UseDyldImageSuffix</variable>
+ <value type="bool">false</value>
+ </data>
+ <data>
+ <variable>RunConfiguration0-UseTerminal</variable>
+ <value type="bool">false</value>
+ </data>
+ <data>
+ <variable>RunConfiguration0-UserEnvironmentChanges</variable>
+ <valuelist type="QVariantList"/>
+ </data>
+ <data>
+ <variable>RunConfiguration0-UserSetName</variable>
+ <value type="bool">false</value>
+ </data>
+ <data>
+ <variable>RunConfiguration0-UserSetWorkingDirectory</variable>
+ <value type="bool">false</value>
+ </data>
+ <data>
+ <variable>RunConfiguration0-UserWorkingDirectory</variable>
+ <value type="QString"></value>
+ </data>
+ <data>
+ <variable>RunConfiguration0-type</variable>
+ <value type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
+ </data>
+ <data>
+ <variable>activeRunConfiguration</variable>
+ <value type="int">0</value>
+ </data>
+ <data>
+ <variable>activebuildconfiguration</variable>
+ <value type="QString">Debug</value>
+ </data>
+ <data>
+ <variable>buildConfiguration-Debug</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
+ <value key="QtVersionId" type="int">0</value>
+ <value key="ToolChain" type="int">0</value>
+ <value key="buildConfiguration" type="int">2</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>buildConfiguration-Release</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
+ <value key="QtVersionId" type="int">0</value>
+ <value key="buildConfiguration" type="int">0</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>buildconfiguration-Debug-buildstep0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>buildconfiguration-Debug-buildstep1</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>buildconfiguration-Debug-cleanstep0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
+ <value key="cleanConfig" type="bool">true</value>
+ <valuelist key="makeargs" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
+ </valuemap>
+ </data>
+ <data>
+ <variable>buildconfiguration-Release-buildstep0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>buildconfiguration-Release-buildstep1</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>buildconfiguration-Release-cleanstep0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>buildconfigurations</variable>
+ <valuelist type="QVariantList">
+ <value type="QString">Debug</value>
+ <value type="QString">Release</value>
+ </valuelist>
+ </data>
+ <data>
+ <variable>buildstep0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
+ <value key="mkspec" type="QString"></value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>buildstep1</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>buildsteps</variable>
+ <valuelist type="QVariantList">
+ <value type="QString">trolltech.qt4projectmanager.qmake</value>
+ <value type="QString">trolltech.qt4projectmanager.make</value>
+ </valuelist>
+ </data>
+ <data>
+ <variable>cleanstep0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
+ <value key="clean" type="bool">true</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>cleansteps</variable>
+ <valuelist type="QVariantList">
+ <value type="QString">trolltech.qt4projectmanager.make</value>
+ </valuelist>
+ </data>
+ <data>
+ <variable>defaultFileEncoding</variable>
+ <value type="QByteArray">System</value>
+ </data>
+ <data>
+ <variable>project</variable>
+ <valuemap type="QVariantMap"/>
+ </data>
+</qtcreator>
+++ /dev/null
-/*
- * Stringlistmodel class
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @exaple http://qt.nokia.com/doc/4.0/qt4-interview.html#example-code
- */
-
-#include "stringlistmodel.h"
-
-int StringListModel::rowCount(const QModelIndex &parent) const
-{
- return stringList.count();
-}
-
-QVariant StringListModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (index.row() < 0 || index.row() >= stringList.size())
- return QVariant();
-
- if (role == Qt::DisplayRole)
- return stringList.at(index.row());
- else
- return QVariant();
-}
-QVariant StringListModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- if (role != Qt::DisplayRole)
- return QVariant();
-
- if (orientation == Qt::Horizontal)
- return QString("Column %1").arg(section);
- else
- return QString("Row %1").arg(section);
-}
+++ /dev/null
-/*
- * Stringlistmodel class
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @exaple http://qt.nokia.com/doc/4.0/qt4-interview.html#example-code
- */
-
-#ifndef STRINGLISTMODEL_H
-#define STRINGLISTMODEL_H
-#include <QAbstractListModel>
-#include <QObject>
-#include <QStringList>
-
-class StringListModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- StringListModel(const QStringList &strings, QObject *parent = 0):QAbstractListModel(parent), stringList(strings) {}
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
-
-private:
- QStringList stringList;
-};
-
-#endif // STRINGLISTMODEL_H
+++ /dev/null
-/*
- * Welcome dialog
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "welcomedialog.h"
-#include "ui_welcomedialog.h"
-
-WelcomeDialog::WelcomeDialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::WelcomeDialog)
-{
- ui->setupUi(this);
- this->setWindowTitle(" ");
- movie = new QMovie("start.gif");
- ui->labelWelcome->setMovie(movie);
- movie->start();
- connect(movie,SIGNAL(frameChanged(int)),this,SLOT(stop(int)));
-}
-
-WelcomeDialog::~WelcomeDialog()
-{
- delete ui;
- movie->stop();
- delete movie;
-}
-
-void WelcomeDialog::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-void WelcomeDialog::stop(int currentFrame)
-{
- if (currentFrame == 21)
- {
- movie->stop();
- this->close();
- }
-}
+++ /dev/null
-/*
- * Welcome dialog
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef WELCOMEDIALOG_H
-#define WELCOMEDIALOG_H
-
-#include <QDialog>
-#include <QMovie>
-
-namespace Ui {
- class WelcomeDialog;
-}
-
-class WelcomeDialog : public QDialog {
- Q_OBJECT
-public:
- WelcomeDialog(QWidget *parent = 0);
- ~WelcomeDialog();
-
-protected:
- void changeEvent(QEvent *e);
-
-private:
- Ui::WelcomeDialog *ui;
- QMovie *movie;
-
-private slots:
- void stop(int currentFrame);
-};
-
-#endif // WELCOMEDIALOG_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>WelcomeDialog</class>
- <widget class="QDialog" name="WelcomeDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>480</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string/>
- </property>
- <widget class="QLabel" name="labelWelcome">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>10</y>
- <width>781</width>
- <height>461</height>
- </rect>
- </property>
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </widget>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- * Parse xml file
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @author Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include <QFile>
-#include <QDebug>
-#include "xmlreader.h"
-
-/**
- *Constructor of this class.
- */
-XmlReader::XmlReader()
-{
- myCategoryList = new CategoryList();
-}
-
-/**
- *Destructor of this class. Should be used to release all allocated resources.
- */
-XmlReader::~XmlReader()
-{
- category = "";
- unit = "";
- position = "";
- user = "";
- value = "";
- delete myCategoryList;
-}
-
-/**
- *This function is used to parse top 10 results of a certain category.
- */
-void XmlReader::xmlReadTop10Results(QNetworkReply *device)
-{
- qDebug() << "_xmlReadTop10Results";
-
- int i = 0;
- int receivedFlag = 0;
-
- xmlreader.clear();
- QByteArray array = device->readAll();
- qDebug() << "array: " << array;
- xmlreader.addData(array);
- //xmlreader.addData(device->readAll());
-
- if(!(myCategoryList->top10List.isEmpty())) {
- myCategoryList->top10List.clear();
- }
-
- //Go trough the xml document
- while(!xmlreader.atEnd())
- {
- //Read next node
- xmlreader.readNext();
- //Check if this element is starting element
- if(xmlreader.isStartElement())
- {
- if(xmlreader.name() == "results")
- {
- qDebug() << xmlreader.name();
- }
- if(xmlreader.name() == "result")
- {
- qDebug() << "result";
- attr = xmlreader.attributes();
-
- user = attr.value("username").toString();
- position = attr.value("position").toString();
- date = attr.value("date").toString();
- unit = attr.value("unit").toString();
- value = attr.value("value").toString();
-
- myCategoryList->top10List.append(position + "\t" +
- user + "\t" +
- value + " " +
- unit + "\t" +
- date + "\n");
-
- qDebug() << position << user << value << unit << date;
- i++;
- receivedFlag = 1;
- }
- }
- }
- //Only change labelTopList if a new top10List has been received
- if(receivedFlag)
- {
- qDebug() << "receivedTop10List() emitted";
- emit receivedTop10List();
- }
-}
-
-void XmlReader::xmlReadCategories(QNetworkReply *device)
-//void XmlReader::xmlReadCategories(QIODevice *device)
-{
- qDebug() << "_xmlReadCategories";
-
- int i = 0;
- int receivedFlag = 0;
-
- xmlreader.clear();
- QByteArray array = device->readAll();
- qDebug() << "array: " << array;
- xmlreader.addData(array);
- //xmlreader.addData(device->readAll());
-
- if(myCategoryList->sizeOfCategoryList() != 0) {
- myCategoryList->clearCategoryList();
- }
- myCategoryList->clearCats();
-
- //Go trough the xml document
- while(!xmlreader.atEnd())
- {
- //Read next node
- xmlreader.readNext();
-
- //Check if this element is starting element
- if(xmlreader.isStartElement())
- {
- if(xmlreader.name() == "categories")
- {
- qDebug() << xmlreader.name();
- }
- if(xmlreader.name() == "category")
- {
- qDebug() << xmlreader.name();
- attr = xmlreader.attributes();
- description = attr.value("description").toString();
- unit = attr.value("unit").toString();
- category = xmlreader.readElementText();
- myCategoryList->appendCategoryList(category);
- myCategoryList->appendCats(i, description, unit, category);
- //qDebug() << "i=" << i << myCategoryList->itemOfCategoryList(i);
- //qDebug() << "description: " << description << "unit: " << unit << "category: " << category;
- i++;
- receivedFlag = 1;
- }
- }
- }
- //Only change comboBoxTopCategory if a new list has been received
- if(receivedFlag)
- {
- qDebug() << "receivedCategoryList() emitted";
- emit receivedCategoryList();
- }
-}
-
-/**
- *This function is used to read example xml file (results.xml).
- *@todo Read real xml.
- */
-void XmlReader::xmlShow()
-{
- //QString filename = "results.xml";
- QString filename = "xmlcategoryfile.xml";
- QFile file(filename);
-
- if (!file.open(QFile::ReadOnly))
- {
- qDebug() << "_xmlShow fail";
- return;
- }
-
- //xmlReadTop10Results(&file);
- //xmlReadCategories(&file);
- file.close();
-}
-
+++ /dev/null
-/*
- * Parse xml file
- *
- * @author Toni Jussila <toni.jussila@fudeco.com>
- * @author Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
- * @copyright (c) 2010 Speed Freak team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef XMLREADER_H
-#define XMLREADER_H
-
-#include <QXmlStreamReader>
-#include <QStringList>
-#include <QNetworkReply>
-#include "categorylist.h"
-
-class XmlReader : public QObject {
- Q_OBJECT
-public:
- XmlReader();
- ~XmlReader();
- CategoryList *myCategoryList;
-
-private:
- QXmlStreamReader xmlreader;
-
- QXmlStreamAttributes attr;
- QString category;
- QString unit;
- QString date;
- QString position;
- QString user;
- QString value;
- QString description;
-
-signals:
- void receivedCategoryList();
- void receivedTop10List();
-
-public slots:
- void xmlReadTop10Results(QNetworkReply *device);
- void xmlReadCategories(QNetworkReply *device);
- //void xmlReadCategories(QIODevice *device);
- void xmlShow();
-};
-
-#endif // XMLREADER_H
+++ /dev/null
-/*
- * Xml writer
- *
- * @author Tiina Kivilinna-Korhola
- * @copyright (c) 2010 Speed Freak team
- * license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#include "xmlwriter.h"
-
-
-
-/**
- *@brief Constructor, connects object to GUI
- *@param Pointer to carmainwindow, which is temporarily used during development
- */
-XmlWriter::XmlWriter()
-{
- tmpvalue = 3010;
-}
-
-/**
- *@brief Destructor
- */
-XmlWriter::~XmlWriter()
-{
-
-}
-
-/**
- *@brief Writes registration items into tags.
- *@param netbuf a buffer where xmlstreamwriter writes to.
- *@param usr for user name.
- *@param psswd for password.
- *@param email.
- */
-void XmlWriter::writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QString email)
-{
- qDebug() << "_writeRegistering";
-
- xmlwriter.setDevice(netbuf);
-
- xmlwriter.writeStartDocument();
- xmlwriter.writeStartElement("user");
-
- xmlwriter.writeStartElement("login");
- xmlwriter.writeCharacters(usr);
- xmlwriter.writeEndElement();
-
- xmlwriter.writeStartElement("password");
- xmlwriter.writeCharacters(psswd);
- xmlwriter.writeEndElement();
-
- xmlwriter.writeStartElement("email");
- xmlwriter.writeCharacters(email);
- xmlwriter.writeEndElement();
-
- xmlwriter.writeEndElement();
- xmlwriter.writeEndDocument();
-}
-
-
-/**
- *@brief Writes Speed Freek results items as tags and contents into a buffer.
- *@todo Consider looping when writing many values.
- *@todo Replace test value to finally used variables.
- */
-void XmlWriter::writeResult(QBuffer *netbuf)
-{
- qDebug() << "_writeResult";
-
- xmlwriter.setDevice(netbuf);
-
- xmlwriter.writeStartDocument();
- xmlwriter.writeStartElement("result");
- tmpvalue++;
- qDebug() << tmpvalue;
- xmlwriter.writeAttribute("value", QString::number(tmpvalue));
- xmlwriter.writeEndElement();
- xmlwriter.writeEndDocument();
-}
-
-
-/**
- *@brief Write track to server.
- *@param netbuf where to write.
- *@param counter is GPSData::roundCounter.
- *@todo Decide suitable attributes.
- */
-void XmlWriter::writeGpsTrack(QBuffer *netbuf, int counter, int start, int stop, int lat, int lon, int alt, int speed, int time)
-{
- qDebug() << "_writeGpsTrack";
-
- double *ptrValue;
- //ptrValue = ptrTable;
- double tmp = 0;
-
- xmlwriter.setDevice(netbuf);
-
- xmlwriter.writeStartDocument();
-
- xmlwriter.writeStartElement("Route");
- xmlwriter.writeAttribute("starttime", QDateTime::currentDateTime().toString());
- xmlwriter.writeAttribute("endtime", QDateTime::currentDateTime().toString());
- xmlwriter.writeAttribute("points", QDateTime::currentDateTime().toString());
- for(int i = 0; i < counter; i++)
- {
- xmlwriter.writeStartElement("point");
- xmlwriter.writeAttribute("lat", QString::number(lat));
- xmlwriter.writeAttribute("lon", QString::number(lon));
- xmlwriter.writeAttribute("alt", QString::number(alt));
- xmlwriter.writeAttribute("speed", QString::number(speed));
- xmlwriter.writeAttribute("time", QString::number(time));
- xmlwriter.writeEndElement();
- }
- xmlwriter.writeEndElement();
- xmlwriter.writeEndDocument();
-}
-
-
-/**
- *@brief Opens and closes a file, when xml information is written into a file,
- *and passes file to writeXmlFile()
- *@param usr for user name.
- *@param psswd for password.
- *@param email.
- *@todo Replace hardcoced filename to finally GUI entry widget.
- */
-//void XmlWriter::writeXml(QString usr, QString psswd, QString email)
-void XmlWriter::writeXml()
-{
- QString filename = "xmlcategoryfile.xml";
- QFile file(filename);
- if (!file.open(QFile::WriteOnly | QFile::Text)) {
- qDebug() << "_xmlWrite fail";
- return;
- }
-
- writeXmlFile(&file);
- //writeRegistering(&file, usr, psswd, email);
- //writeResult(&file);
- file.close();
-}
-
-/**
- *@brief Writes general xml information.
- *Calls other functions to insert login and result information.
- *@param device: target of writing, here filename.
- *@param usr for user name.
- *@param psswd for password.
- *@param email.
- */
-bool XmlWriter::writeXmlFile(QIODevice *device)
-{
- xmlwriter.setDevice(device);
- xmlwriter.writeStartDocument();
- writeItems();
- xmlwriter.writeEndDocument();
-
- return true;
-}
-
-
-/**
- *@brief Writes Speed Freek results items as tags and contents to earlier defined target.
- *@todo Consider looping when writing many values.
- *@todo Replace testing values to finally used variabls.
- */
-void XmlWriter::writeItems()
-{
- xmlwriter.writeStartElement("result");
- xmlwriter.writeAttribute("value", QString::number(14)); //tmp testing value
- xmlwriter.writeAttribute("unit", "seconds");
- xmlwriter.writeAttribute("date", QDateTime::currentDateTime().toString());
- xmlwriter.writeEndElement();
-}
-
+++ /dev/null
-/*
- * Xml writer
- *
- * @author Tiina Kivilinna-Korhola
- * @copyright (c) 2010 Speed Freak team
- * license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
-
-#ifndef XMLWRITER_H
-#define XMLWRITER_H
-
-#include <QXmlStreamWriter>
-#include <QBuffer>
-#include <QtGui>
-#include <QNetworkRequest>
-#include <QIODevice>
-#include <QFile>
-#include <QMessageBox>
-#include <QDebug>
-#include <QDateTime>
-#include <QDate>
-#include <QTime>
-#include <QByteArray>
-#include <QApplication>
-
-
-class XmlWriter : public QObject {
- Q_OBJECT
-public:
- XmlWriter();
- ~XmlWriter();
- int tmpvalue;
- int trackInd;
-
-private:
- QXmlStreamWriter xmlwriter;
-
-public slots:
- void writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QString email);
- void writeResult(QBuffer *netbuf);
- void writeGpsTrack(QBuffer *netbuf, int counter, int start, int stop, int lat, int lon, int alt, int speed, int time);
- bool writeXmlFile(QIODevice *device);
- //void writeXml(QString usr, QString psswd, QString email);
- void writeXml();
- void writeItems();
-};
-
-#endif // XMLWRITER_H
-