Get category when top dialog started.
authorToni Jussila <toni.jussila@fudeco.com>
Fri, 16 Apr 2010 12:01:32 +0000 (15:01 +0300)
committerToni Jussila <toni.jussila@fudeco.com>
Fri, 16 Apr 2010 12:01:32 +0000 (15:01 +0300)
Client/httpclient.cpp
Client/mainwindow.cpp
Client/mainwindow.h
Client/resultdialog.cpp
Client/resultdialog.ui
Client/routesavedialog.h
Client/routesavedialog.ui
Client/topresultdialog.cpp
Client/topresultdialog.ui

index acda598..547f3b8 100644 (file)
@@ -115,7 +115,7 @@ void HttpClient::sendRouteXml()
     currentDownload = netManager->post(request, ("xml=" + file.readAll()));
     connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRoute()));
     //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
-    myMainw->routeDialog->setLabelInfoToUser("Sending route to server");
+    myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser("Sending route to server");
 
     file.close();
 }
@@ -230,7 +230,7 @@ void HttpClient::ackOfRoute()
 {
     qDebug() << "_ackOfRoute";
 
-    myMainw->routeDialog->setLabelInfoToUser("");
+    myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser("");
 
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
 
@@ -238,7 +238,7 @@ void HttpClient::ackOfRoute()
     errorcode = reply->error();
     if(errorcode != 0) {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
-        QMessageBox::about(myMainw->routeDialog, "Server reply to route sending ",reply->errorString());
+        QMessageBox::about(myMainw->routeSaveDialog->routeDialog, "Server reply to route sending ",reply->errorString());
     }
     else {
         qDebug() << "errorcode:" << errorcode << reply->errorString();
@@ -287,11 +287,11 @@ void HttpClient::ackOfCategories()
     errorcode = reply->error();
     if(errorcode != 0) {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
-        QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories",reply->errorString());
+        //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories",reply->errorString());
     }
     else {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
-        QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK");
+        //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK");
     }
 }
 
@@ -361,7 +361,7 @@ void HttpClient::ackOfToplist()
     errorcode = reply->error();
     if(errorcode != 0) {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
-        QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list",reply->errorString());
+        //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list",reply->errorString());
     }
     else {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
index 8179fd7..4f32eee 100644 (file)
@@ -25,25 +25,21 @@ MainWindow::MainWindow(QWidget *parent) :
     QCoreApplication::setOrganizationDomain("fudeco.com");
     QCoreApplication::setApplicationName("Speed Freak");
 
-    routeDialog = new RouteDialog;
-    connect(routeDialog,SIGNAL(sendroute()),this,SLOT(clientSendRoute()));
+    //routeDialog = new RouteDialog;
+    //connect(routeDialog,SIGNAL(sendroute()),this,SLOT(clientSendRoute()));
 
     helpDialog = NULL;
+    accstart = NULL;
     routeSaveDialog = NULL;
+    topResultDialog = NULL;
 
     settingsDialog = new SettingsDialog;
     connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(clientRegUserToServer()));
     connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(clientUserLogin()));
 
-    topResultDialog = new TopResultDialog;
-    connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
-    connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
-
     httpClient = new HttpClient(this);
     connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
-    connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));
-
-    accstart = NULL;
+    connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));    
 
     //creditsDialog = new CreditsDialog;
 
@@ -68,11 +64,27 @@ MainWindow::MainWindow(QWidget *parent) :
 MainWindow::~MainWindow()
 {
     delete ui;
-    delete routeSaveDialog;
-    delete routeDialog;
+
+    if(routeSaveDialog)
+        delete routeSaveDialog;
 
     if(accstart)
         delete accstart;
+
+    if(topResultDialog)
+        delete topResultDialog;
+
+    if(settingsDialog)
+        delete settingsDialog;
+
+    if(welcomeDialog)
+        delete welcomeDialog;
+
+    if(httpClient)
+        delete httpClient;
+
+    if(helpDialog)
+        delete helpDialog;
 }
 
 void MainWindow::changeEvent(QEvent *e)
@@ -114,6 +126,7 @@ void MainWindow::on_pushButtonRoute_clicked()
     if(!routeSaveDialog)
         routeSaveDialog = new RouteSaveDialog;
     connect(routeSaveDialog, SIGNAL(sendroute()), this, SLOT(clientSendRoute()));
+    connect(topResultDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
     routeSaveDialog->show();
 }
 
@@ -133,6 +146,7 @@ void MainWindow::on_pushButtonAccelerate_clicked()
     if(!accstart)
         accstart = new accelerationstart(this);
     connect(accstart, SIGNAL(sendresult(QString, double)), this, SLOT(clientSendResult(QString, double)));
+    connect(topResultDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
     accstart->show();
 }
 
