# -------------------------------------------------
# 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 \
xml
TARGET = UI
+/*
+ * Accelerometer class to access the device accelerometer
+ *
+ * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
+ * @author Kai Rasilainen
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
#include "accelerometer.h"
#include "math.h"
+/*
+ * Accelerometer class to access the device accelerometer
+ *
+ * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
+ * @author Kai Rasilainen
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
#ifndef ACCELEROMETER_H
#define ACCELEROMETER_H
+/*
+ * 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>
+/*
+ * 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
+/**
+ * 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>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
#include "carmainwindow.h"
/**
measure = new MeasureDialog();
xmlreader = new XmlReader();
- initUnitCompoBox();
- initSpeedListView();
-<<<<<<< HEAD:Client/carmainwindow.cpp
- initCategoryCompoBox();
+ initComboBoxStartTabUnits();
+ initListViewStartTabAccelerationCategories();
myLogin = new LoginWindow(this);
myRegistration = new Registration(this);
manager = new QNetworkAccessManager(this);
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(networkResponse(QNetworkReply*)));
-
-=======
->>>>>>> feature/XMLreader:Client/carmainwindow.cpp
}
/**
/**
*This slot function is called when ever list view is update. Start-tab view.
*/
-void CarMainWindow::on_listView_clicked(QModelIndex index)
+void CarMainWindow::on_listViewStartTabAccelerationCategories_clicked(QModelIndex index)
{
QString str = index.data().toString();
QStringList list = str.split("-");
QStringList list2 = list[1].split(" ");
- ui->minLineEdit->setText(list[0]);
- ui->maxLineEdit->setText(list2[0]);
- updateUnitCompoBox(list2[1]);
+ ui->lineEditStartTabMin->setText(list[0]);
+ ui->lineEditStartTabMax->setText(list2[0]);
+ updateComboBoxStartTabUnits(list2[1]);
}
/**
*This slot function is called when ever list view is update. Start-tab view.
*@param QString unit.
*/
-void CarMainWindow::updateUnitCompoBox(QString unit)
+void CarMainWindow::updateComboBoxStartTabUnits(QString unit)
{
- ui->unitComboBox->setCurrentIndex(ui->unitComboBox->findText(unit, Qt::MatchExactly));
+ ui->comboBoxStartTabUnits->setCurrentIndex(ui->comboBoxStartTabUnits->findText(unit, Qt::MatchExactly));
}
/**
*This function is used to init unit combobox. Start-tab view.
*/
-void CarMainWindow::initUnitCompoBox()
+void CarMainWindow::initComboBoxStartTabUnits()
{
units << "km/h" << "km" << "h" << "m" << "min" << "Mile" << "Mph" << "in" << "ft" << "yrd";
- ui->unitComboBox->addItems(units);
+ ui->comboBoxStartTabUnits->addItems(units);
}
/**
*This function is used to set items to unit combobox. Start-tab view.
- *@param QStringlist numbers
+ *@param QStringlist units
*/
-void CarMainWindow::setUnitCompoBox(QStringList units)
+void CarMainWindow::setComboBoxStartTabUnits(QStringList units)
{
- ui->unitComboBox->addItems(units);
+ ui->comboBoxStartTabUnits->addItems(units);
}
/**
- *This function is used to init speed listview. Start-tab view.
+ *This function is used to init listViewStartTabAccelerationCategories. Start-tab view.
*/
-void CarMainWindow::initSpeedListView()
+void CarMainWindow::initListViewStartTabAccelerationCategories()
{
-<<<<<<< HEAD:Client/carmainwindow.cpp
- numbers << "0-40 km/h" << "0-1/4 mil" << "0-50 km" << "50-100 mil" << "0-100 m" << "0-50 ft" << "0-50 yrd" << "0-500 in";
-=======
- numbers << "0-40 km/h" << "0-1/4 Mile" << "0-1/8 Mile" << "0-50 km" << "50-100 Mile" << "0-60 Mph" << "0-100 m" << "0-50 ft" << "0-50 yrd" << "0-500 in";
->>>>>>> feature/XMLreader:Client/carmainwindow.cpp
- QAbstractItemModel *model = new StringListModel(numbers);
- ui->listView->setModel(model);
+ accelerationCategoriesStartTab << "0-40 km/h" << "0-100 km/h"; //<< "0-1/4 Mile" << "0-1/8 Mile" << "0-50 km" << "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 speed listview. Start-tab view.
- *@param QStringlist numbers
+ *This function is used to set items to listViewStartTabAccelerationCategories. Start-tab view.
+ *@param QStringlist accelerationCategoriesStartTab
*/
-void CarMainWindow::setSpeedListView(QStringList numbers)
+void CarMainWindow::setListViewStartTabAccelerationCategories(QStringList accelerationCategoriesStartTab)
{
- QAbstractItemModel *model = new StringListModel(numbers);
- ui->listView->setModel(model);
+ QAbstractItemModel *model = new StringListModel(accelerationCategoriesStartTab);
+ ui->listViewStartTabAccelerationCategories->setModel(model);
}
/**
}
/**
-<<<<<<< HEAD:Client/carmainwindow.cpp
*This slot function is called when the server has finished guery.
*/
void CarMainWindow::networkResponse(QNetworkReply *reply)
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()
void CarMainWindow::on_comboBoxTopCategory_currentIndexChanged(QString category)
{
setListViewTopList(category);
->>>>>>> feature/XMLreader:Client/carmainwindow.cpp
+}
+
+/**
+ *This slot function is called when ever category combobox activated. Top-tab view.
+ *@param QString category
+ */
+void CarMainWindow::on_comboBoxTopCategory_activated(QString category)
+{
+ setListViewTopList(category);
+}
+
+/**
+ *This slot function is called when set/change user button is clicked.
+ */
+void CarMainWindow::on_setUserPushButton_clicked()
+{
+ myLogin->show();
+
+ ui->userNameLabel->setText( "User: " + myLogin->getUserName());
+ ui->setUserPushButton->setText( "Change User");
}
+/**
+ * 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>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
#ifndef CARMAINWINDOW_H
#define CARMAINWINDOW_H
CarMainWindow(QWidget *parent = 0);
~CarMainWindow();
- void setUnitCompoBox(QStringList units); //Start-tab
- void setSpeedListView(QStringList numbers); //Start-tab
- void setListViewTopList(QString category); //Top-tab
+ void setComboBoxStartTabUnits(QStringList units); //Start-tab view
+ void setListViewStartTabAccelerationCategories(QStringList numbers); //Start-tab view
+ void setListViewTopList(QString category); //Top-tab view
void setCategoryCompoBox(); //Top-tab
protected:
QNetworkAccessManager* manager;
LoginWindow *myLogin;
Registration *myRegistration;
- void initCategoryCompoBox();
- void initUnitCompoBox(); //Start-tab
- void initSpeedListView(); //Start-tab
+ //void initCategoryCompoBox(); //
+ void initComboBoxStartTabUnits(); //Start-tab view
+ void initListViewStartTabAccelerationCategories(); //Start-tab view
private:
- QStringList numbers; //Start-tab
- QStringList units; //Start-tab
- QStringList categories; //Top-tab
+ QStringList accelerationCategoriesStartTab; //Start-tab view
+ QStringList units; //Start-tab view
+ QStringList categories; //Top-tab view
private slots:
+ void on_setUserPushButton_clicked();
void on_registratePushButton_clicked();
void on_loginLogoutButton_clicked();
void on_comboBoxTopCategory_activated(QString );
void on_pushButton_clicked();
void networkResponse(QNetworkReply*);
- void on_comboBoxTopCategory_currentIndexChanged(QString category); //Top-tab
- void on_listView_clicked(QModelIndex index); //Start-tab
- void updateUnitCompoBox(QString unit); //Start-tab
+ 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: button
- void on_autoStartButton_clicked(); //Start-tab: button
+ void on_buttonTopRefresh_clicked(); //Top-tab view: button
+ void on_autoStartButton_clicked(); //Start-tab view: button
};
#endif // CARMAINWINDOW_H
</rect>
</property>
<property name="windowTitle">
- <string>CarMainWindow</string>
+ <string>Speed freak</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QTabWidget" name="tabWidget">
</rect>
</property>
<property name="currentIndex">
- <number>0</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="StartTab">
<attribute name="title">
</item>
</layout>
</widget>
- <widget class="QListView" name="listView">
+ <widget class="QListView" name="listViewStartTabAccelerationCategories">
<property name="geometry">
<rect>
<x>0</x>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="minLineEdit"/>
+ <widget class="QLineEdit" name="lineEditStartTabMin"/>
</item>
<item>
<widget class="QLabel" name="stopLabel">
</widget>
</item>
<item>
- <widget class="QLineEdit" name="maxLineEdit"/>
+ <widget class="QLineEdit" name="lineEditStartTabMax"/>
</item>
<item>
<widget class="QLabel" name="unitLabel">
</widget>
</item>
<item>
- <widget class="QComboBox" name="unitComboBox"/>
+ <widget class="QComboBox" name="comboBoxStartTabUnits"/>
</item>
</layout>
</widget>
<attribute name="title">
<string>Settings</string>
</attribute>
+ <widget class="QLabel" name="userNameLabel">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>30</y>
+ <width>141</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>User:</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="setUserPushButton">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>60</y>
+ <width>93</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Set User</string>
+ </property>
+ </widget>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
</item>
</layout>
</widget>
- <widget class="QPushButton" name="loginLogoutButton">
- <property name="geometry">
- <rect>
- <x>690</x>
- <y>0</y>
- <width>93</width>
- <height>27</height>
- </rect>
- </property>
- <property name="text">
- <string>Login</string>
- </property>
- </widget>
<widget class="QPushButton" name="registratePushButton">
<property name="geometry">
<rect>
- <x>580</x>
+ <x>690</x>
<y>0</y>
<width>93</width>
<height>27</height>
close();
}
+void setUser(QString uN, QString pW);
+
void LoginWindow::on_loginPushButton_clicked()
{
- // To do
- //loginToServer(ui->userNameLineEdit->text(),
- // ui->passwordLineEdit->text());
- //close();
- QMessageBox::about(this,"Login",ui->userNameLineEdit->text()+ui->passwordLineEdit->text());
+ this->username = ui->userNameLineEdit->text();
+ this->password = ui->passwordLineEdit->text();
+ 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;
+}
+
+
+
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();
+/**
+ * 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"
/**
- *Constructor of this class.
- *@param QWidget pointer to parent object. By default the value is NULL.
+ * Constructor of this class.
+ * @param QWidget pointer to parent object. By default the value is NULL.
*/
MeasureDialog::MeasureDialog(QWidget *parent) :
QDialog(parent),
}
/**
- *This slot function is called when timer gives timeout signal.
+ * This slot function is called when timer gives timeout signal. Checks current speed
+ * and stores times in measure class.
*/
void MeasureDialog::after_timeout()
{
speed = accelerometer->getCurrentSpeed();
//speed = speed +10;
- if(speed > 9.7 && speed < 10.3)
+ if (speed > 9.7 && speed < 10.3)
{
measures->setTime10kmh(time);
}
}
/**
- *This slot function is called when Abort button is clicked.
+ * This slot function is called when Abort button is clicked.
*/
void MeasureDialog::on_pushButtonAbort_clicked()
{
this->close();
}
+/**
+ * Initializes measures class's member variables.
+ */
void MeasureDialog::initializeMeasures()
{
measures->setTime10kmh(0);
{
}
+/**
+ * Get the value of time10kmh
+ * @return time10kmh the time in qreal when speed has been 10 km/h
+ */
qreal Measures::getTime10kmh()
{
return time10kmh;
return time100kmh;
}
+/**
+ * Set the given time in to the time10kmh
+ * @param pTime is time in qreal
+ */
void Measures::setTime10kmh(qreal pTime)
{
time10kmh = pTime;
void Registration::on_registratePushButton_clicked()
{
// Send username, password and email to SpeedFreak server
- //close(); // Needs some new signal/slot to go forward or ???
- //registrateToServer(ui->newUsernameLineEdit->text(),
- // ui->newPasswordLineEdit->text(),
- // ui->eMailLineEdit->text());
- QMessageBox::about(this,"Registrate",ui->newUsernameLineEdit->text()+ui->newPasswordLineEdit->text()+ui->eMailLineEdit->text());
+ this->username = ui->newUsernameLineEdit->text();
+ this->password = ui->newPasswordLineEdit->text();
+ this->email = ui->eMailLineEdit->text();
+
+ 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 password)
+{
+ this->email = email;
+}
+
+QString Registration::getUserName()
+{
+ return this->username;
+}
+
+QString Registration::getPassword()
+{
+ return this->password;
+}
+
+QString Registration::getEmail()
+{
+ return this->email;
+}
public:
Registration(QWidget *parent = 0);
~Registration();
+ void setUserName(QString username);
+ void setPassword(QString password);
+ void setEmail(QString email);
+ QString getUserName();
+ QString getPassword();
+ QString getEmail();
protected:
void changeEvent(QEvent *e);
private:
Ui::Registration *ui;
+ QString username;
+ QString password;
+ QString email;
private slots:
void on_cancelPushButton_clicked();
// Test point array for the diagram.
QPoint points[10];
+/**
+ * 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->labelYLine->setText(ui->labelYLine->text().append(": speed/ km/h"));
}
+/**
+ * Destructor of this class. Should be used to release all allocated resources.
+ */
ResultDialog::~ResultDialog()
{
delete ui;
/**
* Draws speed diagram to the UI
- *
+ * @param QPaintEvent
*/
void ResultDialog::paintEvent(QPaintEvent *)
{
int currentY = diagramStemStart.y();
// Draws diagram's X-axel
- for(int i = 0; i<13; i++)
+ for (int i = 0; i < 13; i++)
{
currentX += diagramGap;
painter.drawLine(currentX, currentY, currentX, currentY - 10);
currentY = diagramStemStart.y();
// Draws diagram's Y-axel
- for(int i = 0; i<10; i++)
+ for (int i = 0; i < 10; i++)
{
currentY -= diagramGap;
painter.drawLine(currentX, currentY, currentX+10, currentY);
}
/**
- *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.
- **/
+ * 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;
}
/**
- *Saves the given measures to array.
- *@param pMeasures has information about acceleration.
- **/
+ * Saves the given measures to array.
+ * @param pMeasures has information about acceleration.
+ */
void ResultDialog::saveMeasuresToArray(Measures *pMeasures)
{
timeArray[0] = pMeasures->getTime10kmh();
timeArray[8] = pMeasures->getTime90kmh();
timeArray[9] = pMeasures->getTime100kmh();
- for(int i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
{
points[i] = changeMeasuresToDiagramPoint(speedArray[i], timeArray[i]);
}
this->repaint();
- for(int i = 0; i < 10; i++)
+ for (int i = 0; i < 10; i++)
{
timeArray[i] = 0;
}
<string>4</string>
</property>
</widget>
+ <widget class="QPushButton" name="pushButtonSend">
+ <property name="geometry">
+ <rect>
+ <x>402</x>
+ <y>330</y>
+ <width>101</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Send results</string>
+ </property>
+ </widget>
</widget>
<resources/>
<connections/>
+/**
+ * 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 <QApplication>
#include "xmlreader.h"
/**
+/**
+ * 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