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 creditsDialog = new CreditsDialog;
29 routeSaveDialog = new RouteSaveDialog;
30 settingsDialog = new SettingsDialog;
31 connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(regUserToServer()));
32 connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(userLogin()));
33 topResultDialog = new TopResultDialog;
34 connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
35 connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
38 httpClient = new HttpClient(this);
39 connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
40 connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));
42 welcomeDialog = new WelcomeDialog;
43 welcomeDialog->show();
46 ui->pushButtonAccelerate->setAutoFillBackground(true);
47 ui->pushButtonAccelerate->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
48 ui->pushButtonRoute->setAutoFillBackground(true);
49 ui->pushButtonRoute->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
50 ui->pushButtonResults->setAutoFillBackground(true);
51 ui->pushButtonResults->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
52 ui->pushButtonSettings->setAutoFillBackground(true);
53 ui->pushButtonSettings->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
54 ui->pushButtonWWW->setAutoFillBackground(true);
55 ui->pushButtonWWW->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
56 ui->pushButtonCredits->setAutoFillBackground(true);
57 ui->pushButtonCredits->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
60 MainWindow::~MainWindow()
63 delete routeSaveDialog;
69 void MainWindow::changeEvent(QEvent *e)
71 QMainWindow::changeEvent(e);
73 case QEvent::LanguageChange:
74 ui->retranslateUi(this);
81 void MainWindow::on_pushButtonWWW_clicked()
83 QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/"));
86 void MainWindow::on_pushButtonCredits_clicked()
88 creditsDialog->show();
91 void MainWindow::on_pushButtonRoute_clicked()
93 routeSaveDialog->show();
96 void MainWindow::on_pushButtonSettings_clicked()
98 settingsDialog->show();
101 void MainWindow::on_pushButtonAccelerate_clicked()
104 accstart = new accelerationstart(this);
108 void MainWindow::on_pushButtonResults_clicked()
110 topResultDialog->show();
114 *This slot function is called when ever mytTopResultDialog emits signal refreshCategoryList button clicked.
116 void MainWindow::clientRequestCategoryList()
118 httpClient->requestCategories();
122 *This slot function is called when ever mytTopResultDialog emits signal refreshTopList button clicked.
124 void MainWindow::clientRequestTopList(int index)
126 qDebug() << "index" << index << httpClient->myXmlreader->myCategoryList->getRecentCategory(index);
127 QString limit = QString::number(topResultDialog->getLimitNr());
128 httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit);
132 *This function is used to set items to category combobox. Top-tab view.
135 void MainWindow::setCategoryCompoBox()
137 qDebug() << "_setCategoryCompoBox";
138 topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList());
142 *This function prcesses UI updating after a new top10List has been received.
143 *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged.
145 void MainWindow::showTop10()
147 qDebug() << "_showTop10";
148 int ind = topResultDialog->getRecentCategoryIndex();
149 setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr());
153 *This function is used to set items to labelTopList. Top-tab view.
155 *@param Size, number of results.
157 void MainWindow::setListViewTopList(QString category, int size)
159 qDebug() << "_setListViewTopList" << category;
161 topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size));
162 topResultDialog->showTopList(topList);
165 void MainWindow::regUserToServer()
167 httpClient->requestRegistration();
170 void MainWindow::userLogin()
172 httpClient->checkLogin();