Added Info button for all dialog.
[speedfreak] / Client / routesavedialog.cpp
index 506c1e5..ba7100a 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "routesavedialog.h"
 #include "ui_routesavedialog.h"
+#include <QDebug>
 
 /**
   *Constructor of this class.
 RouteSaveDialog::RouteSaveDialog(QWidget *parent) :
     QDialog(parent), ui(new Ui::RouteSaveDialog){
 
+    qDebug() << "__RouteSaveDialog";
     ui->setupUi(this);
     this->setWindowTitle("Tracking");
 
     routeDialog = NULL;
+    location = NULL;
+    gpsData = NULL;
+    helpRoutingDialog = NULL;
 
     //Button settings
     buttonStatus = true;
@@ -32,6 +37,8 @@ RouteSaveDialog::RouteSaveDialog(QWidget *parent) :
     ui->buttonRouteStartStop->setIcon(*iconRouteStart);
     ui->buttonRouteStartStop->setAutoFillBackground(true);
     ui->buttonRouteStartStop->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+    ui->pushButtonInfo->setAutoFillBackground(true);
+    ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
 
     //Satellite picture and label
     ui->labelRouteSatelliteStatus->setVisible(0);
@@ -40,17 +47,17 @@ RouteSaveDialog::RouteSaveDialog(QWidget *parent) :
     timerSatellitePicture = new QTimer();
     timerSatellitePicture->setInterval(400);
     connect(timerSatellitePicture, SIGNAL(timeout()),this, SLOT(timerSatellitePictureTimeout()));
+    ui->labelUserInfo->setText("Push start button");  //User info label
 
-    //Route picture and label
+    //Invisible or clear labels
     ui->labelRouteStatus->setVisible(0);
     ui->labelRoutePicture->setVisible(0);
+    ui->labelGpsSpeed->setVisible(0); //GPS speed label
+    ui->labelSignalStrength->setText(""); //GPS signal strength label
     timerRoutePicture = new QTimer();
     timerRoutePicture->setInterval(400);
     connect(timerRoutePicture, SIGNAL(timeout()),this, SLOT(timerRoutePictureTimeout()));
 
-    //GPS speed label
-    ui->labelGpsSpeed->setVisible(0);
-
     //GPS
     location = new Maemo5Location(this);
     gpsData = new GPSData(location);
@@ -62,12 +69,18 @@ RouteSaveDialog::RouteSaveDialog(QWidget *parent) :
   */
 RouteSaveDialog::~RouteSaveDialog()
 {
-    delete ui;
+    qDebug() << "__~RouteSaveDialog";
+    if(ui)
+        delete ui;
+    if(gpsData)
+        delete gpsData;
+    if(location)
+        delete location;
+    if(routeDialog)
+        delete routeDialog;
+
     delete timerSatellitePicture;
     delete timerRoutePicture;
-    delete location;
-    delete gpsData;
-    delete routeDialog;
     delete pixmapRouteStop;
     delete pixmapRouteStart;
     delete iconRouteStop;
@@ -94,16 +107,17 @@ void RouteSaveDialog::changeEvent(QEvent *e)
   */
 void RouteSaveDialog::on_buttonRouteStartStop_clicked()
 {
-    //If start button clicked
-    if ( buttonStatus == true )
+    if ( buttonStatus == true )//If start button clicked
     {
+        qDebug() << "__start button clicked";
         buttonStatus = false;
         ui->buttonRouteStartStop->setIcon(*iconRouteStop);
         location->startPollingGPS();
         gpsStatus();
     }
-    else
+    else //If stop button clicked
     {
+        qDebug() << "__stop button clicked";
         buttonStatus = true;
         ui->buttonRouteStartStop->setIcon(*iconRouteStart);
 
@@ -133,6 +147,9 @@ void RouteSaveDialog::on_buttonRouteStartStop_clicked()
 
         //Stop route recording
         gpsData->stopRouteRecording();
+
+        //User info label
+        ui->labelUserInfo->setText("Push start button");
     }
 }
 
@@ -182,8 +199,10 @@ void RouteSaveDialog::gpsStatus()
     //IF GPS start button clicked
     if (buttonStatus == false)
     {
-        //If GPS find 4 satellite.
-        if (location->getSatellitesInUse() >= 4)
+        //ui->labelSignalStrength->setText(QString::number(location->getSignalStrength()));    //Returns average signal strength of satellites which are in use.
+
+        //If GPS find 4 or more satellite and signal stregth is 30 or more.
+        if (location->getSatellitesInUse() >= 4 && location->getSignalStrength() >= 30)
         {
             //Satellite picture and label
             ui->labelRouteSatelliteStatus->setText("GPS Ready");
@@ -193,6 +212,7 @@ void RouteSaveDialog::gpsStatus()
 
             //Route picture and label
             ui->labelRouteStatus->setText("Recorded " + QString::number(gpsData->roundCounter) + " route point");
+            ui->labelUserInfo->setText("Recorded " + QString::number(gpsData->roundCounter) + " route point");
             ui->labelRouteStatus->setVisible(1);
             ui->labelRoutePicture->setVisible(1);
             timerRoutePicture->start();
@@ -205,12 +225,11 @@ void RouteSaveDialog::gpsStatus()
             //Start route recording
             gpsData->startRouteRecording();
         }
-
-        //If GPS find less than 4 satellite.
-        else
+        else //If GPS find less than 4 satellite or signal strength is poor.
         {
             //Satellite picture and label
             ui->labelRouteSatelliteStatus->setText("Searching satellite");
+            ui->labelUserInfo->setText("Searching satellite");
             ui->labelRouteSatelliteStatus->setVisible(1);
             ui->labelRouteSatellitePicture->setVisible(1);
             timerSatellitePicture->start();
@@ -224,10 +243,11 @@ void RouteSaveDialog::gpsStatus()
             ui->labelGpsSpeed->setVisible(0);
         }
     }
-    else
+    else //If stop button clicked
     {
         //Satellite picture and label
         ui->labelRouteSatelliteStatus->setText("Searching satellite");
+        ui->labelUserInfo->setText("Push start button");
         ui->labelRouteSatelliteStatus->setVisible(0);
         ui->labelRouteSatellitePicture->setVisible(0);
         timerSatellitePicture->stop();
@@ -249,3 +269,29 @@ void RouteSaveDialog::sendRoute()
 {
     emit sendroute(); //Emit mainwindow clientSendRoute
 }
+
+/**
+  * This slot function called when ever info button clicked.
+  */
+void RouteSaveDialog::on_pushButtonInfo_clicked()
+{
+    if(!helpRoutingDialog)
+    {
+        helpRoutingDialog = new HelpRoutingDialog;
+    }
+    connect(helpRoutingDialog, SIGNAL(rejected()), this, SLOT(killHelpDialog()));
+    helpRoutingDialog->show();
+}
+
+/**
+  * This slot function called when ever dialog rejected.
+  */
+void RouteSaveDialog::killHelpDialog()
+{
+    if(helpRoutingDialog)
+    {
+        qDebug() << "__Route save kill: helpRoutingDialog";
+        delete helpRoutingDialog;
+        helpRoutingDialog = NULL;
+    }
+}