From: Tiina Kivilinna-Korhola Date: Wed, 31 Mar 2010 10:02:04 +0000 (+0300) Subject: More connecting client-server functionality to GUI. X-Git-Tag: v0.2-RC1~15^2~1^2 X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=commitdiff_plain;h=9de94ffc9dac2ad13fda5703e58553737e1a0d42 More connecting client-server functionality to GUI. --- diff --git a/Client/accelerationstart.cpp b/Client/accelerationstart.cpp index 3da0070..2592009 100644 --- a/Client/accelerationstart.cpp +++ b/Client/accelerationstart.cpp @@ -66,10 +66,23 @@ void accelerationstart::on_buttonStart_clicked() void accelerationstart::on_categorComboBox_currentIndexChanged( int index ) { stopMeasureSpeed = 0; - if( index == 1 ) - stopMeasureSpeed = 20; - else if( index == 2 ) + if( index == 1 ) { + stopMeasureSpeed = 10; + measureCategory = "acceleration-0-10"; + } + else if( index == 2 ) { stopMeasureSpeed = 40; - else if( index == 3 ) + measureCategory = "acceleration-0-40"; + } + else if( index == 3 ) { stopMeasureSpeed = 100; + measureCategory = "acceleration-0-100"; + } +} + + +QString accelerationstart::getMeasureCategory() +{ + return measureCategory; } + diff --git a/Client/accelerationstart.h b/Client/accelerationstart.h index ecd2406..2ac1b92 100644 --- a/Client/accelerationstart.h +++ b/Client/accelerationstart.h @@ -13,6 +13,7 @@ class accelerationstart : public QDialog { public: accelerationstart(QWidget *parent = 0); ~accelerationstart(); + QString getMeasureCategory(); protected: void changeEvent(QEvent *e); @@ -21,6 +22,7 @@ private: Ui::accelerationstart *ui; AccRealTimeDialog* accRealTimeDialog; double stopMeasureSpeed; + QString measureCategory; private slots: void on_categorComboBox_currentIndexChanged(int index); diff --git a/Client/categorylist.cpp b/Client/categorylist.cpp index f15fde0..5d86f76 100644 --- a/Client/categorylist.cpp +++ b/Client/categorylist.cpp @@ -137,6 +137,7 @@ void CategoryList::clearCats() *This function is used to get items to top list of the category that is chosen from combobox. *@param QString category *@param int size + *@todo Now there is only one (the latest top10List). Later picking up the requested category. */ QString CategoryList::getTopList( QString category, int size) { diff --git a/Client/httpclient.cpp b/Client/httpclient.cpp index 8cc9a79..69f932e 100644 --- a/Client/httpclient.cpp +++ b/Client/httpclient.cpp @@ -49,7 +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"); + myMainw->settingsDialog->setLabelInfoToUser("Reguesting registration from server"); regbuffer->close(); } @@ -80,7 +80,7 @@ void HttpClient::sendResultXml(QString category, double result) 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"); + myMainw->resultDialog->setLabelInfoToUser("Sending result to server"); xmlbuffer->close(); } @@ -113,7 +113,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->setLabelInfoToUser("Sending route to server"); + myMainw->routeDialog->setLabelInfoToUser("Sending route to server"); file.close(); } @@ -141,7 +141,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"); + myMainw->topResultDialog->setLabelInfoToUser("Reguesting top10 list from server"); } @@ -165,7 +165,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"); + myMainw->topResultDialog->setLabelInfoToUser("Reguesting categories from server"); } @@ -189,7 +189,7 @@ 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"); + myMainw->settingsDialog->setLabelInfoToUser("Checking login validity from server"); } @@ -200,7 +200,7 @@ void HttpClient::ackOfResult() { qDebug() << "_ackOfResult"; - //myMainw->setLabelInfoToUser(""); + myMainw->resultDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); @@ -208,11 +208,11 @@ void HttpClient::ackOfResult() errorcode = reply->error(); if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); - //QMessageBox::about(myMainw, "Server reply to result sending ",reply->errorString()); + QMessageBox::about(myMainw->resultDialog, "Server reply to result sending ",reply->errorString()); } else { qDebug() << "errorcode:" << errorcode << reply->errorString(); - //QMessageBox::about(myMainw, "Server reply to result sending", "Result received " + reply->readAll()); + //QMessageBox::about(myMainw->resultDialog, "Server reply to result sending", "Result received " + reply->readAll()); } } @@ -223,7 +223,7 @@ void HttpClient::ackOfRoute() { qDebug() << "_ackOfRoute"; - //myMainw->setLabelInfoToUser(""); + myMainw->routeDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); @@ -231,7 +231,7 @@ void HttpClient::ackOfRoute() errorcode = reply->error(); if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); - //QMessageBox::about(myMainw, "Server reply to route sending ",reply->errorString()); + QMessageBox::about(myMainw->routeDialog, "Server reply to route sending ",reply->errorString()); } else { qDebug() << "errorcode:" << errorcode << reply->errorString(); @@ -247,7 +247,7 @@ void HttpClient::ackOfRegistration() { qDebug() << "_ackOfRegistration"; - //myMainw->setLabelInfoToUser(""); + myMainw->settingsDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); @@ -255,11 +255,11 @@ void HttpClient::ackOfRegistration() errorcode = reply->error(); if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); - //QMessageBox::about(myMainw, "Server reply to registration",reply->readAll()); + QMessageBox::about(myMainw->settingsDialog, "Server reply to registration",reply->readAll()); } else { qDebug() << "errorcode=0" << errorcode << reply->errorString(); - //QMessageBox::about(myMainw, "Server reply to registration", "User registration " + reply->readAll()); + //QMessageBox::about(myMainw->settingsDialog, "Server reply to registration", "User registration " + reply->readAll()); } } @@ -271,7 +271,7 @@ void HttpClient::ackOfCategories() { qDebug() << "_ackOfCategories"; - //myMainw->setLabelInfoToUser(""); + myMainw->topResultDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); myXmlreader->xmlReadCategories(reply); @@ -280,11 +280,11 @@ void HttpClient::ackOfCategories() errorcode = reply->error(); if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); - //QMessageBox::about(myMainw, "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, "Server reply to requesting categories ", "OK"); + //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK"); } } @@ -296,7 +296,7 @@ void HttpClient::ackOfLogin() { qDebug() << "_ackOffLogin"; - //myMainw->setLabelInfoToUser(""); + myMainw->settingsDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); @@ -304,12 +304,14 @@ void HttpClient::ackOfLogin() errorcode = reply->error(); if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); - //QMessageBox::about(myMainw, "Server does not recognize your username. Please registrate.",reply->errorString()); + QMessageBox::about(myMainw->settingsDialog, "Server does not recognize your username. Please registrate.",reply->errorString()); } else { qDebug() << "errorcode:" << errorcode << reply->errorString(); - //QMessageBox::about(myMainw, "Server reply to login", "User login " + reply->readAll()); + //QMessageBox::about(myMainw->settingsDialog, "Server reply to login", "User login " + reply->readAll()); } + + myMainw->settingsDialog->close(); } @@ -352,11 +354,11 @@ void HttpClient::ackOfToplist() errorcode = reply->error(); if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); - //QMessageBox::about(myMainw, "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(); - //QMessageBox::about(myMainw, "Server reply to requesting top 10 list", "OK " + reply->readAll()); + //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list", "OK " + reply->readAll()); } } diff --git a/Client/mainwindow.cpp b/Client/mainwindow.cpp index d4df9c8..1844859 100644 --- a/Client/mainwindow.cpp +++ b/Client/mainwindow.cpp @@ -24,19 +24,23 @@ MainWindow::MainWindow(QWidget *parent) : QCoreApplication::setOrganizationDomain("fudeco.com"); QCoreApplication::setApplicationName("Speed Freak"); + accstart = NULL; + creditsDialog = new CreditsDialog; routeSaveDialog = new RouteSaveDialog; + routeDialog = new RouteDialog; + connect(routeDialog,SIGNAL(sendroute()),this,SLOT(clientSendRoute())); settingsDialog = new SettingsDialog; - connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(regUserToServer())); - connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(userLogin())); + 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))); - accstart = NULL; - httpClient = new HttpClient(this); connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox())); connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10())); + resultDialog = new ResultDialog; + connect(resultDialog, SIGNAL(sendResult(double)), this, SLOT(clientSendResult(double))); welcomeDialog = new WelcomeDialog; welcomeDialog->show(); @@ -109,7 +113,6 @@ void MainWindow::clientRequestCategoryList() */ void MainWindow::clientRequestTopList(int index) { - qDebug() << "index" << index << httpClient->myXmlreader->myCategoryList->getRecentCategory(index); QString limit = QString::number(topResultDialog->getLimitNr()); httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit); } @@ -120,7 +123,6 @@ void MainWindow::clientRequestTopList(int index) */ void MainWindow::setCategoryCompoBox() { - qDebug() << "_setCategoryCompoBox"; topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList()); } @@ -130,7 +132,6 @@ void MainWindow::setCategoryCompoBox() */ void MainWindow::showTop10() { - qDebug() << "_showTop10"; int ind = topResultDialog->getRecentCategoryIndex(); setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr()); } @@ -142,18 +143,29 @@ void MainWindow::showTop10() */ void MainWindow::setListViewTopList(QString category, int size) { - qDebug() << "_setListViewTopList" << category; QString topList; topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size)); topResultDialog->showTopList(topList); } -void MainWindow::regUserToServer() +void MainWindow::clientRegUserToServer() { httpClient->requestRegistration(); } -void MainWindow::userLogin() +void MainWindow::clientUserLogin() { httpClient->checkLogin(); } + +void MainWindow::clientSendRoute() +{ + httpClient->sendRouteXml(); +} + +void MainWindow::clientSendResult(double result) +{ + if(accstart) { + httpClient->sendResultXml(accstart->getMeasureCategory(), result); + } +} diff --git a/Client/mainwindow.h b/Client/mainwindow.h index f05a62c..b4f1d27 100644 --- a/Client/mainwindow.h +++ b/Client/mainwindow.h @@ -16,11 +16,13 @@ #include #include "creditsdialog.h" #include "routesavedialog.h" +#include "routedialog.h" #include "welcomedialog.h" #include "settingsdialog.h" #include "accelerationstart.h" #include "topresultdialog.h" #include "httpclient.h" +#include "resultdialog.h" namespace Ui { class MainWindow; @@ -34,11 +36,13 @@ public: CreditsDialog *creditsDialog; RouteSaveDialog *routeSaveDialog; + RouteDialog *routeDialog; WelcomeDialog *welcomeDialog; SettingsDialog *settingsDialog; accelerationstart* accstart; TopResultDialog *topResultDialog; HttpClient *httpClient; + ResultDialog *resultDialog; protected: void changeEvent(QEvent *e); @@ -56,10 +60,12 @@ private slots: void on_pushButtonWWW_clicked(); void clientRequestCategoryList(); void clientRequestTopList(int index); + void clientSendRoute(); + void clientRegUserToServer(); + void clientUserLogin(); + void clientSendResult(double result); void setCategoryCompoBox(); void showTop10(); - void regUserToServer(); - void userLogin(); }; #endif // MAINWINDOW_H diff --git a/Client/resultdialog.cpp b/Client/resultdialog.cpp index 3c8c54e..8947482 100644 --- a/Client/resultdialog.cpp +++ b/Client/resultdialog.cpp @@ -706,3 +706,9 @@ int ResultDialog::getTargetChoice() } return targetChoice; } + +void ResultDialog::setLabelInfoToUser(QString infoText) +{ + this->ui->labelInfoToUser->setText(infoText); +} + diff --git a/Client/resultdialog.h b/Client/resultdialog.h index 6f19c38..e8828c7 100644 --- a/Client/resultdialog.h +++ b/Client/resultdialog.h @@ -24,9 +24,10 @@ public: void setEnd(int pValue); void setValue(int pSpeed, double pTime); + void setLabelInfoToUser(QString infoText); signals: - void sendresult(double result); + void sendresult(double); protected: void changeEvent(QEvent *e); diff --git a/Client/resultdialog.ui b/Client/resultdialog.ui index 7d63fe7..a41d21a 100644 --- a/Client/resultdialog.ui +++ b/Client/resultdialog.ui @@ -69,7 +69,7 @@ 510 - 280 + 310 131 71 @@ -175,6 +175,19 @@ New run + + + + 10 + 310 + 471 + 51 + + + + + + diff --git a/Client/routedialog.cpp b/Client/routedialog.cpp index 5a680aa..63de6e6 100644 --- a/Client/routedialog.cpp +++ b/Client/routedialog.cpp @@ -688,5 +688,10 @@ void RouteDialog::on_newPushButton_clicked() void RouteDialog::on_sendPushButton_clicked() { - // Send route points file to server + emit sendroute(); +} + +void RouteDialog::setLabelInfoToUser(QString infoText) +{ + this->ui->labelInfoToUser->setText(infoText); } diff --git a/Client/routedialog.h b/Client/routedialog.h index bea6150..708e74a 100644 --- a/Client/routedialog.h +++ b/Client/routedialog.h @@ -25,6 +25,10 @@ public: int getTop(); int getRight(); int getBottom(); + void setLabelInfoToUser(QString infoText); + +signals: + void sendroute(); protected: void changeEvent(QEvent *e); diff --git a/Client/routedialog.ui b/Client/routedialog.ui index 22e2049..1ee53ab 100644 --- a/Client/routedialog.ui +++ b/Client/routedialog.ui @@ -6,8 +6,8 @@ 0 0 - 634 - 300 + 800 + 480 @@ -65,6 +65,19 @@ TextLabel + + + + 10 + 310 + 521 + 51 + + + + + + diff --git a/Client/settingsdialog.cpp b/Client/settingsdialog.cpp index e19e4e6..b62335b 100644 --- a/Client/settingsdialog.cpp +++ b/Client/settingsdialog.cpp @@ -7,7 +7,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : { ui->setupUi(this); this->setWindowTitle("Settings"); - this->ui->regEMailLineEdit->setText("@meili.fi"); + this->ui->regEMailLineEdit->setText("@"); instructionsDialog = new InstructionsDialog; } @@ -48,7 +48,7 @@ void SettingsDialog::on_registratePushButton_clicked() emit sendregistration(); - close(); + //close(); //using close() hides popup-window which reports error from server } // Next 6 functions can be removed if Settingsdialog is implemented without @@ -92,7 +92,8 @@ void SettingsDialog::on_setUserPushButton_clicked() this->password = ui->setUserPasswordLineEdit->text(); emit userNameChanged(); - close(); + + //close(); //using close() hides popup-window which reports error from server } // Next 4 functions can be removed if Settingsdialog is implemented without @@ -117,3 +118,7 @@ QString SettingsDialog::getPassword() return this->password; } +void SettingsDialog::setLabelInfoToUser(QString infoText) +{ + this->ui->labelInfoToUser->setText(infoText); +} diff --git a/Client/settingsdialog.h b/Client/settingsdialog.h index 09e76f4..7e2096e 100644 --- a/Client/settingsdialog.h +++ b/Client/settingsdialog.h @@ -24,6 +24,7 @@ public: void setPassword(QString password); QString getUserName(); QString getPassword(); + void setLabelInfoToUser(QString infoText); signals: void sendregistration(); diff --git a/Client/settingsdialog.ui b/Client/settingsdialog.ui index cd151b6..0ce677d 100644 --- a/Client/settingsdialog.ui +++ b/Client/settingsdialog.ui @@ -16,9 +16,9 @@ - 280 - 300 - 241 + 520 + 310 + 221 51 @@ -47,9 +47,9 @@ - 550 - 240 - 191 + 520 + 220 + 221 51 @@ -78,9 +78,9 @@ - 550 - 120 - 191 + 520 + 60 + 221 51 @@ -88,12 +88,12 @@ Register - + 10 50 - 531 + 491 121 @@ -145,12 +145,12 @@ - + 10 210 - 531 + 491 81 @@ -188,6 +188,19 @@ + + + + 10 + 310 + 521 + 51 + + + + + + diff --git a/Client/topresultdialog.cpp b/Client/topresultdialog.cpp index ef4478b..245646f 100644 --- a/Client/topresultdialog.cpp +++ b/Client/topresultdialog.cpp @@ -36,11 +36,6 @@ void TopResultDialog::on_buttonTopRefresh_clicked() emit refreshCategoryList(); } -void TopResultDialog::on_pushButton_debclose_clicked() -{ - close(); -} - void TopResultDialog::setCompoBoxCategories(QStringList list) { ui->comboBoxTopCategory->addItems(list); @@ -71,3 +66,8 @@ void TopResultDialog::on_comboBoxTopCategory_currentIndexChanged(int index) recentCategoryIndex = index; emit refreshTopList(index); } + +void TopResultDialog::setLabelInfoToUser(QString infoText) +{ + this->ui->labelInfoToUser->setText(infoText); +} diff --git a/Client/topresultdialog.h b/Client/topresultdialog.h index a46b916..8fad9e8 100644 --- a/Client/topresultdialog.h +++ b/Client/topresultdialog.h @@ -17,6 +17,7 @@ public: int getRecentCategoryIndex(); int getLimitNr(); void setLimitNr(int number); + void setLabelInfoToUser(QString infoText); protected: void changeEvent(QEvent *e); @@ -32,7 +33,6 @@ private: private slots: void on_comboBoxTopCategory_currentIndexChanged(int index); - void on_pushButton_debclose_clicked(); void on_buttonTopRefresh_clicked(); }; diff --git a/Client/topresultdialog.ui b/Client/topresultdialog.ui index 8a77ac7..79b110e 100644 --- a/Client/topresultdialog.ui +++ b/Client/topresultdialog.ui @@ -37,10 +37,10 @@ - 300 + 280 0 - 471 - 261 + 491 + 251 @@ -56,10 +56,10 @@ - 320 + 300 0 - 431 - 261 + 451 + 251 @@ -74,24 +74,11 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - 10 - 20 - 91 - 27 - - - - PushButtondebclose - - 10 - 210 + 200 221 51 @@ -110,12 +97,25 @@ 10 - 269 + 260 601 41 + + + + 10 + 310 + 521 + 51 + + + + + +