Progress bar added to route dialog. Profile send to server disabled.
authorToni Jussila <toni.jussila@fudeco.com>
Fri, 7 May 2010 05:26:16 +0000 (08:26 +0300)
committerToni Jussila <toni.jussila@fudeco.com>
Fri, 7 May 2010 05:26:16 +0000 (08:26 +0300)
Client/calibratedialog.cpp
Client/calibratedialog.h
Client/httpclient.cpp
Client/mainwindow.cpp
Client/routedialog.cpp
Client/routedialog.h
Client/routedialog.ui
Client/routesavedialog.cpp
Client/routesavedialog.h

index 7194c89..146e85c 100644 (file)
@@ -48,3 +48,8 @@ void CalibrateDialog::setMaxValue(int max)
 {
     ui->progressBar->setMaximum( max );
 }
+
+void CalibrateDialog::setTitle(QString title)
+{
+    this->setWindowTitle(title);
+}
index 341e91c..516624d 100644 (file)
@@ -24,6 +24,7 @@ public:
     void setProgressValue(int value);
     void resetProgressValue();
     void setMaxValue(int max);
+    void setTitle(QString title);
 
 protected:
     void changeEvent(QEvent *e);
index d4c723c..944749f 100644 (file)
@@ -463,7 +463,8 @@ void HttpClient::sendProfileXml()
     if(myMainw->settingsDialog->profileDialog)
         myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Profile saved to phone");
 
-    QUrl qurl("http://api.speedfreak-app.com/api/profile");
+    // Send xml to server
+    /*QUrl qurl("http://api.speedfreak-app.com/api/profile");
     QNetworkRequest request(qurl);
     qDebug() << qurl.toString();
     QNetworkReply *currentDownload;
@@ -473,12 +474,12 @@ void HttpClient::sendProfileXml()
     request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
 
     currentDownload = netManager->post(request, ("xml=" + file.readAll()));
-    bool error = connect(currentDownload, SIGNAL(finished()), this, SLOT(ackOfProfile()));
+    bool error = connect(currentDownload, SIGNAL(finished()), this, SLOT(ackOfProfile()));*/
 
     file.close();
 
-    // Send picture
-    if(myMainw->settingsDialog->profileDialog->getPicture() != "" && error == false)
+    // Send picture to server
+    /*if(myMainw->settingsDialog->profileDialog->getPicture() != "" && error == false)
     {
         QFile pictureFile( myMainw->settingsDialog->profileDialog->getPicture() );
         if (!pictureFile.open(QIODevice::ReadOnly))
@@ -489,7 +490,7 @@ void HttpClient::sendProfileXml()
         currentDownload = netManager->post(request, pictureFile.readAll());
         connect(currentDownload, SIGNAL(finished()), this, SLOT(ackOfSendingPicture()));
         pictureFile.close();
-    }
+    }*/
 }
 
 /**
index 3e8d531..6eb8757 100644 (file)
@@ -317,7 +317,7 @@ void MainWindow::killDialog()
     }
     if(routeSaveDialog)
     {
-        qDebug() << "__MW kill: routeSaveDialog";
+        //qDebug() << "__MW kill: routeSaveDialog";
         //delete routeSaveDialog;
         //routeSaveDialog = NULL;
     }
index a711974..85a848e 100644 (file)
@@ -184,8 +184,6 @@ RouteDialog::RouteDialog(RouteSaveDialog *parent) :
     // Button settings
     ui->sendPushButton->setAutoFillBackground(true);
     ui->sendPushButton->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
-    ui->newPushButton->setAutoFillBackground(true);
-    ui->newPushButton->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
 
     // Clear labels
     ui->labelInfoToUser->setText("");
@@ -430,39 +428,31 @@ void RouteDialog::paintEvent(QPaintEvent *)
 /**
   *
   */
-bool RouteDialog::readRouteFromFile( QString &routeFile , CalibrateDialog *calibrateDialog)
+bool RouteDialog::readRouteFromFile( QString &routeFile )
 {
     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)"));
-
-    //file.setFileName( fileName);
     file.setFileName( "routetemp.xml");
     if (!file.open(QIODevice::ReadOnly))
     {
         QMessageBox::about(0, "Error", "File not found");
-        progresbar->setProgressValue(100);
         return false;
     }
-
+emit progressbar(5);
     vertexList.clear();
