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");
27 creditsDialog = new CreditsDialog;
28 routeSaveDialog = new RouteSaveDialog;
29 settingsDialog = new SettingsDialog;
30 connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(regUserToServer()));
31 connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(userLogin()));
32 topResultDialog = new TopResultDialog;
33 connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
34 connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
37 httpClient = new HttpClient(this);
38 connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
39 connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));
41 welcomeDialog = new WelcomeDialog;
42 welcomeDialog->show();
45 MainWindow::~MainWindow()
49 delete routeSaveDialog;
55 void MainWindow::changeEvent(QEvent *e)
57 QMainWindow::changeEvent(e);
59 case QEvent::LanguageChange:
60 ui->retranslateUi(this);
67 void MainWindow::on_pushButtonWWW_clicked()
69 QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/"));
72 void MainWindow::on_pushButtonCredits_clicked()
74 creditsDialog->show();
77 void MainWindow::on_pushButtonRoute_clicked()
79 routeSaveDialog->show();
82 void MainWindow::on_pushButtonSettings_clicked()
84 settingsDialog->show();
87 void MainWindow::on_pushButtonAccelerate_clicked()
90 accstart = new accelerationstart(this);
94 void MainWindow::on_pushButtonResults_clicked()
96 topResultDialog->show();
100 *This slot function is called when ever mytTopResultDialog emits signal refreshCategoryList button clicked.
102 void MainWindow::clientRequestCategoryList()
104 httpClient->requestCategories();
108 *This slot function is called when ever mytTopResultDialog emits signal refreshTopList button clicked.
110 void MainWindow::clientRequestTopList(int index)
112 qDebug() << "index" << index << httpClient->myXmlreader->myCategoryList->getRecentCategory(index);
113 QString limit = QString::number(topResultDialog->getLimitNr());
114 httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit);
118 *This function is used to set items to category combobox. Top-tab view.
121 void MainWindow::setCategoryCompoBox()
123 qDebug() << "_setCategoryCompoBox";
124 topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList());
128 *This function prcesses UI updating after a new top10List has been received.
129 *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged.
131 void MainWindow::showTop10()
133 qDebug() << "_showTop10";
134 int ind = topResultDialog->getRecentCategoryIndex();
135 setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr());
139 *This function is used to set items to labelTopList. Top-tab view.
141 *@param Size, number of results.
143 void MainWindow::setListViewTopList(QString category, int size)
145 qDebug() << "_setListViewTopList" << category;
147 topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size));
148 topResultDialog->showTopList(topList);
151 void MainWindow::regUserToServer()
153 httpClient->requestRegistration();
156 void MainWindow::userLogin()
158 httpClient->checkLogin();