Merge branch 'master' of https://vcs.maemo.org/git/speedfreak
authorOlavi Pulkkinen <olavi.pulkkinen@fudeco.com>
Wed, 24 Mar 2010 12:14:43 +0000 (14:14 +0200)
committerOlavi Pulkkinen <olavi.pulkkinen@fudeco.com>
Wed, 24 Mar 2010 12:14:43 +0000 (14:14 +0200)
Client/carmainwindow.cpp
Client/carmainwindow.h
Client/carmainwindow.ui
Client/httpclient.cpp

index b6108af..af637b3 100644 (file)
@@ -66,7 +66,7 @@ CarMainWindow::CarMainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::Ca
     accelerationStartThreshold = 0.02;
 
     accelerometerTimer = new QTimer(this);
-//tkk  connect(accelerometerTimer, SIGNAL(timeout()), this, SLOT(readAccelerometerData()));
+    connect(accelerometerTimer, SIGNAL(timeout()), this, SLOT(readAccelerometerData()));
     //accelerometerTimer->start(kAccelerometerSampleRate);
 
     // Calculate
@@ -153,7 +153,7 @@ void CarMainWindow::on_autoStartButton_clicked()
     ui->pushButtonShowResultDialog->setEnabled(false);
     choice = ui->listViewStartTabAccelerationCategories->currentIndex();
     choiceInt = choice.row();
-    qDebug() << "choiceInt" << choiceInt << " " << catList.at(choiceInt);
+    //qDebug() << "choiceInt" << choiceInt << " " << catList.at(choiceInt);
     if (choiceInt == 0)
     {
         ui->labelMeasureTabHeader->setText("Accelerate to 40 km/h");
@@ -223,7 +223,8 @@ void CarMainWindow::initListViewStartTabAccelerationCategories()
     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";
+    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);
 }
@@ -238,6 +239,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
index 9b7ee18..a1140d7 100644 (file)
@@ -61,6 +61,7 @@ public:
 
     void setComboBoxStartTabUnits(QStringList units);       //Start-tab view
     void setListViewStartTabAccelerationCategories(QStringList numbers); //Start-tab view
+    void setLabelInfoToUser(QString infoText);
 
 protected:
     void changeEvent(QEvent *e);
index 3780027..196eb76 100644 (file)
@@ -24,7 +24,7 @@
      </rect>
     </property>
     <property name="currentIndex">
-     <number>4</number>
+     <number>1</number>
     </property>
     <widget class="QWidget" name="tabTop">
      <attribute name="title">
      <widget class="QListView" name="listViewStartTabAccelerationCategories">
       <property name="geometry">
        <rect>
-        <x>0</x>
+        <x>20</x>
         <y>10</y>
-        <width>151</width>
+        <width>251</width>
         <height>301</height>
        </rect>
       </property>
      <widget class="QWidget" name="layoutWidget">
       <property name="geometry">
        <rect>
-        <x>160</x>
+        <x>320</x>
         <y>10</y>
-        <width>311</width>
+        <width>161</width>
         <height>301</height>
        </rect>
       </property>
      <widget class="QLabel" name="labelMeasureTabHeader">
       <property name="geometry">
        <rect>
-        <x>40</x>
+        <x>20</x>
         <y>10</y>
         <width>261</width>
         <height>41</height>
      <widget class="QLabel" name="labelMeasureTabTimeHeader">
       <property name="geometry">
        <rect>
-        <x>25</x>
+        <x>20</x>
         <y>70</y>
         <width>60</width>
         <height>41</height>
      <widget class="QLabel" name="labelMeasureTabSpeedHeader">
       <property name="geometry">
        <rect>
-        <x>25</x>
+        <x>20</x>
         <y>160</y>
         <width>81</width>
         <height>41</height>
      <string>Registrate</string>
     </property>
    </widget>
+   <widget class="QLabel" name="labelInfoToUser">
+    <property name="geometry">
+     <rect>
+      <x>20</x>
+      <y>370</y>
+      <width>461</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string/>
+    </property>
+   </widget>
   </widget>
   <widget class="QMenuBar" name="menuBar">
    <property name="geometry">
index 0a68341..750aa42 100644 (file)
@@ -27,7 +27,6 @@ HttpClient::~HttpClient()
 /**
   *@brief Sends registration information to the server in xml format.
   *Reads user name, password and emaol address from resuldialogs internal variables.
-  *@todo Replace msg box with better reaction to server`s responce.
   */
 void HttpClient::requestRegistration()
 {
@@ -50,6 +49,7 @@ void HttpClient::requestRegistration()
     currentDownload = netManager->post(request, ("xml=" + regbuffer->data()));
     connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRegistration()));
     //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
+    myMainw->setLabelInfoToUser("Reguesting registration from server");
 
     regbuffer->close();
 }