@@ -141,6 +155,12 @@ void MainWindow::on_pushButtonAccelerate_clicked()
   */
 void MainWindow::on_pushButtonResults_clicked()
 {
+    if (!topResultDialog)
+        topResultDialog = new TopResultDialog;
+    clientRequestCategoryList();
+    connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
+    connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
+    connect(topResultDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
     topResultDialog->show();
 }
 
@@ -193,7 +213,7 @@ void MainWindow::setListViewTopList(QString category, int size)
 }
 
 /**
-  * This function
+  * This function register user to server.
   */
 void MainWindow::clientRegUserToServer()
 {
@@ -201,7 +221,7 @@ void MainWindow::clientRegUserToServer()
 }
 
 /**
-  * This function performs login to server
+  * This function performs login to server.
   */
 void MainWindow::clientUserLogin()
 {
@@ -209,7 +229,7 @@ void MainWindow::clientUserLogin()
 }
 
 /**
-  * This function send route to server
+  * This function send route data to server.
   */
 void MainWindow::clientSendRoute()
 {
@@ -217,7 +237,7 @@ void MainWindow::clientSendRoute()
 }
 
 /**
-  * This function send acceleration data to server
+  * This function send acceleration data to server.
   */
 void MainWindow::clientSendResult(QString category, double result)
 {
@@ -227,3 +247,24 @@ void MainWindow::clientSendResult(QString category, double result)
         httpClient->sendResultXml(category, result);
     }
 }
+/**
+  * This slot function called when ever dialog finished.
+  */
+void MainWindow::killDialog()
+{
+    if(topResultDialog)
+    {
+        delete topResultDialog;
+        topResultDialog = NULL;
+    }
+    else if(routeSaveDialog)
+    {
+        delete routeSaveDialog;
+        routeSaveDialog = NULL;
+    }
+    else if(accstart)
+    {
+        delete accstart;
+        accstart = NULL;
+    }
+}
index 87c603d..7619e24 100644 (file)
@@ -40,7 +40,7 @@ public:
 
     //CreditsDialog *creditsDialog;
     RouteSaveDialog *routeSaveDialog;
-    RouteDialog *routeDialog;
+    //RouteDialog *routeDialog;
     WelcomeDialog *welcomeDialog;
     SettingsDialog *settingsDialog;
     accelerationstart* accstart;
@@ -70,6 +70,7 @@ private slots:
     void clientSendResult(QString category, double result);
     void setCategoryCompoBox();
     void showTop10();
+    void killDialog();
 
 };
 
index 38af4d2..e53db80 100644 (file)
@@ -77,6 +77,9 @@ ResultDialog::ResultDialog(QWidget *parent) :
     {
         ui->pushButtonSend->setEnabled(false);
     }
+
+    //Clear info label
+    ui->labelInfoToUser->setText("");
 }
 
 /**
index 6bd68bb..444fab4 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>800</width>
-    <height>480</height>
+    <height>380</height>
    </rect>
   </property>
   <property name="windowTitle">
     </rect>
    </property>
    <property name="text">
-    <string/>
+    <string>User info label</string>
    </property>
   </widget>
  </widget>
index 8a0d539..64d1da5 100644 (file)
@@ -27,6 +27,7 @@ class RouteSaveDialog : public QDialog {
 public:
     RouteSaveDialog(QWidget *parent = 0);
     ~RouteSaveDialog();
+    RouteDialog *routeDialog;
 
 protected:
     void changeEvent(QEvent *e);
@@ -37,7 +38,6 @@ private:
     QTimer *timerRoutePicture;
     GPSData *gpsData;
     Maemo5Location *location;
-    RouteDialog *routeDialog;
     QString gpsSpeed;
     QPixmap *pixmapRouteStop;
     QPixmap *pixmapRouteStart;
index 25d18ed..5edc2ff 100644 (file)
     <pixmap resource="graphics.qrc">:/new/prefix1/Graphics/sf_2.png</pixmap>
    </property>
   </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>200</x>
+     <y>320</y>
+     <width>501</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>User info label</string>
+   </property>
+  </widget>
  </widget>
  <resources>
   <include location="graphics.qrc"/>
index b7cfdd4..fafff58 100644 (file)
@@ -24,6 +24,10 @@ TopResultDialog::TopResultDialog(QWidget *parent) :
     //Button settings
     ui->buttonTopRefresh->setAutoFillBackground(true);
     ui->buttonTopRefresh->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+
+    //Clear labels
+    ui->labelInfoToUser->setText("");
+    ui->labelTopList->setText("");
 }
 
 TopResultDialog::~TopResultDialog()
index 01d976c..9089f32 100644 (file)
   <widget class="QLabel" name="labelTopList">
    <property name="geometry">
     <rect>
-     <x>150</x>
+     <x>120</x>
      <y>70</y>
-     <width>471</width>
+     <width>521</width>
      <height>251</height>
     </rect>
    </property>
    <property name="font">
     <font>
-     <pointsize>9</pointsize>
+     <pointsize>11</pointsize>
     </font>
    </property>
    <property name="text">
-    <string/>
+    <string>Top list label</string>
    </property>
    <property name="alignment">
     <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
     </rect>
    </property>
    <property name="text">
-    <string/>
+    <string>Info label</string>
    </property>
   </widget>
   <widget class="QLabel" name="label">