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 routeDialog = new RouteDialog;
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 MainWindow::~MainWindow()
50 delete routeSaveDialog;
57 void MainWindow::changeEvent(QEvent *e)
59 QMainWindow::changeEvent(e);
61 case QEvent::LanguageChange:
62 ui->retranslateUi(this);
69 void MainWindow::on_pushButtonWWW_clicked()
71 QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/"));
74 void MainWindow::on_pushButtonCredits_clicked()
76 creditsDialog->show();
79 void MainWindow::on_pushButtonRoute_clicked()
81 routeSaveDialog->show();
84 void MainWindow::on_pushButtonSettings_clicked()
86 settingsDialog->show();
89 void MainWindow::on_pushButtonAccelerate_clicked()
92 accstart = new accelerationstart(this);
96 void MainWindow::on_pushButtonResults_clicked()
98 topResultDialog->show();
102 *This slot function is called when ever mytTopResultDialog emits signal refreshCategoryList button clicked.
104 void MainWindow::clientRequestCategoryList()
106 httpClient->requestCategories();
110 *This slot function is called when ever mytTopResultDialog emits signal refreshTopList button clicked.
112 void MainWindow::clientRequestTopList(int index)
114 qDebug() << "index" << index << httpClient->myXmlreader->myCategoryList->getRecentCategory(index);
115 QString limit = QString::number(topResultDialog->getLimitNr());
116 httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit);
120 *This function is used to set items to category combobox. Top-tab view.
123 void MainWindow::setCategoryCompoBox()
125 qDebug() << "_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 qDebug() << "_showTop10";
136 int ind = topResultDialog->getRecentCategoryIndex();
137 setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr());
141 *This function is used to set items to labelTopList. Top-tab view.
143 *@param Size, number of results.
145 void MainWindow::setListViewTopList(QString category, int size)
147 qDebug() << "_setListViewTopList" << category;
149 topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size));
150 topResultDialog->showTopList(topList);
153 void MainWindow::regUserToServer()
155 httpClient->requestRegistration();
158 void MainWindow::userLogin()
160 httpClient->checkLogin();