void HttpClient::requestRegistration()
{
qDebug() << "_requestRegistration" ;
- qDebug() << myMainw->myRegistration->getUserName() << "+" << myMainw->myRegistration->getPassword() << "+" << myMainw->myRegistration->getEmail();
+ qDebug() << myMainw->settingsDialog->getRegUserName() << "+" << myMainw->settingsDialog->getRegPassword() << "+" << myMainw->settingsDialog->getRegEmail();
QBuffer *regbuffer = new QBuffer();
QUrl qurl("http://api.speedfreak-app.com/api/register");
regbuffer->open(QBuffer::ReadWrite);
myXmlwriter->writeRegistering(regbuffer,
- myMainw->myRegistration->getUserName(),
- myMainw->myRegistration->getPassword(),
- myMainw->myRegistration->getEmail());
+ myMainw->settingsDialog->getRegUserName(),
+ myMainw->settingsDialog->getRegPassword(),
+ myMainw->settingsDialog->getRegEmail());
qDebug() << "carmainwindow: regbuffer->data(): " << regbuffer->data();
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->setLabelInfoToUser("Reguesting registration from server");
+ //myMainw->setLabelInfoToUser("Reguesting registration from server");
regbuffer->close();
}
myXmlwriter->writeResult(xmlbuffer, result);
qDebug() << "carmainwindow: xmlbuffer->data(): " << xmlbuffer->data();
- QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
+ QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
credentials = "Basic " + credentials.toAscii().toBase64();
request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
currentDownload = netManager->post(request, ("xml=" + xmlbuffer->data()));
connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfResult()));
//connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- myMainw->setLabelInfoToUser("Sending result to server");
+ //myMainw->setLabelInfoToUser("Sending result to server");
xmlbuffer->close();
}
QNetworkRequest request(qurl);
QNetworkReply *currentDownload;
- QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
+ QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
credentials = "Basic " + credentials.toAscii().toBase64();
request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
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->setLabelInfoToUser("Sending route to server");
+ //myMainw->setLabelInfoToUser("Sending route to server");
file.close();
}
QNetworkRequest request(qurl);
QNetworkReply *currentDownload;
- QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
+ QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
credentials = "Basic " + credentials.toAscii().toBase64();
request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
currentDownload = netManager->post(request, ("data=" ));
connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfToplist()));
//connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- myMainw->setLabelInfoToUser("Reguesting top10 list from server");
+ //myMainw->setLabelInfoToUser("Reguesting top10 list from server");
}
QNetworkRequest request(qurl);
QNetworkReply *currentDownload;
- QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
+ QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
credentials = "Basic " + credentials.toAscii().toBase64();
request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
currentDownload = netManager->post(request, ("data=" ));
connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfCategories()));
//connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- myMainw->setLabelInfoToUser("Reguesting categories from server");
+ //myMainw->setLabelInfoToUser("Reguesting categories from server");
}
QNetworkRequest request(qurl);
QNetworkReply *currentDownload;
- QString credentials = myMainw->myLogin->getUserName() + ":" + myMainw->myLogin->getPassword();
+ QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
credentials = "Basic " + credentials.toAscii().toBase64();
request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
currentDownload = netManager->post(request, ("data=" ));
connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfLogin()));
//connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- myMainw->setLabelInfoToUser("Checking login validity from server");
+ //myMainw->setLabelInfoToUser("Checking login validity from server");
}
{
qDebug() << "_ackOfResult";
- myMainw->setLabelInfoToUser("");
+ //myMainw->setLabelInfoToUser("");
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
errorcode = reply->error();
if(errorcode != 0) {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to result sending ",reply->errorString());
+ //QMessageBox::about(myMainw, "Server reply to result sending ",reply->errorString());
}
else {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to result sending", "Result received " + reply->readAll());
+ //QMessageBox::about(myMainw, "Server reply to result sending", "Result received " + reply->readAll());
}
}
{
qDebug() << "_ackOfRoute";
- myMainw->setLabelInfoToUser("");
+ //myMainw->setLabelInfoToUser("");
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
errorcode = reply->error();
if(errorcode != 0) {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to route sending ",reply->errorString());
+ //QMessageBox::about(myMainw, "Server reply to route sending ",reply->errorString());
}
else {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to route sending", "Route received " + reply->readAll());
+ //QMessageBox::about(myMainw, "Server reply to route sending", "Route received " + reply->readAll());
}
}
{
qDebug() << "_ackOfRegistration";
- myMainw->setLabelInfoToUser("");
+ //myMainw->setLabelInfoToUser("");
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
errorcode = reply->error();
if(errorcode != 0) {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to registration",reply->readAll());
+ //QMessageBox::about(myMainw, "Server reply to registration",reply->readAll());
}
else {
qDebug() << "errorcode=0" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to registration", "User registration " + reply->readAll());
+ //QMessageBox::about(myMainw, "Server reply to registration", "User registration " + reply->readAll());
}
}
{
qDebug() << "_ackOfCategories";
- myMainw->setLabelInfoToUser("");
+ //myMainw->setLabelInfoToUser("");
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
myXmlreader->xmlReadCategories(reply);
errorcode = reply->error();
if(errorcode != 0) {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to requesting categories",reply->errorString());
+ //QMessageBox::about(myMainw, "Server reply to requesting categories",reply->errorString());
}
else {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to requesting categories ", "OK");
+ //QMessageBox::about(myMainw, "Server reply to requesting categories ", "OK");
}
}
{
qDebug() << "_ackOffLogin";
- myMainw->setLabelInfoToUser("");
+ //myMainw->setLabelInfoToUser("");
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
errorcode = reply->error();
if(errorcode != 0) {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server does not recognize your username. Please registrate.",reply->errorString());
+ //QMessageBox::about(myMainw, "Server does not recognize your username. Please registrate.",reply->errorString());
}
else {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to login", "User login " + reply->readAll());
+ //QMessageBox::about(myMainw, "Server reply to login", "User login " + reply->readAll());
}
}
{
qDebug() << "_errorFromServer";
- myMainw->setLabelInfoToUser("");
+ //myMainw->setLabelInfoToUser("");
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
{
qDebug() << "_ackOfToplist";
- myMainw->setLabelInfoToUser("");
+ //myMainw->setLabelInfoToUser("");
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
myXmlreader->xmlReadTop10Results(reply);
errorcode = reply->error();
if(errorcode != 0) {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to requesting top 10 list",reply->errorString());
+ //QMessageBox::about(myMainw, "Server reply to requesting top 10 list",reply->errorString());
}
else {
qDebug() << "errorcode:" << errorcode << reply->errorString();
- QMessageBox::about(myMainw, "Server reply to requesting top 10 list", "OK " + reply->readAll());
+ //QMessageBox::about(myMainw, "Server reply to requesting top 10 list", "OK " + reply->readAll());
}
}
creditsDialog = new CreditsDialog;
routeSaveDialog = new RouteSaveDialog;
settingsDialog = new SettingsDialog;
+ connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(regUserToServer()));
+ connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(userLogin()));
topResultDialog = new TopResultDialog;
connect(topResultDialog, SIGNAL(refreshCategoryList()), this, SLOT(clientRequestCategoryList()));
connect(topResultDialog, SIGNAL(refreshTopList(int)), this, SLOT(clientRequestTopList(int)));
accstart = NULL;
httpClient = new HttpClient(this);
+ connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
+ connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));
welcomeDialog = new WelcomeDialog;
welcomeDialog->show();
QString limit = QString::number(topResultDialog->getLimitNr());
httpClient->requestTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(index), limit);
}
+
+/**
+ *This function is used to set items to category combobox. Top-tab view.
+ *@param
+ */
+void MainWindow::setCategoryCompoBox()
+{
+ qDebug() << "_setCategoryCompoBox";
+ topResultDialog->setCompoBoxCategories(httpClient->myXmlreader->myCategoryList->getCategoryList());
+}
+
+/**
+ *This function prcesses UI updating after a new top10List has been received.
+ *@todo Check where limitNr is taken, fixed or user input, see on_comboBoxTopCategory_currentIndexChanged.
+ */
+void MainWindow::showTop10()
+{
+ qDebug() << "_showTop10";
+ int ind = topResultDialog->getRecentCategoryIndex();
+ setListViewTopList(httpClient->myXmlreader->myCategoryList->getRecentCategory(ind), topResultDialog->getLimitNr());
+}
+
+/**
+ *This function is used to set items to labelTopList. Top-tab view.
+ *@param Category
+ *@param Size, number of results.
+ */
+void MainWindow::setListViewTopList(QString category, int size)
+{
+ qDebug() << "_setListViewTopList" << category;
+ QString topList;
+ topList.append(httpClient->myXmlreader->myCategoryList->getTopList(category, size));
+ topResultDialog->showTopList(topList);
+}
+
+void MainWindow::regUserToServer()
+{
+ httpClient->requestRegistration();
+}
+
+void MainWindow::userLogin()
+{
+ httpClient->checkLogin();
+}