Profile dialog development
[speedfreak] / Client / routedialog.cpp
index f0806c8..35f232f 100644 (file)
@@ -7,6 +7,7 @@
  * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
  */
 
+#include "routesavedialog.h"
 #include "routedialog.h"
 #include "ui_routedialog.h"
 #include "usersettings.h"
@@ -169,17 +170,17 @@ qreal countDistance(Vector *p1, Vector *p2)
 /**
   * Constructor of this class.
   */
-RouteDialog::RouteDialog(QWidget *parent) :
+RouteDialog::RouteDialog(RouteSaveDialog *parent) :
     QDialog(parent), ui(new Ui::RouteDialog)
 {
     qDebug() << "__RouteDialog";
     ui->setupUi(this);
 
-    helpRoutingDialog = NULL;
-
     this->setWindowTitle("Route");
     left = 5; top = 5; right = 495; bottom = 295; // Limits in screen coordinates
 
+    helpRoutingDialog = NULL;
+
     // Button settings
     ui->sendPushButton->setAutoFillBackground(true);
     ui->sendPushButton->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
@@ -189,9 +190,15 @@ RouteDialog::RouteDialog(QWidget *parent) :
     // Clear labels
     ui->labelInfoToUser->setText("");
     ui->speedValueLabel->setText("");
+    ui->avgSpeedValueLabel->setText("");
 
     // Check login
     checkLogin();
+
+    // Set average speed
+    QString average;
+    ui->avgSpeedValueLabel->setText(average.sprintf("%.1f", parent->getAverageSpeed()) + " km/h");
+    ui->distanceValueLabel->setText(parent->getDistanceTraveled() + " km");
 }
 
 /**
@@ -202,6 +209,8 @@ RouteDialog::~RouteDialog()
     qDebug() << "__~RouteDialog";
     if(ui)
         delete ui;
+    if(calibrateDialog)
+        delete calibrateDialog;
 }
 
 /**
@@ -411,7 +420,7 @@ void RouteDialog::paintEvent(QPaintEvent *)
 
         // Show max velocity point by yellow circle
         painter.drawEllipse( x1Screen-5, y1Screen-5, 10, 10);
-        painter.drawEllipse( 650, 225, 10, 10);
+        painter.drawEllipse( ui->maxSpeedLabel->geometry().x()-15, ui->maxSpeedLabel->geometry().y()+15, 10, 10);
 
         QString jono;
         //jono = QString("%1 km/h").arg(maxv);
@@ -423,13 +432,17 @@ void RouteDialog::paintEvent(QPaintEvent *)
 /**
   *
   */
-bool RouteDialog::readRouteFromFile( QString &routeFile)
- {
+bool RouteDialog::readRouteFromFile( QString &routeFile , CalibrateDialog *calibrateDialog)
+{
     QString rFile = routeFile; //Not used
     Vector temp;
     QString rivi;
     QFile file;
 
+    progresbar = calibrateDialog;
+    int progresbarValue = 0;
+    progresbar->setProgressValue(++progresbarValue);
+
     //QString fileName = QFileDialog::getOpenFileName(this,
     //     tr("Read Route"), "./", tr("Route Files (*.txt)"));
 
@@ -438,6 +451,7 @@ bool RouteDialog::readRouteFromFile( QString &routeFile)
     if (!file.open(QIODevice::ReadOnly))
     {
         QMessageBox::about(0, "Error", "File not found");
+        progresbar->setProgressValue(100);
         return false;
     }
 
@@ -553,7 +567,7 @@ bool RouteDialog::readRouteFromFile( QString &routeFile)
      */
 
      return true;
- }
+}
 
 /**
   * Find out data range for x-, y- and z-coordinates