@@ -80,6 +80,7 @@ void HttpClient::sendResultXml(QString category)
     currentDownload = netManager->post(request, ("xml=" + xmlbuffer->data()));
     connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfResult()));
     //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
+    myMainw->setLabelInfoToUser("Sending result to server");
 
     xmlbuffer->close();
 }
@@ -111,6 +112,7 @@ void HttpClient::sendRouteXml()
     currentDownload = netManager->post(request, ("xml=" + xmlbuffer->data()));
     connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRoute()));
     //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
+    myMainw->setLabelInfoToUser("Sending route to server");
 
     xmlbuffer->close();
 }
@@ -138,6 +140,7 @@ void HttpClient::requestTopList(QString category, QString limit)
     currentDownload = netManager->post(request, ("data=" ));
     connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfToplist()));
     //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
+    myMainw->setLabelInfoToUser("Reguesting top10 list from server");
 }
 
 
@@ -161,6 +164,7 @@ void HttpClient::requestCategories()
     currentDownload = netManager->post(request, ("data=" ));
     connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfCategories()));
     //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
+    myMainw->setLabelInfoToUser("Reguesting categories from server");
 }
 
 
@@ -184,17 +188,19 @@ void HttpClient::checkLogin()
     currentDownload = netManager->post(request, ("data=" ));
     connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfLogin()));
     //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
+    myMainw->setLabelInfoToUser("Checking login validity from server");
 }
 
 
 /**
   *@brief React to servers responce after result has been sent.
-  *@todo Implement consequencies of reply.
   */
 void HttpClient::ackOfResult()
 {
     qDebug() << "_ackOfResult";
 
+    myMainw->setLabelInfoToUser("");
+
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
 
     QNetworkReply::NetworkError errorcode;
@@ -210,13 +216,14 @@ void HttpClient::ackOfResult()
 }
 
 /**
-  *@brief React to servers responce after result has been sent.
-  *@todo Implement consequencies of reply.
+  *@brief React to servers responce after route has been sent.
   */
 void HttpClient::ackOfRoute()
 {
     qDebug() << "_ackOfRoute";
 
+    myMainw->setLabelInfoToUser("");
+
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
 
     QNetworkReply::NetworkError errorcode;
@@ -239,6 +246,8 @@ void HttpClient::ackOfRegistration()
 {
     qDebug() << "_ackOfRegistration";
 
+    myMainw->setLabelInfoToUser("");
+
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
 
     QNetworkReply::NetworkError errorcode;
@@ -251,7 +260,6 @@ void HttpClient::ackOfRegistration()
         qDebug() << "errorcode=0" << errorcode << reply->errorString();
         QMessageBox::about(myMainw, "Server reply to registration", "User registration " + reply->readAll());
     }
-
 }
 
 
@@ -262,6 +270,8 @@ void HttpClient::ackOfCategories()
 {
     qDebug() << "_ackOfCategories";
 
+    myMainw->setLabelInfoToUser("");
+
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
     myXmlreader->xmlReadCategories(reply);
 
@@ -275,18 +285,18 @@ void HttpClient::ackOfCategories()
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
         QMessageBox::about(myMainw, "Server reply to requesting categories ", "OK");
     }
-
 }
 
 
 /**
   *@brief React to servers responce after request of TopList in certain category has been sent.
-  *@todo Implement routing reply`s contents to UI.
   */
 void HttpClient::ackOfLogin()
 {
     qDebug() << "_ackOffLogin";
 
+    myMainw->setLabelInfoToUser("");
+
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
 
     QNetworkReply::NetworkError errorcode;
@@ -309,29 +319,31 @@ void HttpClient::errorFromServer(QNetworkReply::NetworkError errorcode)
 {
     qDebug() << "_errorFromServer";
 
+    myMainw->setLabelInfoToUser("");
+
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
 
     if(errorcode != 0) {
         qDebug() <<  "errorcode:" << errorcode;
-        //Note that errors are already reported on other ach-functions for server communication
+        //Note that errors are already reported on other each functions for server communication
         //QMessageBox::about(myMainw, "Server reported an error", reply->errorString());
     }
     else {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
         qDebug() << reply->readAll();
     }
-
 }
 
 
 /**
   *@brief React to servers responce after request of TopList in certain category has been sent.
-  *@todo Implement routing reply`s contents to UI.
   */
 void HttpClient::ackOfToplist()
 {
     qDebug() << "_ackOfToplist";
 
+    myMainw->setLabelInfoToUser("");
+
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
     myXmlreader->xmlReadTop10Results(reply);
 
@@ -345,6 +357,5 @@ void HttpClient::ackOfToplist()
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
         QMessageBox::about(myMainw, "Server reply to requesting top 10 list", "OK " + reply->readAll());
     }
-
 }