Merge branch 'development/GPSroute'
[speedfreak] / Client / carmainwindow.cpp
index 0deeddc..ca0cb8e 100644 (file)
@@ -158,6 +158,7 @@ void CarMainWindow::on_listViewStartTabAccelerationCategories_clicked(QModelInde
 
 /**
   *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()
 {
@@ -167,19 +168,22 @@ void CarMainWindow::on_autoStartButton_clicked()
     ui->pushButtonShowResultDialog->setEnabled(false);
     choice = ui->listViewStartTabAccelerationCategories->currentIndex();
     choiceInt = choice.row();
-    qDebug() << choiceInt;
+    //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");
@@ -223,10 +227,19 @@ void CarMainWindow::setComboBoxStartTabUnits(QStringList 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()
 {
-    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";
+    //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 << "0-40 km/h" << "0-100 km/h" << "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);
 }
@@ -241,6 +254,11 @@ void CarMainWindow::setListViewStartTabAccelerationCategories(QStringList accele
     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
@@ -397,7 +415,8 @@ void CarMainWindow::on_pushButtonMeasureTabAbort_clicked()
   */
 void CarMainWindow::on_pushButtonSendResult_clicked()
 {
-    myHttpClient->sendResultXml("acceleration-0-100");
+    //Pick up relevant category name and pass it to the server
+    myHttpClient->sendResultXml(catList.at(choiceInt));
     ui->pushButtonSendResult->setEnabled(false);
 }
 
@@ -428,7 +447,11 @@ void CarMainWindow::regUserToServer()
 
 void CarMainWindow::on_drawRoutePushButton_clicked()
 {
-    myRoute->show();
+    QString routeFile = QString("route.txt");
+    if (myRoute->readRouteFromFile( routeFile) == true)
+    {
+        myRoute->show();
+    }
 }
 
 /**
@@ -532,7 +555,6 @@ void CarMainWindow::handleCheckPoint(double totalTime, double currentSpeed)
         this->speed = 0;
         counterForSaveResults = 0;
     }
-
     else if (choiceInt == 1 && measures->getTime100kmh() != 0)
     {
         setTimeAxisGapAndShowResult(measures->getTime100kmh());
@@ -541,9 +563,16 @@ void CarMainWindow::handleCheckPoint(double totalTime, double currentSpeed)
         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());
@@ -553,10 +582,9 @@ void CarMainWindow::handleCheckPoint(double totalTime, double currentSpeed)
         this->speed = 0;
         counterForSaveResults = 0;
     }
-
     else
     {
-
+        qDebug() << "something wrong in handleCheckPoint()";
     }
 }