From: Toni Jussila Date: Thu, 22 Apr 2010 07:02:44 +0000 (+0300) Subject: Conflict fixed: mainwindow.cpp and httpclient.cpp X-Git-Tag: help~6 X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=commitdiff_plain;h=ac84b058f9433e99aee2f560ef4f4e634d6900f7 Conflict fixed: mainwindow.cpp and httpclient.cpp --- diff --git a/Client/categorylist.cpp b/Client/categorylist.cpp index 5d86f76..5ec3703 100644 --- a/Client/categorylist.cpp +++ b/Client/categorylist.cpp @@ -14,7 +14,7 @@ */ CategoryList::CategoryList() { - + qDebug() << "__CategoryList"; } /** @@ -22,6 +22,7 @@ CategoryList::CategoryList() */ CategoryList::~CategoryList() { + qDebug() << "__~CategoryList"; } /** @@ -30,7 +31,7 @@ CategoryList::~CategoryList() */ QStringList CategoryList::getCategoryList() { - qDebug() << "_getCategoryList" << realSizeOfCats; + qDebug() << "__getCategoryList" << realSizeOfCats; if(sizeOfCategoryList() != 0) { clearCategoryList(); diff --git a/Client/gpsdata.cpp b/Client/gpsdata.cpp index db0a6bc..eca9efb 100644 --- a/Client/gpsdata.cpp +++ b/Client/gpsdata.cpp @@ -7,12 +7,14 @@ */ #include "gpsdata.h" +#include /** *Default constructor of this class. */ GPSData::GPSData(Maemo5Location *maemo5location) { + qDebug() << "__GPSData"; location = maemo5location; connect(location,SIGNAL(agnss()),this,SLOT(agnss())); @@ -33,10 +35,16 @@ GPSData::GPSData(Maemo5Location *maemo5location) */ GPSData::~GPSData() { - delete location; - delete gpsDateTime; + qDebug() << "__~GPSData"; + location = NULL; + + if(gpsDateTime) + delete gpsDateTime; } +/** + * This function reset all variables + */ void GPSData::resetAll() { satellitesInUse = 0; diff --git a/Client/httpclient.cpp b/Client/httpclient.cpp index a71c104..12e681a 100644 --- a/Client/httpclient.cpp +++ b/Client/httpclient.cpp @@ -1,15 +1,25 @@ +/* + * Http client Connects application to server. + * + * @author Tiina Kivilinna-Korhola + * @author Olavi Pulkkinen + * @author Toni Jussila + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + */ + #include #include #include "httpclient.h" #include "mainwindow.h" - /** *@brief Constructor, connects object to GUI *@param Pointer to carmainwindow, which is temporarily used during development */ HttpClient::HttpClient(MainWindow *myCarw) { + qDebug() << "__HttpClient"; myMainw = myCarw; netManager = new QNetworkAccessManager(); myXmlwriter = new XmlWriter(); @@ -21,7 +31,7 @@ HttpClient::HttpClient(MainWindow *myCarw) */ HttpClient::~HttpClient() { - + qDebug() << "__~HttpClient" ; } /** @@ -49,7 +59,10 @@ void HttpClient::requestRegistration() currentDownload = netManager->post(request, ("xml=" + regbuffer->data())); connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRegistration())); //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError))); - myMainw->settingsDialog->setLabelInfoToUser("Reguesting registration from server"); + + //Indicating user + if(myMainw->settingsDialog) + myMainw->settingsDialog->setLabelInfoToUser("Reguesting registration from server"); regbuffer->close(); } @@ -82,7 +95,8 @@ void HttpClient::sendResultXml(QString category, double result) //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError))); //Indicating user - myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser("Sending result to server"); + if(myMainw->accstart->accRealTimeDialog->resultDialog) + myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser("Sending result to server"); xmlbuffer->close(); } @@ -115,7 +129,10 @@ void HttpClient::sendRouteXml() currentDownload = netManager->post(request, ("xml=" + file.readAll())); connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRoute())); //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError))); - myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser("Sending route to server"); + + //Indicating user + if(myMainw->routeSaveDialog->routeDialog) + myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser("Sending route to server"); file.close(); } @@ -143,9 +160,11 @@ void HttpClient::requestTopList(QString category, QString limit) currentDownload = netManager->post(request, ("data=" )); connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfToplist())); //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError))); - myMainw->topResultDialog->setLabelInfoToUser("Reguesting top10 list from server"); -} + //Indicating user + if(myMainw->topResultDialog) + myMainw->topResultDialog->setLabelInfoToUser("Reguesting top10 list from server"); +} /** *@brief Request categories list from the server. @@ -167,9 +186,11 @@ void HttpClient::requestCategories() currentDownload = netManager->post(request, ("data=" )); connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfCategories())); //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError))); - myMainw->topResultDialog->setLabelInfoToUser("Reguesting categories from server"); -} + //Indicating user + if(myMainw->topResultDialog) + myMainw->topResultDialog->setLabelInfoToUser("Reguesting categories from server"); +} /** *@brief Check that username and password exist on the server. @@ -191,9 +212,11 @@ void HttpClient::checkLogin() currentDownload = netManager->post(request, ("data=" )); connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfLogin())); //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError))); - myMainw->settingsDialog->setLabelInfoToUser("Checking login validity from server"); -} + //Indicating user + if(myMainw->settingsDialog) + myMainw->settingsDialog->setLabelInfoToUser("Checking login validity from server"); +} /** *@brief React to servers responce after result has been sent. @@ -203,7 +226,8 @@ void HttpClient::ackOfResult() qDebug() << "_ackOfResult"; //Indicating user - myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser(""); + if(myMainw->accstart->accRealTimeDialog->resultDialog) + myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); @@ -213,13 +237,21 @@ void HttpClient::ackOfResult() qDebug() << "errorcode:" << errorcode << reply->errorString(); //Indicating user - QMessageBox::about(myMainw->accstart->accRealTimeDialog->resultDialog, "Server reply to result sending ",reply->errorString()); + if(myMainw->accstart->accRealTimeDialog->resultDialog) + QMessageBox::about(myMainw->accstart->accRealTimeDialog->resultDialog, "Server reply to result sending ",reply->errorString()); + if(myMainw->accstart->accRealTimeDialog->resultDialog) + myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser("Error"); + if(myMainw->accstart->accRealTimeDialog->resultDialog) + myMainw->accstart->accRealTimeDialog->resultDialog->setSendServerButtonEnabled(); } else { qDebug() << "errorcode:" << errorcode << reply->errorString(); //Indicating user - QMessageBox::about(myMainw->accstart->accRealTimeDialog->resultDialog, "Server reply to result sending", "Result received " + reply->readAll()); + if(myMainw->accstart->accRealTimeDialog->resultDialog) + QMessageBox::about(myMainw->accstart->accRealTimeDialog->resultDialog, "Server reply to result sending", "Result received " + reply->readAll()); + if(myMainw->accstart->accRealTimeDialog->resultDialog) + myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser("Result received"); } } @@ -230,7 +262,8 @@ void HttpClient::ackOfRoute() { qDebug() << "_ackOfRoute"; - myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser(""); + if(myMainw->routeSaveDialog->routeDialog) + myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); @@ -238,11 +271,15 @@ void HttpClient::ackOfRoute() errorcode = reply->error(); if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); - QMessageBox::about(myMainw->routeSaveDialog->routeDialog, "Server reply to route sending ",reply->errorString()); + if(myMainw->routeSaveDialog->routeDialog) + QMessageBox::about(myMainw->routeSaveDialog->routeDialog, "Server reply to route sending ",reply->errorString()); + if(myMainw->routeSaveDialog->routeDialog) + myMainw->routeSaveDialog->routeDialog->setSendServerButtonEnabled(); } else { qDebug() << "errorcode:" << errorcode << reply->errorString(); - QMessageBox::about(myMainw, "Server reply to route sending", "Route received " + reply->readAll()); + if(myMainw->routeSaveDialog->routeDialog) + QMessageBox::about(myMainw->routeSaveDialog->routeDialog, "Server reply to route sending", "Route received " + reply->readAll()); } } @@ -254,7 +291,8 @@ void HttpClient::ackOfRegistration() { qDebug() << "_ackOfRegistration"; - myMainw->settingsDialog->setLabelInfoToUser(""); + if(myMainw->settingsDialog) + myMainw->settingsDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); @@ -262,15 +300,16 @@ void HttpClient::ackOfRegistration() errorcode = reply->error(); if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); - QMessageBox::about(myMainw->settingsDialog, "Server reply to registration",reply->readAll()); + if(myMainw->settingsDialog) + QMessageBox::about(myMainw->settingsDialog, "Server reply to registration",reply->readAll()); } else { qDebug() << "errorcode=0" << errorcode << reply->errorString(); - QMessageBox::about(myMainw->settingsDialog, "Server reply to registration", "User registration " + reply->readAll()); + if(myMainw->settingsDialog) + QMessageBox::about(myMainw->settingsDialog, "Server reply to registration", "User registration " + reply->readAll()); } } - /** *@brief React to servers responce after request for categories has been sent. */ @@ -278,7 +317,8 @@ void HttpClient::ackOfCategories() { qDebug() << "_ackOfCategories"; - myMainw->topResultDialog->setLabelInfoToUser(""); + if(myMainw->topResultDialog) + myMainw->topResultDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); myXmlreader->xmlReadCategories(reply); @@ -288,14 +328,17 @@ void HttpClient::ackOfCategories() if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories",reply->errorString()); + if(myMainw->topResultDialog) + myMainw->topResultDialog->setLabelInfoToUser("You're not logged! Please register or log in."); } else { qDebug() << "errorcode:" << errorcode << reply->errorString(); //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK"); + if(myMainw->topResultDialog) + myMainw->topResultDialog->setLabelInfoToUser(""); } } - /** *@brief React to servers responce after request of TopList in certain category has been sent. */ @@ -303,39 +346,44 @@ void HttpClient::ackOfLogin() { qDebug() << "_ackOffLogin"; - myMainw->settingsDialog->setLabelInfoToUser(""); + if(myMainw->settingsDialog) + myMainw->settingsDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); QNetworkReply::NetworkError errorcode; errorcode = reply->error(); - if(errorcode != 0) { + if(errorcode != 0) + { qDebug() << "errorcode:" << errorcode << reply->errorString(); - QMessageBox::about(myMainw->settingsDialog, "Server does not recognize your username. Please registrate.",reply->errorString()); - myMainw->settingsDialog->usernameOk(false); + if(myMainw->settingsDialog) + { + QMessageBox::about(myMainw->settingsDialog, "Server does not recognize your username. Please registrate.",reply->errorString()); + myMainw->settingsDialog->usernameOk(false); + } } - else { + else + { qDebug() << "errorcode:" << errorcode << reply->errorString(); - QMessageBox::about(myMainw->settingsDialog, "Server reply to login", "User login " + reply->readAll()); + if(myMainw->settingsDialog) + QMessageBox::about(myMainw->settingsDialog, "Server reply to login", "User login " + reply->readAll()); // here signal emit to mainwindow for username setting to main panel emit loginOK(); - myMainw->settingsDialog->usernameOk(true); - myMainw->settingsDialog->close(); - } - + if( myMainw->settingsDialog) + { + myMainw->settingsDialog->usernameOk(true); + myMainw->settingsDialog->close(); + } + } } - /** *@brief Reports errors, when server has sent error signal. */ void HttpClient::errorFromServer(QNetworkReply::NetworkError errorcode) { qDebug() << "_errorFromServer"; - - //myMainw->setLabelInfoToUser(""); - QNetworkReply* reply = qobject_cast(sender()); if(errorcode != 0) { @@ -349,16 +397,12 @@ void HttpClient::errorFromServer(QNetworkReply::NetworkError errorcode) } } - /** *@brief React to servers responce after request of TopList in certain category has been sent. */ void HttpClient::ackOfToplist() { qDebug() << "_ackOfToplist"; - - //myMainw->setLabelInfoToUser(""); - QNetworkReply* reply = qobject_cast(sender()); myXmlreader->xmlReadTop10Results(reply); @@ -367,10 +411,13 @@ void HttpClient::ackOfToplist() if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list",reply->errorString()); + if(myMainw->topResultDialog) + myMainw->topResultDialog->setLabelInfoToUser("Error"); } else { qDebug() << "errorcode:" << errorcode << reply->errorString(); //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list", "OK " + reply->readAll()); + if(myMainw->topResultDialog) + myMainw->topResultDialog->setLabelInfoToUser(""); } } - diff --git a/Client/httpclient.h b/Client/httpclient.h index 0f4283f..772d1b8 100644 --- a/Client/httpclient.h +++ b/Client/httpclient.h @@ -1,9 +1,11 @@ /* * Http client Connects application to server. * - * @author Tiina Kivilinna-Korhola - * @copyright (c) 2010 Speed Freak team - * license http://opensource.org/licenses/gpl-license.php GNU Public License + * @author Tiina Kivilinna-Korhola + * @author Olavi Pulkkinen + * @author Toni Jussila + * @copyright (c) 2010 Speed Freak team + * license http://opensource.org/licenses/gpl-license.php GNU Public License */ #ifndef HTTPCLIENT_H diff --git a/Client/maemo5location.cpp b/Client/maemo5location.cpp index a8065fd..535cef3 100755 --- a/Client/maemo5location.cpp +++ b/Client/maemo5location.cpp @@ -9,6 +9,7 @@ //#ifdef Q_WS_MAEMO_5 #include "maemo5locationprivate.h" #include "maemo5location.h" +#include /** *Default constructor of this class. @@ -16,6 +17,7 @@ */ Maemo5Location::Maemo5Location(QObject* parent):QObject(parent) { + qDebug() << "__Maemo5Location"; ptr = new Maemo5LocationPrivate(this); connect(ptr, SIGNAL(agnss()), this, SIGNAL(agnss())); @@ -33,7 +35,9 @@ Maemo5Location::Maemo5Location(QObject* parent):QObject(parent) */ Maemo5Location::~Maemo5Location() { - delete ptr; + qDebug() << "__~Maemo5Location"; + if(ptr) + delete ptr; } /** @@ -41,6 +45,7 @@ Maemo5Location::~Maemo5Location() */ void Maemo5Location::startPollingGPS() { + qDebug() << "__Maemo5Location: startPollingGPS"; ptr->get_agnss(); } @@ -49,6 +54,7 @@ void Maemo5Location::startPollingGPS() */ void Maemo5Location::stopPollingGPS() { + qDebug() << "__Maemo5Location: stopPollingGPS"; ptr->stop(); } diff --git a/Client/maemo5locationprivate.cpp b/Client/maemo5locationprivate.cpp index d8b3b5d..8935c8d 100755 --- a/Client/maemo5locationprivate.cpp +++ b/Client/maemo5locationprivate.cpp @@ -7,6 +7,7 @@ */ #include "maemo5locationprivate.h" +#include /** *Default constructor of this class. @@ -14,13 +15,16 @@ */ Maemo5LocationPrivate::Maemo5LocationPrivate(Maemo5Location* location):QObject(location) { + qDebug() << "__Maemo5LocationPrivate"; //Initialize variables gps_online = false; usegps = -1; resetAll(); //Get gps control object + control = NULL; control = location_gpsd_control_get_default(); //create gps device + device = NULL; device = (LocationGPSDevice*) g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL); g_signal_connect(device, "changed", G_CALLBACK(gps_data_changed), this); @@ -37,8 +41,9 @@ Maemo5LocationPrivate::Maemo5LocationPrivate(Maemo5Location* location):QObject(l */ Maemo5LocationPrivate::~Maemo5LocationPrivate() { - delete device; - delete control; + qDebug() << "__~Maemo5LocationPrivate"; + //delete device; + //delete control; } /** diff --git a/Client/mainwindow.cpp b/Client/mainwindow.cpp index 7b04b08..52f7efe 100644 --- a/Client/mainwindow.cpp +++ b/Client/mainwindow.cpp @@ -26,9 +26,6 @@ MainWindow::MainWindow(QWidget *parent) : QCoreApplication::setOrganizationDomain("fudeco.com"); QCoreApplication::setApplicationName("Speed Freak"); - //routeDialog = new RouteDialog; - //connect(routeDialog,SIGNAL(sendroute()),this,SLOT(clientSendRoute())); - helpDialog = NULL; accstart = NULL; routeSaveDialog = NULL; @@ -43,10 +40,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox())); connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10())); - //creditsDialog = new CreditsDialog; - welcomeDialog = new WelcomeDialog; - welcomeDialog->show(); + //welcomeDialog->show(); this->setUsernameToMainPanel(); @@ -118,8 +113,8 @@ void MainWindow::on_pushButtonCredits_clicked() { if(!helpDialog) helpDialog = new HelpDialog; + helpDialog->show(); - //creditsDialog->show(); } /** @@ -129,8 +124,9 @@ void MainWindow::on_pushButtonRoute_clicked() { if(!routeSaveDialog) routeSaveDialog = new RouteSaveDialog; + connect(routeSaveDialog, SIGNAL(sendroute()), this, SLOT(clientSendRoute())); - connect(topResultDialog, SIGNAL(rejected()), this, SLOT(killDialog())); + connect(routeSaveDialog, SIGNAL(rejected()), this, SLOT(killDialog())); routeSaveDialog->show(); } @@ -149,6 +145,7 @@ void MainWindow::on_pushButtonAccelerate_clicked() { if(!accstart) accstart = new accelerationstart(this); + connect(accstart, SIGNAL(sendresult(QString, double)), this, SLOT(clientSendResult(QString, double))); connect(accstart, SIGNAL(rejected()), this, SLOT(killDialog())); accstart->show(); @@ -161,6 +158,7 @@ void MainWindow::on_pushButtonResults_clicked() { if (!topResultDialog) topResultDialog = new TopResultDialog; + clientRequestCategoryList(); connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList())); connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int))); @@ -173,7 +171,8 @@ void MainWindow::on_pushButtonResults_clicked() */ void MainWindow::clientRequestCategoryList() { - httpClient->requestCategories(); + if(httpClient) + httpClient->requestCategories(); } /** @@ -181,8 +180,13 @@ void MainWindow::clientRequestCategoryList() */ void MainWindow::clientRequestTopList(int index) { - QString limit = QString::number(topResultDialog->getLimitNr()); - httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit); + QString limit; + + if(topResultDialog && httpClient->myXmlreader->myCategoryList) + { + limit = QString::number(topResultDialog->getLimitNr()); + httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit); + } } /** @@ -191,7 +195,8 @@ void MainWindow::clientRequestTopList(int index) */ void MainWindow::setCategoryCompoBox() { - topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList()); + if(topResultDialog && httpClient->myXmlreader->myCategoryList) + topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList()); } /** @@ -200,8 +205,13 @@ void MainWindow::setCategoryCompoBox() */ void MainWindow::showTop10() { - int ind = topResultDialog->getRecentCategoryIndex(); - setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr()); + int ind; + + if(topResultDialog && httpClient->myXmlreader->myCategoryList && topResultDialog) + { + ind = topResultDialog->getRecentCategoryIndex(); + setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr()); + } } /** @@ -212,8 +222,12 @@ void MainWindow::showTop10() void MainWindow::setListViewTopList(QString category, int size) { QString topList; - topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size)); - topResultDialog->showTopList(topList); + + if(httpClient->myXmlreader->myCategoryList && topResultDialog) + { + topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size)); + topResultDialog->showTopList(topList); + } } /** @@ -221,7 +235,8 @@ void MainWindow::setListViewTopList(QString category, int size) */ void MainWindow::clientRegUserToServer() { - httpClient->requestRegistration(); + if(httpClient) + httpClient->requestRegistration(); } /** @@ -229,8 +244,12 @@ void MainWindow::clientRegUserToServer() */ void MainWindow::clientUserLogin() { - connect(httpClient, SIGNAL(loginOK()), this, SLOT(setUsernameToMainPanel())); - httpClient->checkLogin(); + + if(httpClient) + { + connect(httpClient, SIGNAL(loginOK()), this, SLOT(setUsernameToMainPanel())); + httpClient->checkLogin(); + } } /** @@ -238,7 +257,8 @@ void MainWindow::clientUserLogin() */ void MainWindow::clientSendRoute() { - httpClient->sendRouteXml(); + if(httpClient) + httpClient->sendRouteXml(); } /** @@ -249,7 +269,8 @@ void MainWindow::clientSendResult(QString category, double result) qDebug() << "__clientSendResult"; if(accstart) { qDebug() << "_clientSendResult, calling server"; - httpClient->sendResultXml(category, result); + if(httpClient) + httpClient->sendResultXml(category, result); } } /** @@ -259,19 +280,34 @@ void MainWindow::killDialog() { if(topResultDialog) { + qDebug() << "__MW kill: topResultDialog"; delete topResultDialog; topResultDialog = NULL; } - else if(routeSaveDialog) + if(routeSaveDialog) { - delete routeSaveDialog; - routeSaveDialog = NULL; + qDebug() << "__MW kill: routeSaveDialog"; + //delete routeSaveDialog; + //routeSaveDialog = NULL; } - else if(accstart) + if(accstart) { + qDebug() << "__MW kill: accstart"; delete accstart; accstart = NULL; } + if(welcomeDialog) + { + qDebug() << "__MW kill: welcomeDialog"; + delete welcomeDialog; + welcomeDialog = NULL; + } + if(helpDialog) + { + qDebug() << "__MW kill: helpDialog"; + delete helpDialog; + helpDialog = NULL; + } } void MainWindow::setUsernameToMainPanel() diff --git a/Client/resultdialog.cpp b/Client/resultdialog.cpp index 0662fe2..88171ab 100644 --- a/Client/resultdialog.cpp +++ b/Client/resultdialog.cpp @@ -324,7 +324,7 @@ void ResultDialog::on_pushButtonNew_clicked() */ void ResultDialog::on_pushButtonSend_clicked() { - //emit sendresult(); + ui->pushButtonSend->setEnabled(false); emit sendresult(timeArray[this->getTargetChoice()]); } @@ -759,3 +759,11 @@ void ResultDialog::setLabelInfoToUser(QString infoText) { this->ui->labelInfoToUser->setText(infoText); } + +/** + * This function enable send server button. + */ +void ResultDialog::setSendServerButtonEnabled() +{ + ui->pushButtonSend->setEnabled(true); +} diff --git a/Client/resultdialog.h b/Client/resultdialog.h index 09c4174..252e7ff 100644 --- a/Client/resultdialog.h +++ b/Client/resultdialog.h @@ -27,6 +27,7 @@ public: void setValue(int pSpeed, double pTime); void setLabelInfoToUser(QString infoText); double getResult(); + void setSendServerButtonEnabled(); signals: void sendresult(double); diff --git a/Client/resultdialog.ui b/Client/resultdialog.ui index 444fab4..8846941 100644 --- a/Client/resultdialog.ui +++ b/Client/resultdialog.ui @@ -179,9 +179,9 @@ 10 - 310 - 471 - 51 + 350 + 781 + 21 diff --git a/Client/routedialog.cpp b/Client/routedialog.cpp index 0fc2dcf..7ad0e70 100644 --- a/Client/routedialog.cpp +++ b/Client/routedialog.cpp @@ -3,8 +3,8 @@ * * @author Olavi Pulkkinen * @author Toni Jussila - * @copyright (c) 2010 Speed Freak team - * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ #include "routedialog.h" @@ -17,8 +17,9 @@ #include #include #include +#include -/* +/** * Vector class. * In starting Qt 4.6 there is QVector3D. * Later (updating Qt version) this class can be removed. @@ -141,7 +142,8 @@ void setFromPoint( Viewing *v); void transformseg( Viewing *v, Vector *v1, Vector *v2, int *xscreen1, int *yscreen1, int *xscreen2, int *yscreen2 ); #define R 6378.140 // The radius of the earth by kilometers -/* + +/** * count distance of two points (defined by longitude & latitude) * on the surface of the earth. */ @@ -164,10 +166,14 @@ qreal countDistance(Vector *p1, Vector *p2) return R*c; // Return distance in kilometers } +/** + * Constructor of this class. + */ RouteDialog::RouteDialog(QWidget *parent) : QDialog(parent), ui(new Ui::RouteDialog) { + qDebug() << "__RouteDialog"; ui->setupUi(this); this->setWindowTitle("Route"); left = 5; top = 5; right = 495; bottom = 295; // Limits in screen coordinates @@ -178,19 +184,36 @@ RouteDialog::RouteDialog(QWidget *parent) : ui->newPushButton->setAutoFillBackground(true); ui->newPushButton->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)"); + //Clear labels + ui->labelInfoToUser->setText(""); + ui->maxSpeedLabel->setText(""); + ui->speedValueLabel->setText(""); + // Send rout to server button disable/enable. ui->sendPushButton->setEnabled(false); if (loginSaved()) { ui->sendPushButton->setEnabled(true); } + else + { + ui->labelInfoToUser->setText("You're not logged! Please register or log in."); + } } +/** + * Destructor of this class. + */ RouteDialog::~RouteDialog() { - delete ui; + qDebug() << "__~RouteDialog"; + if(ui) + delete ui; } +/** + * + */ void RouteDialog::changeEvent(QEvent *e) { QDialog::changeEvent(e); @@ -202,23 +225,42 @@ void RouteDialog::changeEvent(QEvent *e) break; } } + +/** + * + */ int RouteDialog::getLeft() { return left; } + +/** + * + */ int RouteDialog::getRight() { return right; } + +/** + * + */ int RouteDialog::getTop() { return top; } + +/** + * + */ int RouteDialog::getBottom() { return bottom; } +/** + * + */ void drawFlag( RouteDialog *rD, QPainter *p, int x, int y) { /*QPolygon pg; @@ -369,8 +411,12 @@ void RouteDialog::paintEvent(QPaintEvent *) } } +/** + * + */ bool RouteDialog::readRouteFromFile( QString &routeFile) { + QString rFile = routeFile; //Not used Vector temp; QString rivi; QFile file; @@ -500,7 +546,7 @@ bool RouteDialog::readRouteFromFile( QString &routeFile) return true; } -/* +/** * Find out data range for x-, y- and z-coordinates */ void dataMinMax( void) @@ -555,7 +601,7 @@ void dataMinMax( void) //QMessageBox::about(0,"Tark", jono); } -/* +/** * Setting the point where the viewed object is. In the middle of datapoints. */ void setAtPoint( Viewing *v) @@ -579,7 +625,7 @@ void setAtPoint( Viewing *v) * */ } -/* +/** * Setting the point where the object is viewed by eye. */ void setFromPoint( Viewing *v) @@ -612,7 +658,8 @@ void setFromPoint( Viewing *v) #define RIGHTEDGE 0x02 #define BOTTOMEDGE 0x04 #define TOPEDGE 0x08 -/* + +/** * Returns a code specifying which edge in the viewing pyramid was crossed. * There may be more than one. */ @@ -629,7 +676,7 @@ int code( qreal x, qreal y, qreal z) return c; } -/* +/** * Converts clipped world coordinates to screen coordinates. */ void WORLDtoSCREEN( qreal xWorld, qreal yWorld, int *xScreen, int *yScreen) @@ -638,7 +685,7 @@ void WORLDtoSCREEN( qreal xWorld, qreal yWorld, int *xScreen, int *yScreen) *yScreen = (int) (c*yWorld+d); } -/* +/** * Clips the line segment in three-dimensional coordinates to the * viewing pyramid. */ @@ -713,7 +760,7 @@ void clip3d( qreal x1, qreal y1, qreal z1, qreal x2, qreal y2, qreal z2, int *xs //Now ready to draw line( xscreen1, yscreen1, xscreen2, yscreen2); } -/* +/** * Transform the segment connecting the two vectors into the viewing plane. * clip3d() clips the line if needed. */ @@ -738,17 +785,35 @@ void transformseg( Viewing *v, Vector *v1, Vector *v2, int *xscreen1, int *yscre clip3d(x1,y1,z1,x2,y2,z2, xscreen1, yscreen1, xscreen2, yscreen2 ); } +/** + * This slot function is called when ever new push button clicked. + */ void RouteDialog::on_newPushButton_clicked() { close(); // go back to previous dialog } +/** + * This slot function is called when ever send push button clicked. + */ void RouteDialog::on_sendPushButton_clicked() { + ui->sendPushButton->setEnabled(false); emit sendroute(); } +/** + * This function is set info text to user. + */ void RouteDialog::setLabelInfoToUser(QString infoText) { this->ui->labelInfoToUser->setText(infoText); } + +/** + * This function enable send server button. + */ +void RouteDialog::setSendServerButtonEnabled() +{ + ui->sendPushButton->setEnabled(true); +} diff --git a/Client/routedialog.h b/Client/routedialog.h index 1d70aaa..6ffb865 100644 --- a/Client/routedialog.h +++ b/Client/routedialog.h @@ -3,8 +3,8 @@ * * @author Olavi Pulkkinen * @author Toni Jussila - * @copyright (c) 2010 Speed Freak team - * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @copyright (c) 2010 Speed Freak team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ #ifndef ROUTEDIALOG_H @@ -18,6 +18,7 @@ namespace Ui { class RouteDialog : public QDialog { Q_OBJECT + public: RouteDialog(QWidget *parent = 0); ~RouteDialog(); @@ -27,6 +28,7 @@ public: int getRight(); int getBottom(); void setLabelInfoToUser(QString infoText); + void setSendServerButtonEnabled(); signals: void sendroute(); diff --git a/Client/routedialog.ui b/Client/routedialog.ui index e6cafbe..8063b03 100644 --- a/Client/routedialog.ui +++ b/Client/routedialog.ui @@ -95,13 +95,13 @@ 10 - 310 - 521 + 330 + 781 51 - + User info diff --git a/Client/routesavedialog.cpp b/Client/routesavedialog.cpp index 253784e..22ac907 100644 --- a/Client/routesavedialog.cpp +++ b/Client/routesavedialog.cpp @@ -8,6 +8,7 @@ #include "routesavedialog.h" #include "ui_routesavedialog.h" +#include /** *Constructor of this class. @@ -16,10 +17,13 @@ RouteSaveDialog::RouteSaveDialog(QWidget *parent) : QDialog(parent), ui(new Ui::RouteSaveDialog){ + qDebug() << "__RouteSaveDialog"; ui->setupUi(this); this->setWindowTitle("Tracking"); routeDialog = NULL; + location = NULL; + gpsData = NULL; //Button settings buttonStatus = true; @@ -41,19 +45,15 @@ RouteSaveDialog::RouteSaveDialog(QWidget *parent) : timerSatellitePicture->setInterval(400); connect(timerSatellitePicture, SIGNAL(timeout()),this, SLOT(timerSatellitePictureTimeout())); - //Route picture and label + //Invisible or clear labels ui->labelRouteStatus->setVisible(0); ui->labelRoutePicture->setVisible(0); + ui->labelGpsSpeed->setVisible(0); //GPS speed label + ui->labelUserInfo->setText(""); //User info label timerRoutePicture = new QTimer(); timerRoutePicture->setInterval(400); connect(timerRoutePicture, SIGNAL(timeout()),this, SLOT(timerRoutePictureTimeout())); - //GPS speed label - ui->labelGpsSpeed->setVisible(0); - - //User info label - ui->labelUserInfo->setText(""); - //GPS location = new Maemo5Location(this); gpsData = new GPSData(location); @@ -65,12 +65,18 @@ RouteSaveDialog::RouteSaveDialog(QWidget *parent) : */ RouteSaveDialog::~RouteSaveDialog() { - delete ui; + qDebug() << "__~RouteSaveDialog"; + if(ui) + delete ui; + if(gpsData) + delete gpsData; + if(location) + delete location; + if(routeDialog) + delete routeDialog; + delete timerSatellitePicture; delete timerRoutePicture; - delete location; - delete gpsData; - delete routeDialog; delete pixmapRouteStop; delete pixmapRouteStart; delete iconRouteStop; @@ -97,16 +103,17 @@ void RouteSaveDialog::changeEvent(QEvent *e) */ void RouteSaveDialog::on_buttonRouteStartStop_clicked() { - //If start button clicked - if ( buttonStatus == true ) + if ( buttonStatus == true )//If start button clicked { + qDebug() << "__start button clicked"; buttonStatus = false; ui->buttonRouteStartStop->setIcon(*iconRouteStop); location->startPollingGPS(); gpsStatus(); } - else + else //If stop button clicked { + qDebug() << "__stop button clicked"; buttonStatus = true; ui->buttonRouteStartStop->setIcon(*iconRouteStart); diff --git a/Client/speedfreak.pro b/Client/speedfreak.pro index 22ebcb8..dd99248 100644 --- a/Client/speedfreak.pro +++ b/Client/speedfreak.pro @@ -88,7 +88,7 @@ contains(QT_CONFIG, hildon):CONFIG += hildon CONFIG += link_pkgconfig # Enable this to disable debugging -DEFINES += QT_NO_DEBUG_OUTPUT +#DEFINES += QT_NO_DEBUG_OUTPUT target.path += /usr/lib devincludes.files = $$HEADERS devincludes.path += /usr/include/$$TEMPLATE$$TARGET diff --git a/Client/xmlreader.cpp b/Client/xmlreader.cpp index eeed22e..b6c1653 100644 --- a/Client/xmlreader.cpp +++ b/Client/xmlreader.cpp @@ -16,6 +16,7 @@ */ XmlReader::XmlReader() { + qDebug() << "__XmlReader"; myCategoryList = new CategoryList(); } @@ -24,12 +25,15 @@ XmlReader::XmlReader() */ XmlReader::~XmlReader() { + qDebug() << "__~XmlReader"; category = ""; unit = ""; position = ""; user = ""; value = ""; - delete myCategoryList; + + if(myCategoryList) + delete myCategoryList; } /** @@ -44,7 +48,7 @@ void XmlReader::xmlReadTop10Results(QNetworkReply *device) xmlreader.clear(); QByteArray array = device->readAll(); - qDebug() << "array: " << array; + //qDebug() << "array: " << array; xmlreader.addData(array); //xmlreader.addData(device->readAll()); @@ -106,7 +110,7 @@ void XmlReader::xmlReadCategories(QNetworkReply *device) xmlreader.clear(); QByteArray array = device->readAll(); - qDebug() << "array: " << array; + //qDebug() << "array: " << array; xmlreader.addData(array); //xmlreader.addData(device->readAll()); diff --git a/Client/xmlwriter.cpp b/Client/xmlwriter.cpp index 495eed9..3abe02a 100644 --- a/Client/xmlwriter.cpp +++ b/Client/xmlwriter.cpp @@ -2,14 +2,13 @@ * Xml writer * * @author Tiina Kivilinna-Korhola + * @author Toni Jussila * @copyright (c) 2010 Speed Freak team * license http://opensource.org/licenses/gpl-license.php GNU Public License */ #include "xmlwriter.h" - - /** *@brief Constructor, connects object to GUI *@param Pointer to carmainwindow, which is temporarily used during development @@ -59,7 +58,6 @@ void XmlWriter::writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QS xmlwriter.writeEndDocument(); } - /** *@brief Writes Speed Freek results items as tags and contents into a buffer. *@todo Consider looping when writing many values. @@ -78,7 +76,6 @@ void XmlWriter::writeResult(QBuffer *netbuf, double result) xmlwriter.writeEndDocument(); } - /** *@brief Write track to server. *@param netbuf where to write. @@ -115,7 +112,6 @@ void XmlWriter::writeGpsTrack(QBuffer *netbuf, int counter, int start, int stop, xmlwriter.writeEndDocument(); } - /** *@brief Opens and closes a file, when xml information is written into a file, *and passes file to writeXmlFile() @@ -158,7 +154,6 @@ bool XmlWriter::writeXmlFile(QIODevice *device) return true; } - /** *@brief Writes Speed Freek results items as tags and contents to earlier defined target. *@todo Consider looping when writing many values.