X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=blobdiff_plain;f=Client%2Fmainwindow.cpp;h=0b78399137b923beab3a93355d28d1ec0fcaba28;hp=6e5ea660dce23cfedc342ef299fdfffc5d47a8ff;hb=20d58825bd115adb8e56401a1055ff6d2a3c7850;hpb=2902e3c96a34377d252d222ff60ce11f46556882 diff --git a/Client/mainwindow.cpp b/Client/mainwindow.cpp index 6e5ea66..0b78399 100644 --- a/Client/mainwindow.cpp +++ b/Client/mainwindow.cpp @@ -1,7 +1,8 @@ /* * Mainwindow for speedFreak project * - * @author Rikhard Kuutti + * @author Rikhard Kuutti + * @author Toni Jussila * @copyright (c) 2010 Speed Freak team * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ @@ -11,6 +12,8 @@ #include #include +#include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -18,9 +21,36 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); - creditsDialog = new CreditsDialog; + QCoreApplication::setOrganizationName("Fudeco Oy"); + QCoreApplication::setOrganizationDomain("fudeco.com"); + QCoreApplication::setApplicationName("Speed Freak"); + + routeDialog = new RouteDialog; + connect(routeDialog,SIGNAL(sendroute()),this,SLOT(clientSendRoute())); + routeSaveDialog = new RouteSaveDialog; + 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())); + + resultDialog = new ResultDialog; + + accstart = NULL; + + creditsDialog = new CreditsDialog; + + welcomeDialog = new WelcomeDialog; + welcomeDialog->show(); + //Button settings ui->pushButtonAccelerate->setAutoFillBackground(true); ui->pushButtonAccelerate->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)"); @@ -32,12 +62,18 @@ MainWindow::MainWindow(QWidget *parent) : ui->pushButtonSettings->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)"); ui->pushButtonWWW->setAutoFillBackground(true); ui->pushButtonWWW->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)"); + ui->pushButtonCredits->setAutoFillBackground(true); + ui->pushButtonCredits->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)"); } MainWindow::~MainWindow() { delete ui; delete routeSaveDialog; + delete routeDialog; + + if(accstart) + delete accstart; } void MainWindow::changeEvent(QEvent *e) @@ -52,17 +88,141 @@ void MainWindow::changeEvent(QEvent *e) } } +/** + * This slot function opens browser to project www page. + */ void MainWindow::on_pushButtonWWW_clicked() { QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/")); } +/** + * This slot function opens the credits dialog + */ void MainWindow::on_pushButtonCredits_clicked() { creditsDialog->show(); } +/** + * This slot function opens the route save dialog + */ void MainWindow::on_pushButtonRoute_clicked() { routeSaveDialog->show(); } + +/** + * This slot function opens the settings dialog + */ +void MainWindow::on_pushButtonSettings_clicked() +{ + settingsDialog->show(); +} + +/** + * This slot function opens the acceleration dialog + */ +void MainWindow::on_pushButtonAccelerate_clicked() +{ + if(!accstart) + accstart = new accelerationstart(this); + connect(accstart, SIGNAL(sendresult(QString, double)), this, SLOT(clientSendResult(QString, double))); + accstart->show(); +} + +/** + * This slot function opens the top results dialog + */ +void MainWindow::on_pushButtonResults_clicked() +{ + topResultDialog->show(); +} + +/** + *This slot function is called when ever mytTopResultDialog emits signal refreshCategoryList button clicked. + */ +void MainWindow::clientRequestCategoryList() +{ + httpClient->requestCategories(); +} + +/** + *This slot function is called when ever mytTopResultDialog emits signal refreshTopList button clicked. + */ +void MainWindow::clientRequestTopList(int index) +{ + QString limit = QString::number(topResultDialog->getLimitNr()); + httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit); +} + +/** + *This function is used to set items to category combobox. Top-tab view. + *@param + */ +void MainWindow::setCategoryCompoBox() +{ + topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList()); +} + +/** + *This function prcesses UI updating after a new top10List has been received. + *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged. + */ +void MainWindow::showTop10() +{ + int ind = topResultDialog->getRecentCategoryIndex(); + setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr()); +} + +/** + *This function is used to set items to labelTopList. Top-tab view. + *@param Category + *@param Size, number of results. + */ +void MainWindow::setListViewTopList(QString category, int size) +{ + QString topList; + topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size)); + topResultDialog->showTopList(topList); +} + +void MainWindow::clientRegUserToServer() +{ + httpClient->requestRegistration(); +} + +/** + * This function performs login to server + */ +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(QString category, double result) +{ + /*QMessageBox msgBox; + msgBox.setWindowTitle("client send result!"); + msgBox.setText("client send result!"); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.exec();*/ + + qDebug() << "__clientSendResult"; + if(accstart) { + qDebug() << "_clientSendResult, calling server"; + httpClient->sendResultXml(category, result); + //httpClient->sendResultXml(accstart->getMeasureCategory(), resultDialog->getResult()); + } +}