From: Artem Daniliants Date: Fri, 5 Mar 2010 13:34:18 +0000 (+0200) Subject: Merge remote branch 'remotes/origin/master' into server X-Git-Tag: v0.1~75 X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=commitdiff_plain;h=6a5d354c744e7a91500478d77d38f6376068c892;hp=8062481f7ee26d12aeed313ce860b1d471b4491f Merge remote branch 'remotes/origin/master' into server --- diff --git a/Client/UI.pro b/Client/UI.pro index 590687e..924d9d7 100644 --- a/Client/UI.pro +++ b/Client/UI.pro @@ -1,6 +1,11 @@ # ------------------------------------------------- # 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 diff --git a/Client/accelerometer.cpp b/Client/accelerometer.cpp index 1a36361..5c16c98 100644 --- a/Client/accelerometer.cpp +++ b/Client/accelerometer.cpp @@ -1,3 +1,12 @@ +/* + * Accelerometer class to access the device accelerometer + * + * @author Rikhard Kuutti + * @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" diff --git a/Client/accelerometer.h b/Client/accelerometer.h index 52990df..2ee3ec9 100644 --- a/Client/accelerometer.h +++ b/Client/accelerometer.h @@ -1,3 +1,12 @@ +/* + * Accelerometer class to access the device accelerometer + * + * @author Rikhard Kuutti + * @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 diff --git a/Client/calculate.cpp b/Client/calculate.cpp index ad535b1..85afca3 100644 --- a/Client/calculate.cpp +++ b/Client/calculate.cpp @@ -1,3 +1,12 @@ +/* + * 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 diff --git a/Client/calculate.h b/Client/calculate.h index 421990f..ef000ba 100644 --- a/Client/calculate.h +++ b/Client/calculate.h @@ -1,3 +1,11 @@ +/* + * 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 diff --git a/Client/carmainwindow.cpp b/Client/carmainwindow.cpp index d340d19..67be42d 100644 --- a/Client/carmainwindow.cpp +++ b/Client/carmainwindow.cpp @@ -1,3 +1,14 @@ +/** + * CarMainWindow main class + * + * @author Toni Jussila + * @author Janne Änäkkälä + * @author Tiina Kivilinna-Korhola + * @author Olavi Pulkkinen + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + #include "carmainwindow.h" /** @@ -11,18 +22,13 @@ CarMainWindow::CarMainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::Ca 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 } /** @@ -55,15 +61,15 @@ void CarMainWindow::changeEvent(QEvent *e) /** *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]); } /** @@ -85,51 +91,47 @@ void CarMainWindow::on_autoStartButton_clicked() *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); } /** @@ -177,7 +179,6 @@ void CarMainWindow::openResultView() } /** -<<<<<<< HEAD:Client/carmainwindow.cpp *This slot function is called when the server has finished guery. */ void CarMainWindow::networkResponse(QNetworkReply *reply) @@ -212,7 +213,9 @@ void CarMainWindow::on_loginLogoutButton_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() @@ -227,5 +230,24 @@ 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"); } diff --git a/Client/carmainwindow.h b/Client/carmainwindow.h index c6c0963..89868c6 100644 --- a/Client/carmainwindow.h +++ b/Client/carmainwindow.h @@ -1,3 +1,14 @@ +/** + * CarMainWindow main class + * + * @author Toni Jussila + * @author Janne Änäkkälä + * @author Tiina Kivilinna-Korhola + * @author Olavi Pulkkinen + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + #ifndef CARMAINWINDOW_H #define CARMAINWINDOW_H @@ -27,9 +38,9 @@ public: 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: @@ -43,27 +54,28 @@ private: 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 diff --git a/Client/carmainwindow.ui b/Client/carmainwindow.ui index a7c48c1..0df2dae 100644 --- a/Client/carmainwindow.ui +++ b/Client/carmainwindow.ui @@ -11,7 +11,7 @@ - CarMainWindow + Speed freak @@ -24,7 +24,7 @@ - 0 + 2 @@ -72,7 +72,7 @@ - + 0 @@ -100,7 +100,7 @@ - + @@ -110,7 +110,7 @@ - + @@ -120,7 +120,7 @@ - + @@ -223,6 +223,32 @@ Settings + + + + 20 + 30 + 141 + 17 + + + + User: + + + + + + 20 + 60 + 93 + 27 + + + + Set User + + @@ -265,23 +291,10 @@ - - - - 690 - 0 - 93 - 27 - - - - Login - - - 580 + 690 0 93 27 diff --git a/Client/loginwindow.cpp b/Client/loginwindow.cpp index 0b4e6cf..e8b816b 100644 --- a/Client/loginwindow.cpp +++ b/Client/loginwindow.cpp @@ -32,14 +32,36 @@ void LoginWindow::on_cancelPushButton_clicked() 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; +} + + + diff --git a/Client/loginwindow.h b/Client/loginwindow.h index b5f9c1b..51c5a2c 100644 --- a/Client/loginwindow.h +++ b/Client/loginwindow.h @@ -12,12 +12,18 @@ class LoginWindow : public QDialog { 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(); diff --git a/Client/main.cpp b/Client/main.cpp index d7eceae..68e444e 100644 --- a/Client/main.cpp +++ b/Client/main.cpp @@ -1,3 +1,11 @@ +/** + * CarMainWindow main class + * + * @author Toni Jussila + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + #include #include "carmainwindow.h" diff --git a/Client/measuredialog.cpp b/Client/measuredialog.cpp index 038116a..7e65537 100644 --- a/Client/measuredialog.cpp +++ b/Client/measuredialog.cpp @@ -3,8 +3,8 @@ /** - *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), @@ -49,7 +49,8 @@ void MeasureDialog::changeEvent(QEvent *e) } /** - *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() { @@ -59,7 +60,7 @@ 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); } @@ -139,7 +140,7 @@ void MeasureDialog::after_timeout() } /** - *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() { @@ -160,6 +161,9 @@ void MeasureDialog::on_pushButtonAbort_clicked() this->close(); } +/** + * Initializes measures class's member variables. + */ void MeasureDialog::initializeMeasures() { measures->setTime10kmh(0); diff --git a/Client/measures.cpp b/Client/measures.cpp index c840ec0..bf277f8 100644 --- a/Client/measures.cpp +++ b/Client/measures.cpp @@ -4,6 +4,10 @@ Measures::Measures() { } +/** + * Get the value of time10kmh + * @return time10kmh the time in qreal when speed has been 10 km/h + */ qreal Measures::getTime10kmh() { return time10kmh; @@ -54,6 +58,10 @@ 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; diff --git a/Client/registration.cpp b/Client/registration.cpp index de79f57..eae469f 100644 --- a/Client/registration.cpp +++ b/Client/registration.cpp @@ -30,11 +30,11 @@ void Registration::changeEvent(QEvent *e) 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() @@ -42,3 +42,32 @@ 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; +} diff --git a/Client/registration.h b/Client/registration.h index 6a7df95..87b049d 100644 --- a/Client/registration.h +++ b/Client/registration.h @@ -12,12 +12,21 @@ class Registration : public QDialog { 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(); diff --git a/Client/resultdialog.cpp b/Client/resultdialog.cpp index c3b3a74..e10b46e 100644 --- a/Client/resultdialog.cpp +++ b/Client/resultdialog.cpp @@ -17,6 +17,10 @@ static const int speedArray[10] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; // 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) @@ -29,6 +33,9 @@ ResultDialog::ResultDialog(QWidget *parent) : // 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; @@ -48,7 +55,7 @@ void ResultDialog::changeEvent(QEvent *e) /** * Draws speed diagram to the UI - * + * @param QPaintEvent */ void ResultDialog::paintEvent(QPaintEvent *) { @@ -64,7 +71,7 @@ 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); @@ -74,7 +81,7 @@ void ResultDialog::paintEvent(QPaintEvent *) 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); @@ -85,10 +92,10 @@ void ResultDialog::paintEvent(QPaintEvent *) } /** - *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; @@ -104,9 +111,9 @@ QPoint ResultDialog::changeMeasuresToDiagramPoint(int aSpeed, qreal aTime) } /** - *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(); @@ -120,7 +127,7 @@ void ResultDialog::saveMeasuresToArray(Measures *pMeasures) 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]); } @@ -163,7 +170,7 @@ void ResultDialog::saveMeasuresToArray(Measures *pMeasures) this->repaint(); - for(int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { timeArray[i] = 0; } diff --git a/Client/resultdialog.ui b/Client/resultdialog.ui index c0c3a73..81717c3 100644 --- a/Client/resultdialog.ui +++ b/Client/resultdialog.ui @@ -483,6 +483,19 @@ 4 + + + + 402 + 330 + 101 + 27 + + + + Send results + + diff --git a/Client/xmlreader.cpp b/Client/xmlreader.cpp index 3e26629..c3a439c 100644 --- a/Client/xmlreader.cpp +++ b/Client/xmlreader.cpp @@ -1,6 +1,14 @@ +/** + * Parse xml file + * + * @author Toni Jussila + * @author Tiina Kivilinna-Korhola + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + #include #include -//#include #include "xmlreader.h" /** diff --git a/Client/xmlreader.h b/Client/xmlreader.h index fa69133..615ca36 100644 --- a/Client/xmlreader.h +++ b/Client/xmlreader.h @@ -1,3 +1,12 @@ +/** + * Parse xml file + * + * @author Toni Jussila + * @author Tiina Kivilinna-Korhola + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + #ifndef XMLREADER_H #define XMLREADER_H