2 * Mainwindow for speedFreak project
4 * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
5 * @copyright (c) 2010 Speed Freak team
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 #include "mainwindow.h"
10 #include "ui_mainwindow.h"
12 #include <QDesktopServices>
17 MainWindow::MainWindow(QWidget *parent) :
19 ui(new Ui::MainWindow)
23 QCoreApplication::setOrganizationName("Fudeco Oy");
24 QCoreApplication::setOrganizationDomain("fudeco.com");
25 QCoreApplication::setApplicationName("Speed Freak");
29 creditsDialog = new CreditsDialog;
30 routeSaveDialog = new RouteSaveDialog;
31 routeDialog = new RouteDialog;
32 connect(routeDialog,SIGNAL(sendroute()),this,SLOT(clientSendRoute()));
33 settingsDialog = new SettingsDialog;
34 connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(clientRegUserToServer()));
35 connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(clientUserLogin()));
36 topResultDialog = new TopResultDialog;
37 connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
38 connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
39 httpClient = new HttpClient(this);
40 connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
41 connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));
42 resultDialog = new ResultDialog;
43 connect(resultDialog, SIGNAL(sendResult(double)), this, SLOT(clientSendResult(double)));
45 welcomeDialog = new WelcomeDialog;
46 welcomeDialog->show();
49 MainWindow::~MainWindow()
53 delete routeSaveDialog;
59 void MainWindow::changeEvent(QEvent *e)
61 QMainWindow::changeEvent(e);
63 case QEvent::LanguageChange:
64 ui->retranslateUi(this);
71 void MainWindow::on_pushButtonWWW_clicked()
73 QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/"));
76 void MainWindow::on_pushButtonCredits_clicked()
78 creditsDialog->show();
81 void MainWindow::on_pushButtonRoute_clicked()
83 routeSaveDialog->show();
86 void MainWindow::on_pushButtonSettings_clicked()
88 settingsDialog->show();
91 void MainWindow::on_pushButtonAccelerate_clicked()
94 accstart = new accelerationstart(this);
98 void MainWindow::on_pushButtonResults_clicked()
100 topResultDialog->show();
104 *This slot function is called when ever mytTopResultDialog emits signal refreshCategoryList button clicked.
106 void MainWindow::clientRequestCategoryList()
108 httpClient->requestCategories();
112 *This slot function is called when ever mytTopResultDialog emits signal refreshTopList button clicked.
114 void MainWindow::clientRequestTopList(int index)
116 QString limit = QString::number(topResultDialog->getLimitNr());
117 httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit);
121 *This function is used to set items to category combobox. Top-tab view.
124 void MainWindow::setCategoryCompoBox()
126 topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList());
130 *This function prcesses UI updating after a new top10List has been received.
131 *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged.
133 void MainWindow::showTop10()
135 int ind = topResultDialog->getRecentCategoryIndex();
136 setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr());
140 *This function is used to set items to labelTopList. Top-tab view.
142 *@param Size, number of results.
144 void MainWindow::setListViewTopList(QString category, int size)
147 topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size));
148 topResultDialog->showTopList(topList);
151 void MainWindow::clientRegUserToServer()
153 httpClient->requestRegistration();
156 void MainWindow::clientUserLogin()
158 httpClient->checkLogin();
161 void MainWindow::clientSendRoute()
163 httpClient->sendRouteXml();
166 void MainWindow::clientSendResult(double result)
169 httpClient->sendResultXml(accstart->getMeasureCategory(), result);