Youtube video and text (draft).
[speedfreak] / Client / mainwindow.cpp
index cbe7846..8dbfc79 100644 (file)
@@ -26,20 +26,29 @@ MainWindow::MainWindow(QWidget *parent) :
     QCoreApplication::setApplicationName("Speed Freak");
 
     routeDialog = new RouteDialog;
-    creditsDialog = new CreditsDialog;
+    connect(routeDialog,SIGNAL(sendroute()),this,SLOT(clientSendRoute()));
+
     routeSaveDialog = new RouteSaveDialog;
+
     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()), this, SLOT(clientSendResult()));
+
+    accstart = NULL;
+
+    creditsDialog = new CreditsDialog;
+
     welcomeDialog = new WelcomeDialog;
     welcomeDialog->show();
 
@@ -143,7 +152,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);
 }
@@ -154,7 +162,6 @@ void MainWindow::clientRequestTopList(int index)
   */
 void MainWindow::setCategoryCompoBox()
 {
-    qDebug() << "_setCategoryCompoBox";
     topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList());
 }
 
@@ -164,7 +171,6 @@ void MainWindow::setCategoryCompoBox()
   */
 void MainWindow::showTop10()
 {
-    qDebug() << "_showTop10";
     int ind = topResultDialog->getRecentCategoryIndex();
     setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr());
 }
@@ -176,16 +182,12 @@ 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);
 }
 
-/**
-  * This function performs registration to server
-  */
-void MainWindow::regUserToServer()
+void MainWindow::clientRegUserToServer()
 {
     httpClient->requestRegistration();
 }
@@ -193,7 +195,27 @@ void MainWindow::regUserToServer()
 /**
   * This function performs login to server
   */
-void MainWindow::userLogin()
+void MainWindow::clientUserLogin()
 {
     httpClient->checkLogin();
 }
+
+/**
+  * This function send route to server
+  */
+void MainWindow::clientSendRoute()
+{
+    httpClient->sendRouteXml();
+}
+
+/**
+  * This function send acceleration data to server
+  */
+void MainWindow::clientSendResult()
+{
+    qDebug() << "_clientSendResult";
+    if(accstart) {
+        qDebug() << "_clientSendResult, calling server";
+        httpClient->sendResultXml(accstart->getMeasureCategory(), resultDialog->getResult());
+    }
+}