-
+    emit progressbar(50);
     while(!file.atEnd())
     {
+        //qDebug() << "__jee ";
+
         int count;
         bool allRead;
         QString astr1, astr2, astr3, astr4;
         QString str1, str2, str3, str4;
         rivi = file.readLine();
-
         allRead = false;
         count = 0;
         while( !allRead)
@@ -478,9 +468,6 @@ bool RouteDialog::readRouteFromFile( QString &routeFile , CalibrateDialog *calib
                 str2 = astr2.section('"',1,1);
                 str3 = astr3.section('"',1,1);
                 str4 = astr4.section('"',1,1);
-            //QString str = QString("%1 %2 %3 %4").arg(str1).arg(str2).arg(str3).arg(str4);
-            //QMessageBox::about(0, "LUKEE", str);
-                /* */
 
                 if (str1.length() > 0)
                 {
@@ -488,8 +475,6 @@ bool RouteDialog::readRouteFromFile( QString &routeFile , CalibrateDialog *calib
                     y = str1.toDouble();// longitude x-value
                     z = str3.toDouble();// altitude z-value
                     v = str4.toDouble();// speed km/h
-               // QString str = QString("%1 %2 %3 %4").arg(x).arg(y).arg(z).arg(v);
-               // QMessageBox::about(0, "LUKEE", str);
                     temp.setX( x); // Longitude
                     temp.setY( y); // Latitude
                     temp.setZ( z); // altitude
@@ -504,34 +489,6 @@ bool RouteDialog::readRouteFromFile( QString &routeFile , CalibrateDialog *calib
                 }
             }
         }
-        // Older version
-        /*
-        str1 = rivi.section(" ", 0, 0);
-        if (str1.compare("Start:") != 0 && str1.compare("Stop:") != 0)
-        {
-            str1 = rivi.section(" ", 2, 2); // latitude y-value
-            str2 = rivi.section(" ", 4, 4); // longitude x-value
-            str3 = rivi.section(" ", 6, 6); // altitude z-value
-            str4 = rivi.section(" ", 8, 8); // speed km/h
-            //QString str = QString("la: %1 lo: %2 al: %3").arg(str1).arg(str2).arg(str3);
-            //QMessageBox::about(0, "LUKEE", str);
-
-            if (str1.length() > 0)
-            {
-                double x, y, z, v;
-                x = str2.toDouble();
-                y = str1.toDouble();
-                z = str3.toDouble();
-                v = str4.toDouble();
-                temp.setX( x); // Longitude
-                temp.setY( y); // Latitude
-                temp.setZ( z); // altitude
-                temp.setV( v);
-
-                vertexList.append(temp);
-            }
-        }
-        */
     }
 
     file.close();
@@ -563,8 +520,8 @@ bool RouteDialog::readRouteFromFile( QString &routeFile , CalibrateDialog *calib
      QString str = QString("Min & Max datan v√§limatka %1").arg(dist);
      QMessageBox::about( 0, "Testi", str);
      */
-
-     return true;
+    emit progressbar(100);
+    return true;
 }
 
 /**
@@ -807,14 +764,6 @@ void transformseg( Viewing *v, Vector *v1, Vector *v2, int *xscreen1, int *yscre
 }
 
 /**
-  * This slot function is called when ever new push button clicked.
-  */
-void RouteDialog::on_newPushButton_clicked()
-{
-    close();    // go back to previous dialog
-}
-
-/**
   * This slot function is called when ever send push button clicked.
   */
 void RouteDialog::on_sendPushButton_clicked()
index 81e3584..9f68617 100644 (file)
@@ -13,7 +13,6 @@
 #include <QDialog>
 #include <helproutingdialog.h>
 class RouteSaveDialog;
-class CalibrateDialog;
 
 namespace Ui {
     class RouteDialog;
@@ -25,7 +24,7 @@ class RouteDialog : public QDialog {
 public:
     RouteDialog(RouteSaveDialog *parent = 0);
     ~RouteDialog();
-    bool readRouteFromFile( QString &routeFile, CalibrateDialog *calibrateDialog);
+    bool readRouteFromFile( QString &routeFile);
     int getLeft();
     int getTop();
     int getRight();
@@ -36,6 +35,7 @@ public:
 
 signals:
     void sendroute();
+    void progressbar(int);
 
 protected:
     void changeEvent(QEvent *e);
@@ -43,14 +43,12 @@ protected:
 
 private:
     Ui::RouteDialog *ui;
-    CalibrateDialog *progresbar;
     int left, top, right, bottom;       // Limits in screen coordinates in route dialog
     void checkLogin();
 
 private slots:
     void on_pushButtonInfo_clicked();
     void on_sendPushButton_clicked();
-    void on_newPushButton_clicked();
     void killHelpDialog();
 };
 
index e89d67d..e4b7b57 100644 (file)
   <property name="windowTitle">
    <string>Dialog</string>
   </property>
-  <widget class="QPushButton" name="newPushButton">
-   <property name="geometry">
-    <rect>
-     <x>710</x>
-     <y>150</y>
-     <width>90</width>
-     <height>90</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string/>
-   </property>
-   <property name="icon">
-    <iconset resource="graphics.qrc">
-     <normaloff>:/new/prefix1/Graphics/route_new.png</normaloff>:/new/prefix1/Graphics/route_new.png</iconset>
-   </property>
-   <property name="iconSize">
-    <size>
-     <width>85</width>
-     <height>85</height>
-    </size>
-   </property>
-  </widget>
   <widget class="QPushButton" name="sendPushButton">
    <property name="geometry">
     <rect>
      <x>710</x>
-     <y>50</y>
+     <y>120</y>
      <width>90</width>
      <height>90</height>
     </rect>
index d24bcb2..ed66bee 100644 (file)
@@ -103,6 +103,11 @@ RouteSaveDialog::~RouteSaveDialog()
         delete location;
     if(routeDialog)
         delete routeDialog;
+    if(calibrateDialog)
+    {
+        delete calibrateDialog;
+        calibrateDialog = NULL;
+    }
 
     delete timerSatellitePicture;
     delete timerRoutePicture;
@@ -258,37 +263,41 @@ void RouteSaveDialog::on_buttonRouteStartStop_clicked()
         timerRoutePicture->stop();
         location->stopPollingGPS();
 
-        // Progres bar
+        // Progress bar
         if(!calibrateDialog)
+        {
             calibrateDialog = new CalibrateDialog();
+        }
 
-        calibrateDialog->show();
+        progressbarPoints = 100;
+        progressbarIteration = 0;
         calibrateDialog->resetProgressValue();
-        int points = 100;
-        int iteration = 0;
-        calibrateDialog->setMaxValue( points + 1 );
+        calibrateDialog->setMaxValue( progressbarPoints );
+        calibrateDialog->setTitle("Calculating route...");
+        calibrateDialog->show();
+
 
-        /*do {
-            calibrateDialog->setProgressValue(iteration);
-            iteration++;
+        if(!routeDialog)
+        {
+            routeDialog = new RouteDialog(this);
+        }
 
-        } while(iteration != points);*/
+        connect(routeDialog, SIGNAL(sendroute()),      this, SLOT(sendRoute()));
+        connect(routeDialog, SIGNAL(progressbar(int)), this, SLOT(setProgressbar(int)));
+        connect(routeDialog, SIGNAL(rejected()),       this, SLOT(killRouteDialog()));
+        //connect(routeDialog, SIGNAL(killRoute()),      this, SLOT(killRouteDialog()));
 
         QString routeFile = QString("routetemp.xml");
-        if (routeDialog->readRouteFromFile( routeFile , calibrateDialog) == true)
+        if (routeDialog->readRouteFromFile( routeFile ) == true)
         {
-            if(!routeDialog)
-                routeDialog = new RouteDialog(this);
-            connect(routeDialog, SIGNAL(sendroute()), this, SLOT(sendRoute()));
-
-            calibrateDialog->close();
+            //calibrateDialog->close();
             routeDialog->show();
         }
         else
         {
-            calibrateDialog->close();
+            //calibrateDialog->close();
         }
-
+calibrateDialog->close();
         //Set GPS speed labels in visible
         ui->labelGpsSpeed->setVisible(0);
         ui->labelGpsAvgSpeed->setVisible(0);
@@ -476,6 +485,25 @@ void RouteSaveDialog::killHelpDialog()
 }
 
 /**
+  * This slot function called when ever dialog rejected.
+  */
+void RouteSaveDialog::killRouteDialog()
+{
+    if(routeDialog)
+    {
+        qDebug() << "__Route save kill: routeDialog";
+        delete routeDialog;
+        routeDialog = NULL;
+    }
+    if(calibrateDialog)
+    {
+        qDebug() << "__Route save kill: calibrateDialog";
+        delete calibrateDialog;
+        calibrateDialog = NULL;
+    }
+}
+
+/**
   * This function return speed average.
   * @return double average speed
   */
@@ -492,3 +520,14 @@ QString RouteSaveDialog::getDistanceTraveled()
 {
     return distanceString;
 }
+
+/**
+  * This function
+  */
+void RouteSaveDialog::setProgressbar(int i)
+{
+    qDebug() << "__setProgressbar " ;//+ i;
+    qDebug() << i;
+    calibrateDialog->setProgressValue(i);//progressbarIteration);
+    progressbarIteration++;
+}
index 924b4d6..4c257a9 100644 (file)
@@ -31,6 +31,7 @@ public:
     ~RouteSaveDialog();
     RouteDialog *routeDialog;
     HelpRoutingDialog *helpRoutingDialog;
+    CalibrateDialog *calibrateDialog;
     double getAverageSpeed();
     QString getDistanceTraveled();
 
@@ -44,7 +45,6 @@ private:
     QTimer *timerRoutePicture;
     GPSData *gpsData;
     Maemo5Location *location;
-    CalibrateDialog *calibrateDialog;
     QString gpsSpeed;
     QString distanceString;
     QPixmap *pixmapRouteStop;
@@ -57,6 +57,8 @@ private:
     double allSpeeds;
     int speedCount;
     double direction;
+    int progressbarIteration;
+    int progressbarPoints;
 
 private slots:
     void on_pushButtonInfo_clicked();
@@ -66,6 +68,8 @@ private slots:
     void gpsStatus();
     void sendRoute();
     void killHelpDialog();
+    void killRouteDialog();
+    void setProgressbar(int i);
 
 signals:
     void sendroute();