2 * Mainwindow for speedFreak project
4 * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
5 * @author Toni Jussila <toni.jussila@fudeco.com>
6 * @copyright (c) 2010 Speed Freak team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 #include "mainwindow.h"
11 #include "ui_mainwindow.h"
13 #include <QDesktopServices>
18 MainWindow::MainWindow(QWidget *parent) :
20 ui(new Ui::MainWindow)
24 QCoreApplication::setOrganizationName("Fudeco Oy");
25 QCoreApplication::setOrganizationDomain("fudeco.com");
26 QCoreApplication::setApplicationName("Speed Freak");
28 routeDialog = new RouteDialog;
29 creditsDialog = new CreditsDialog;
30 routeSaveDialog = new RouteSaveDialog;
31 settingsDialog = new SettingsDialog;
32 connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(regUserToServer()));
33 connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(userLogin()));
34 topResultDialog = new TopResultDialog;
35 connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
36 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()));
43 welcomeDialog = new WelcomeDialog;
44 welcomeDialog->show();
47 ui->pushButtonAccelerate->setAutoFillBackground(true);
48 ui->pushButtonAccelerate->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
49 ui->pushButtonRoute->setAutoFillBackground(true);
50 ui->pushButtonRoute->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
51 ui->pushButtonResults->setAutoFillBackground(true);
52 ui->pushButtonResults->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
53 ui->pushButtonSettings->setAutoFillBackground(true);
54 ui->pushButtonSettings->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
55 ui->pushButtonWWW->setAutoFillBackground(true);
56 ui->pushButtonWWW->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
57 ui->pushButtonCredits->setAutoFillBackground(true);
58 ui->pushButtonCredits->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
61 MainWindow::~MainWindow()
64 delete routeSaveDialog;
71 void MainWindow::changeEvent(QEvent *e)
73 QMainWindow::changeEvent(e);
75 case QEvent::LanguageChange:
76 ui->retranslateUi(this);
83 void MainWindow::on_pushButtonWWW_clicked()
85 QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/"));
88 void MainWindow::on_pushButtonCredits_clicked()
90 creditsDialog->show();
93 void MainWindow::on_pushButtonRoute_clicked()
95 routeSaveDialog->show();
98 void MainWindow::on_pushButtonSettings_clicked()
100 settingsDialog->show();
103 void MainWindow::on_pushButtonAccelerate_clicked()
106 accstart = new accelerationstart(this);
110 void MainWindow::on_pushButtonResults_clicked()
112 topResultDialog->show();
116 *This slot function is called when ever mytTopResultDialog emits signal refreshCategoryList button clicked.
118 void MainWindow::clientRequestCategoryList()
120 httpClient->requestCategories();
124 *This slot function is called when ever mytTopResultDialog emits signal refreshTopList button clicked.
126 void MainWindow::clientRequestTopList(int index)
128 qDebug() << "index" << index << httpClient->myXmlreader->myCategoryList->getRecentCategory(index);
129 QString limit = QString::number(topResultDialog->getLimitNr());
130 httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit);
134 *This function is used to set items to category combobox. Top-tab view.
137 void MainWindow::setCategoryCompoBox()
139 qDebug() << "_setCategoryCompoBox";
140 topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList());
144 *This function prcesses UI updating after a new top10List has been received.
145 *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged.
147 void MainWindow::showTop10()
149 qDebug() << "_showTop10";
150 int ind = topResultDialog->getRecentCategoryIndex();
151 setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr());
155 *This function is used to set items to labelTopList. Top-tab view.
157 *@param Size, number of results.
159 void MainWindow::setListViewTopList(QString category, int size)
161 qDebug() << "_setListViewTopList" << category;
163 topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size));
164 topResultDialog->showTopList(topList);
167 void MainWindow::regUserToServer()
169 httpClient->requestRegistration();
172 void MainWindow::userLogin()
174 httpClient->checkLogin();