From: Toni Jussila Date: Fri, 16 Apr 2010 12:01:32 +0000 (+0300) Subject: Get category when top dialog started. X-Git-Tag: help~16 X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=commitdiff_plain;h=f7f140509f9767c1062c6dbcab5862353de86e1d Get category when top dialog started. --- diff --git a/Client/httpclient.cpp b/Client/httpclient.cpp index acda598..547f3b8 100644 --- a/Client/httpclient.cpp +++ b/Client/httpclient.cpp @@ -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(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(); diff --git a/Client/mainwindow.cpp b/Client/mainwindow.cpp index 8179fd7..4f32eee 100644 --- a/Client/mainwindow.cpp +++ b/Client/mainwindow.cpp @@ -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; + } +} diff --git a/Client/mainwindow.h b/Client/mainwindow.h index 87c603d..7619e24 100644 --- a/Client/mainwindow.h +++ b/Client/mainwindow.h @@ -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(); }; diff --git a/Client/resultdialog.cpp b/Client/resultdialog.cpp index 38af4d2..e53db80 100644 --- a/Client/resultdialog.cpp +++ b/Client/resultdialog.cpp @@ -77,6 +77,9 @@ ResultDialog::ResultDialog(QWidget *parent) : { ui->pushButtonSend->setEnabled(false); } + + //Clear info label + ui->labelInfoToUser->setText(""); } /** diff --git a/Client/resultdialog.ui b/Client/resultdialog.ui index 6bd68bb..444fab4 100644 --- a/Client/resultdialog.ui +++ b/Client/resultdialog.ui @@ -7,7 +7,7 @@ 0 0 800 - 480 + 380 @@ -185,7 +185,7 @@ - + User info label diff --git a/Client/routesavedialog.h b/Client/routesavedialog.h index 8a0d539..64d1da5 100644 --- a/Client/routesavedialog.h +++ b/Client/routesavedialog.h @@ -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; diff --git a/Client/routesavedialog.ui b/Client/routesavedialog.ui index 25d18ed..5edc2ff 100644 --- a/Client/routesavedialog.ui +++ b/Client/routesavedialog.ui @@ -182,6 +182,19 @@ :/new/prefix1/Graphics/sf_2.png + + + + 200 + 320 + 501 + 41 + + + + User info label + + diff --git a/Client/topresultdialog.cpp b/Client/topresultdialog.cpp index b7cfdd4..fafff58 100644 --- a/Client/topresultdialog.cpp +++ b/Client/topresultdialog.cpp @@ -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() diff --git a/Client/topresultdialog.ui b/Client/topresultdialog.ui index 01d976c..9089f32 100644 --- a/Client/topresultdialog.ui +++ b/Client/topresultdialog.ui @@ -47,19 +47,19 @@ - 150 + 120 70 - 471 + 521 251 - 9 + 11 - + Top list label Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -104,7 +104,7 @@ - + Info label