From: Toni Jussila Date: Thu, 27 May 2010 07:06:42 +0000 (+0300) Subject: Added new Register dialog. X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=commitdiff_plain;h=2cff5ca17d324f817ff283782e5a4bd242a27cbc Added new Register dialog. --- diff --git a/Client/httpclient.cpp b/Client/httpclient.cpp index 08e1695..3169730 100644 --- a/Client/httpclient.cpp +++ b/Client/httpclient.cpp @@ -48,7 +48,7 @@ HttpClient::~HttpClient() void HttpClient::requestRegistration() { qDebug() << "_requestRegistration" ; - qDebug() << myMainw->settingsDialog->getRegUserName() << "+" << myMainw->settingsDialog->getRegPassword() << "+" << myMainw->settingsDialog->getRegEmail(); + qDebug() << myMainw->settingsDialog->registerDialog->getRegUserName() << "+" << myMainw->settingsDialog->registerDialog->getRegPassword() << "+" << myMainw->settingsDialog->registerDialog->getRegEmail(); QBuffer *regbuffer = new QBuffer(); QUrl qurl("http://www.speedfreak-app.com/users/register"); @@ -57,11 +57,30 @@ void HttpClient::requestRegistration() QNetworkReply *currentDownload; regbuffer->open(QBuffer::ReadWrite); - myXmlwriter->writeRegistering(regbuffer, + + // Without profile dialog + /*myXmlwriter->writeRegistering(regbuffer, myMainw->settingsDialog->getRegUserName(), myMainw->settingsDialog->getRegPassword(), - myMainw->settingsDialog->getRegEmail(), - "My car is cool"); + myMainw->settingsDialog->getRegEmail());*/ + // With profile dialog + /*myXmlwriter->writeRegistering(regbuffer, + myMainw->settingsDialog->getRegUserName(), + myMainw->settingsDialog->getRegPassword(), + myMainw->settingsDialog->getRegEmail(), + myMainw->settingsDialog->profileDialog->getDescription()); + myMainw->settingsDialog->profileDialog->getManufacturer(), + myMainw->settingsDialog->profileDialog->getType(), + myMainw->settingsDialog->profileDialog->getModel(), + myMainw->settingsDialog->profileDialog->getDescription(), + myMainw->settingsDialog->profileDialog->getPicture());*/ + // New way: Registerdialog = register + Profiledialog + myXmlwriter->writeRegistering(regbuffer, + myMainw->settingsDialog->registerDialog->getRegUserName(), + myMainw->settingsDialog->registerDialog->getRegPassword(), + myMainw->settingsDialog->registerDialog->getRegEmail(), + myMainw->settingsDialog->registerDialog->getDescription()); + qDebug() << "carmainwindow: regbuffer->data(): " << regbuffer->data(); currentDownload = netManager->post(request, ("xml=" + regbuffer->data())); @@ -69,8 +88,8 @@ void HttpClient::requestRegistration() //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError))); //Indicating user - if(myMainw->settingsDialog) - myMainw->settingsDialog->setLabelInfoToUser("Reguesting registration from server"); + if(myMainw->settingsDialog->registerDialog) + myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Reguesting registration from server"); regbuffer->close(); } @@ -202,8 +221,8 @@ void HttpClient::requestTopList(QString category, QString limit) void HttpClient::requestCategories() { qDebug() << "_requestCategories" ; - QUrl qurl("http://www.speedfreak-app.com/results/categories"); + QUrl qurl("http://www.speedfreak-app.com/results/categories"); qDebug() << qurl.toString(); QNetworkRequest request(qurl); QNetworkReply *currentDownload; @@ -275,8 +294,6 @@ void HttpClient::ackOfResult() myMainw->accstart->accRealTimeDialog->resultDialog->setSendServerButtonEnabled(); } else { - //qDebug() << "errorcode:" << errorcode << reply->errorString(); - //Indicating user if(myMainw->accstart->accRealTimeDialog->resultDialog) QMessageBox::about(myMainw->accstart->accRealTimeDialog->resultDialog, "Server reply to result sending", "Result received " + reply->readAll()); @@ -322,7 +339,7 @@ void HttpClient::ackOfRegistration() qDebug() << "_ackOfRegistration"; if(myMainw->settingsDialog) - myMainw->settingsDialog->setLabelInfoToUser(""); + myMainw->settingsDialog->registerDialog->setLabelInfoToUser(""); QNetworkReply* reply = qobject_cast(sender()); @@ -330,15 +347,15 @@ void HttpClient::ackOfRegistration() errorcode = reply->error(); if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); - if(myMainw->settingsDialog) - QMessageBox::about(myMainw->settingsDialog, "Server reply to registration",reply->readAll()); + if(myMainw->settingsDialog->registerDialog) + QMessageBox::about(myMainw->settingsDialog->registerDialog, "Server reply to registration",reply->readAll()); } else { qDebug() << "errorcode=0" << errorcode << reply->errorString(); - if(myMainw->settingsDialog) + if(myMainw->settingsDialog->registerDialog) { - QMessageBox::about(myMainw->settingsDialog, "Server reply to registration", "User registration " + reply->readAll()); - myMainw->settingsDialog->clearRegisterLineEdits(); + QMessageBox::about(myMainw->settingsDialog->registerDialog, "Server reply to registration", "User registration " + reply->readAll()); + myMainw->settingsDialog->registerDialog->clearRegisterLineEdits(); } } } @@ -365,7 +382,6 @@ void HttpClient::ackOfCategories() 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(""); @@ -477,15 +493,15 @@ void HttpClient::sendProfileXml() return; } myXmlwriter->writeProfileXmlFile(&file, userName, - myMainw->settingsDialog->profileDialog->getManufacturer(), - myMainw->settingsDialog->profileDialog->getType(), - myMainw->settingsDialog->profileDialog->getModel(), - myMainw->settingsDialog->profileDialog->getDescription(), - myMainw->settingsDialog->profileDialog->getPicture()); + myMainw->settingsDialog->registerDialog->getManufacturer(), + myMainw->settingsDialog->registerDialog->getType(), + myMainw->settingsDialog->registerDialog->getModel(), + myMainw->settingsDialog->registerDialog->getDescription(), + myMainw->settingsDialog->registerDialog->getPicture()); //Indicating user - if(myMainw->settingsDialog->profileDialog) - myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Profile saved to phone"); + if(myMainw->settingsDialog->registerDialog) + myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Profile saved to phone"); // Send xml to server /*QUrl qurl("http://speedfreak-app.com/api/profile"); @@ -529,20 +545,20 @@ bool HttpClient::ackOfProfile() if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); //Indicating user - if(myMainw->settingsDialog->profileDialog) + if(myMainw->settingsDialog->registerDialog) { //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting profile",reply->errorString()); - myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Profile save to server - fail"); + myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Profile save to server - fail"); return true; } } else { qDebug() << "errorcode:" << errorcode << reply->errorString(); //Indicating user - if(myMainw->settingsDialog->profileDialog) + if(myMainw->settingsDialog->registerDialog) { //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting profile", "OK " + reply->readAll()); - myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Profile saved to server"); + myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Profile saved to server"); return false; } } @@ -559,19 +575,19 @@ void HttpClient::ackOfSendingPicture() if(errorcode != 0) { qDebug() << "errorcode:" << errorcode << reply->errorString(); //Indicating user - if(myMainw->settingsDialog->profileDialog) + if(myMainw->settingsDialog->registerDialog) { //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting picture",reply->errorString()); - myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Picture save to server - fail"); + myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Picture save to server - fail"); } } else { qDebug() << "errorcode:" << errorcode << reply->errorString(); //Indicating user - if(myMainw->settingsDialog->profileDialog) + if(myMainw->settingsDialog->registerDialog) { //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting picture", "OK " + reply->readAll()); - myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Picture saved to server"); + myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Picture saved to server"); } } } diff --git a/Client/profiledialog.cpp b/Client/profiledialog.cpp index 82707cd..276c209 100644 --- a/Client/profiledialog.cpp +++ b/Client/profiledialog.cpp @@ -146,8 +146,9 @@ void ProfileDialog::on_buttonSave_clicked() setModel(ui->lineEditModel->text()); setDescription(ui->textEditDescription->toPlainText()); + this->close(); // emit settingsdialog --> mainwindow --> httpclient - emit saveprofile(); + //emit saveprofile(); } /** diff --git a/Client/registerdialog.cpp b/Client/registerdialog.cpp new file mode 100644 index 0000000..b3fcd33 --- /dev/null +++ b/Client/registerdialog.cpp @@ -0,0 +1,313 @@ +#include "registerdialog.h" +#include "ui_registerdialog.h" +#include +#include +#include +#include +#include +#include +#include +#include "usersettings.h" +#include "settingsdialog.h" +#include "xmlreader.h" + +/** + * Constructor of this class. + */ +RegisterDialog::RegisterDialog(QWidget *parent) : + QDialog(parent), ui(new Ui::RegisterDialog) +{ + ui->setupUi(this); + this->setWindowTitle("Register new user"); + this->ui->regEMailLineEdit->setText("@"); + // User info label + ui->labelInfoToUser->setVisible(0); + ui->labelInfoToUser->setText(""); + // Button + imageButtonState = false; + manufacturer=""; + type=""; + model=""; + description=""; + picture=""; + + ui->buttonImage->setVisible(false); + ui->labelImage->setVisible(false); + // Read user profile xml + /*QString filename = "/home/user/MyDocs/speedfreak/profile/" + parent->getUserName() + "_profile.xml"; + QFile file(filename); + + if (!file.open(QFile::ReadOnly)) + { + qDebug() << "_xmlRead fail"; + return; + } + else + { + xmlReader = new XmlReader(); + xmlReader->xmlReadProfile(&file,this); + } + file.close();*/ +} + +/** + * Destructor of this class. + */ +RegisterDialog::~RegisterDialog() +{ + delete ui; +} + +/** + * + */ +void RegisterDialog::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +/** + * This function is used to clear lineEdits and close this dialog. + */ +void RegisterDialog::clearRegisterLineEdits() +{ + ui->regEMailLineEdit->setText("@"); + ui->regPasswordLineEdit->setText(""); + ui->regUserNameLineEdit->setText(""); + ui->lineEditManufacturer->setText(""); + ui->lineEditModel->setText(""); + ui->lineEditType->setText(""); + ui->textEditDescription->setText(""); + + this->close(); +} + +// Next 6 functions can be removed if Settingsdialog is implemented without +// own copy of username, password & email +/** + * + */ +void RegisterDialog::setRegUserName(QString username) +{ + this->regUsername = username; +} + +/** + * + */ +void RegisterDialog::setRegPassword(QString password) +{ + this->regPassword = password; +} + +/** + * + */ +void RegisterDialog::setRegEmail(QString email) +{ + this->regEmail = email; +} + +/** + * + */ +QString RegisterDialog::getRegUserName() +{ + return this->regUsername; +} + +/** + * + */ +QString RegisterDialog::getRegPassword() +{ + return this->regPassword; +} + +/** + * + */ +QString RegisterDialog::getRegEmail() +{ + return this->regEmail; +} + +void RegisterDialog::on_registratePushButton_clicked() +{ + // Save labels data + setManufacturer(ui->lineEditManufacturer->text()); + setType(ui->lineEditType->text()); + setModel(ui->lineEditModel->text()); + setDescription(ui->textEditDescription->toPlainText()); + + // emit settingsdialog --> mainwindow --> httpclient + //emit saveprofile(); + + + + // Send username, password and email to SpeedFreak server + this->regUsername = ui->regUserNameLineEdit->text(); + this->regPassword = ui->regPasswordLineEdit->text(); + this->regEmail = ui->regEMailLineEdit->text(); + + if (this->regUsername.compare("") && this->regPassword.compare("") && this->regEmail.compare("") && this->regEmail.compare("@")) + { + emit registrate(); + } + else + { + QMessageBox::about(this, "One or more of the fields is empty", "Set username (3-12 characters), password (at least 6 characters) and valid email address"); + } + + //close(); //using close() hides popup-window which reports error from server +} + +/** + * This get function return manufacturer + * @return QString + */ +QString RegisterDialog::getManufacturer() +{ + return manufacturer; +} + +/** + * This get function return type + * @return QString + */ +QString RegisterDialog::getType() +{ + return type; +} + +/** + * This get function return model + * @return QString + */ +QString RegisterDialog::getModel() +{ + return model; +} + +/** + * This get function return description + * @return QString + */ +QString RegisterDialog::getDescription() +{ + QString all = manufacturer + ";" + type + ";" + model + ";" + description; + return all; +} + +/** + * This get function return description + * @return QString + */ +QString RegisterDialog::getPicture() +{ + return picture; +} + +/** + * This set function set manufacturer + * @param QString + */ +void RegisterDialog::setManufacturer(QString m) +{ + manufacturer = m; + ui->lineEditManufacturer->setText(m); +} + +/** + * This set function set type + * @param QString + */ +void RegisterDialog::setType(QString t) +{ + type = t; + ui->lineEditType->setText(t); +} + +/** + * This set function set model + * @param QString + */ +void RegisterDialog::setModel(QString m) +{ + model = m; + ui->lineEditModel->setText(m); +} + +/** + * This set function set description + * @param QString + */ +void RegisterDialog::setDescription(QString d) +{ + description = d; + ui->textEditDescription->setText(d); +} + +/** + * This set function set description + * @param QString + */ +void RegisterDialog::setPicture(QString p) +{ + picture = p; + loadPicture(p); +} + +/** + * This function set label info text to user + * @param QString + */ +void RegisterDialog::setLabelInfoToUser(QString infoText) +{ + ui->labelInfoToUser->setVisible(1); + this->ui->labelInfoToUser->setText(infoText); +} + +/** + * This slot function called when image button clicked. + */ +void RegisterDialog::on_buttonImage_clicked() +{ + if (imageButtonState == false) + { + ui->buttonImage->setText("Load image"); + } + else + { + ui->buttonImage->setText("Change image"); + } + + QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath()); + loadPicture(fileName); +} + +/** + * This function load picture. + * @param QString + */ +void RegisterDialog::loadPicture(QString fileName) +{ + if (!fileName.isEmpty()) + { + QImage image(fileName); + if (image.isNull()) + { + QMessageBox::information(this, tr("Profile"),tr("Cannot load %1.").arg(fileName)); + return; + } + ui->labelImage->setPixmap(QPixmap::fromImage(image.scaled(QSize(120,120), Qt::KeepAspectRatio))); + picture = fileName; + } +} diff --git a/Client/registerdialog.h b/Client/registerdialog.h new file mode 100644 index 0000000..7e39209 --- /dev/null +++ b/Client/registerdialog.h @@ -0,0 +1,58 @@ +#ifndef REGISTERDIALOG_H +#define REGISTERDIALOG_H + +#include + +namespace Ui { + class RegisterDialog; +} + +class RegisterDialog : public QDialog { + Q_OBJECT +public: + RegisterDialog(QWidget *parent = 0); + ~RegisterDialog(); + void clearRegisterLineEdits(); + QString getRegUserName(); + QString getRegPassword(); + QString getRegEmail(); + void setRegUserName(QString username); + void setRegPassword(QString password); + void setRegEmail(QString email); + QString getManufacturer(); + QString getType(); + QString getModel(); + QString getDescription(); + QString getPicture(); + void setManufacturer(QString m); + void setType(QString t); + void setModel(QString m); + void setDescription(QString d); + void setPicture(QString p); + void setLabelInfoToUser(QString infoText); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::RegisterDialog *ui; + bool imageButtonState; + void loadPicture(QString); + QString regUsername; + QString regPassword; + QString regEmail; + QString manufacturer; + QString type; + QString model; + QString description; + QString picture; + +private slots: + void on_buttonImage_clicked(); + void on_registratePushButton_clicked(); + +signals: + void registrate(); +}; + +#endif // REGISTERDIALOG_H diff --git a/Client/registerdialog.ui b/Client/registerdialog.ui new file mode 100644 index 0000000..5d18b66 --- /dev/null +++ b/Client/registerdialog.ui @@ -0,0 +1,265 @@ + + + RegisterDialog + + + + 0 + 0 + 800 + 380 + + + + Dialog + + + + + 670 + 270 + 120 + 60 + + + + Register + + + + + + 200 + 0 + 401 + 341 + + + + + + + Username: + + + + + + + + Bitstream Charter + 14 + + + + 12 + + + + + + + Password: + + + + + + + + Bitstream Charter + 14 + + + + 255 + + + QLineEdit::Password + + + + + + + Email: + + + + + + + + Bitstream Charter + 14 + + + + 255 + + + + + + + Manufacturer: + + + + + + + + Bitstream Charter + 14 + + + + 12 + + + + + + + Type: + + + + + + + + Bitstream Charter + 14 + + + + 12 + + + + + + + Model: + + + + + + + + Bitstream Charter + 14 + + + + 10 + + + + + + + Description: + + + + + + + + Bitstream Charter + 14 + + + + + + + + + + 30 + 30 + 120 + 120 + + + + background-color: rgb(99, 99, 99); + + + QFrame::Box + + + 0 + + + No image + + + Qt::AlignCenter + + + 0 + + + + + + 30 + 160 + 120 + 60 + + + + Load image + + + + + + 110 + 340 + 681 + 41 + + + + Label info to user + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 0 + 230 + 150 + 150 + + + + + + + :/new/prefix1/Graphics/sf_2.png + + + label + registratePushButton + layoutWidget + labelImage + buttonImage + labelInfoToUser + + + + + + diff --git a/Client/settingsdialog.cpp b/Client/settingsdialog.cpp index cf6e26d..935b88d 100644 --- a/Client/settingsdialog.cpp +++ b/Client/settingsdialog.cpp @@ -13,18 +13,16 @@ #include #include -SettingsDialog::SettingsDialog(QWidget *parent) : - QDialog(parent), ui(new Ui::SettingsDialog) +/** + * Constructor of this class + */ +SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SettingsDialog) { ui->setupUi(this); helpSettingsDialog = NULL; - profileDialog = NULL; - + registerDialog = NULL; this->setWindowTitle("Settings"); - this->ui->regEMailLineEdit->setText("@"); - - ui->pushButtonProfile->setDisabled(true); if (loginSaved()) { @@ -44,20 +42,28 @@ SettingsDialog::SettingsDialog(QWidget *parent) : ui->setUserPushButton->setText("Log out"); // Button settings - ui->pushButtonInfo->setAutoFillBackground(true); - ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)"); + ui->pushButtonProfile->setAutoFillBackground(true); + ui->pushButtonProfile->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)"); ui->pushButtonProfile->setDisabled(false); + ui->pushButtonProfile->setVisible(false); } - + // Button settings ui->pushButtonInfo->setAutoFillBackground(true); ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)"); + ui->pushButtonProfile->setVisible(false); } +/** + * Destructor of this class + */ SettingsDialog::~SettingsDialog() { delete ui; } +/** + * + */ void SettingsDialog::changeEvent(QEvent *e) { QDialog::changeEvent(e); @@ -70,64 +76,23 @@ void SettingsDialog::changeEvent(QEvent *e) } } -// -// Registrate -// +/** + * This slot function called when ever "register new user" -button clicked. + */ void SettingsDialog::on_registratePushButton_clicked() { - // Send username, password and email to SpeedFreak server - this->regUsername = ui->regUserNameLineEdit->text(); - this->regPassword = ui->regPasswordLineEdit->text(); - this->regEmail = ui->regEMailLineEdit->text(); - - if (this->regUsername.compare("") && this->regPassword.compare("") && this->regEmail.compare("") && this->regEmail.compare("@")) - { - emit sendregistration(); - - } - else + if(!registerDialog) { - QMessageBox::about(this, "One or more of the fields is empty", "Set username (3-12 characters), password (at least 6 characters) and valid email address"); + registerDialog = new RegisterDialog(this); } - - //close(); //using close() hides popup-window which reports error from server -} - -// Next 6 functions can be removed if Settingsdialog is implemented without -// own copy of username, password & email -void SettingsDialog::setRegUserName(QString username) -{ - this->regUsername = username; -} - -void SettingsDialog::setRegPassword(QString password) -{ - this->regPassword = password; + connect(registerDialog, SIGNAL(registrate()), this, SLOT(registrate())); + connect(registerDialog, SIGNAL(rejected()), this, SLOT(killDialog())); + registerDialog->show(); } -void SettingsDialog::setRegEmail(QString email) -{ - this->regEmail = email; -} - -QString SettingsDialog::getRegUserName() -{ - return this->regUsername; -} - -QString SettingsDialog::getRegPassword() -{ - return this->regPassword; -} - -QString SettingsDialog::getRegEmail() -{ - return this->regEmail; -} - -// -// Set / Change user -// +/** + * Set / Change user + */ void SettingsDialog::on_setUserPushButton_clicked() { if (!ui->setUserPushButton->text().compare("Log out")) @@ -167,8 +132,6 @@ void SettingsDialog::on_setUserPushButton_clicked() // Save these also to usersettings //saveLogin( this->username, this->password); - - /* // Set "Set/Change User" button text if (this->username.length() > 0) @@ -187,31 +150,49 @@ void SettingsDialog::on_setUserPushButton_clicked() // Next 4 functions can be removed if Settingsdialog is implemented without // own copy of username & password +/** + * + */ void SettingsDialog::setUserName(QString username) { this->username = username; } +/** + * + */ void SettingsDialog::setPassword(QString password) { this->password = password; } +/** + * + */ QString SettingsDialog::getUserName() { return this->username; } +/** + * + */ QString SettingsDialog::getPassword() { return this->password; } +/** + * + */ void SettingsDialog::setLabelInfoToUser(QString infoText) { this->ui->labelInfoToUser->setText(infoText); } +/** + * + */ void SettingsDialog::usernameOk(bool isOk) { if (isOk) @@ -234,13 +215,6 @@ void SettingsDialog::usernameOk(bool isOk) } } -void SettingsDialog::clearRegisterLineEdits() -{ - ui->regEMailLineEdit->setText("@"); - ui->regPasswordLineEdit->setText(""); - ui->regUserNameLineEdit->setText(""); -} - /** * This slot function called when ever info button clicked. */ @@ -265,30 +239,18 @@ void SettingsDialog::killDialog() delete helpSettingsDialog; helpSettingsDialog = NULL; } - if(profileDialog) + if(registerDialog) { - qDebug() << "__Settings kill: profileDialog"; - delete profileDialog; - profileDialog = NULL; + qDebug() << "__Settings kill: registerDialog"; + delete registerDialog; + registerDialog = NULL; } } /** - * This slot function called when ever profile button clicked. - * Open profile dialog. + * This slot function called when */ -void SettingsDialog::on_pushButtonProfile_clicked() -{ - if(!profileDialog) - { - profileDialog = new ProfileDialog(this); - } - connect(profileDialog, SIGNAL(saveprofile()), this, SLOT(saveProfile())); - connect(profileDialog, SIGNAL(rejected()), this, SLOT(killDialog())); - profileDialog->show(); -} - -void SettingsDialog::saveProfile() +void SettingsDialog::registrate() { - emit saveprofile(); + emit sendregistration(); } diff --git a/Client/settingsdialog.h b/Client/settingsdialog.h index 0cef1d9..4c62817 100644 --- a/Client/settingsdialog.h +++ b/Client/settingsdialog.h @@ -12,7 +12,7 @@ #include #include "instructionsdialog.h" #include -#include +#include namespace Ui { class SettingsDialog; @@ -24,45 +24,33 @@ public: SettingsDialog(QWidget *parent = 0); ~SettingsDialog(); HelpSettingsDialog *helpSettingsDialog; - ProfileDialog *profileDialog; - void setRegUserName(QString username); - void setRegPassword(QString password); - void setRegEmail(QString email); - QString getRegUserName(); - QString getRegPassword(); - QString getRegEmail(); + RegisterDialog *registerDialog; void setUserName(QString username); void setPassword(QString password); QString getUserName(); QString getPassword(); void setLabelInfoToUser(QString infoText); void usernameOk(bool isOk); - void clearRegisterLineEdits(); signals: void sendregistration(); void userNameChanged(); void logout(); - void saveprofile(); protected: void changeEvent(QEvent *e); private: Ui::SettingsDialog *ui; - QString regUsername; - QString regPassword; - QString regEmail; QString username; QString password; private slots: - void on_pushButtonProfile_clicked(); void on_pushButtonInfo_clicked(); void on_setUserPushButton_clicked(); void on_registratePushButton_clicked(); void killDialog(); - void saveProfile(); + void registrate(); }; #endif // SETTINGSDIALOG_H diff --git a/Client/settingsdialog.ui b/Client/settingsdialog.ui index dc0caae..eadfa97 100644 --- a/Client/settingsdialog.ui +++ b/Client/settingsdialog.ui @@ -16,8 +16,8 @@ - 50 - 210 + 60 + 20 371 31 @@ -34,52 +34,35 @@ - 540 - 270 - 221 - 51 + 580 + 70 + 140 + 60 Log in - - - - 40 - 0 - 271 - 31 - - - - - 13 - - - - Register new user: - - - 540 - 80 - 221 - 51 + 580 + 240 + 140 + 60 - Register + Register +new user - 100 - 240 + 110 + 50 401 101 @@ -135,7 +118,7 @@ 100 340 - 501 + 691 41 @@ -143,81 +126,6 @@ - - - - 100 - 37 - 401 - 141 - - - - - - - New username: - - - - - - - - Bitstream Charter - 14 - - - - 12 - - - - - - - New password: - - - - - - - - Bitstream Charter - 14 - - - - 255 - - - QLineEdit::Password - - - - - - - Email: - - - - - - - - Bitstream Charter - 14 - - - - 255 - - - - - @@ -260,31 +168,26 @@ - 640 + 730 180 - 93 - 27 + 61 + 21 - Profile + profile label setUserLabel setUserPushButton - registrateLabel registratePushButton layoutWidget - labelInfoToUser - layoutWidget pushButtonInfo pushButtonProfile + labelInfoToUser - regUserNameLineEdit - regPasswordLineEdit - regEMailLineEdit registratePushButton setUserUsernameLineEdit setUserPasswordLineEdit diff --git a/Client/speedfreak.pro b/Client/speedfreak.pro index 0c954a7..b5682e5 100644 --- a/Client/speedfreak.pro +++ b/Client/speedfreak.pro @@ -40,8 +40,9 @@ SOURCES += main.cpp \ helpsettingsdialog.cpp \ custombutton.cpp \ profiledialog.cpp \ - filereader.cpp \ - usersdialog.cpp + filereader.cpp \ + usersdialog.cpp \ + registerdialog.cpp HEADERS += mainwindow.h \ creditsdialog.h \ routedialog.h \ @@ -72,8 +73,9 @@ HEADERS += mainwindow.h \ helpsettingsdialog.h \ custombutton.h \ profiledialog.h \ - filereader.h \ - usersdialog.h + filereader.h \ + usersdialog.h \ + registerdialog.h FORMS += mainwindow.ui \ creditsdialog.ui \ routedialog.ui \ @@ -92,7 +94,8 @@ FORMS += mainwindow.ui \ helproutingdialog.ui \ helpsettingsdialog.ui \ profiledialog.ui \ - usersdialog.ui + usersdialog.ui \ + registerdialog.ui RESOURCES += graphics.qrc contains(QT_CONFIG, hildon):CONFIG += hildon CONFIG += link_pkgconfig diff --git a/Client/usersettings.cpp b/Client/usersettings.cpp index be95562..2c79cad 100644 --- a/Client/usersettings.cpp +++ b/Client/usersettings.cpp @@ -2,6 +2,7 @@ * UserSettings class * * @author Olavi Pulkkinen + * @author Toni Jussila * @copyright (c) 2010 Speed Freak team * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ @@ -60,7 +61,7 @@ void saveLogin( QString userName, QString password) myLogin.writeLoginSettings( userName, password); } -/* +/** * Function to test if login info saved. * Returns true if so. */ diff --git a/Client/xmlwriter.cpp b/Client/xmlwriter.cpp index cb97457..027e0ba 100644 --- a/Client/xmlwriter.cpp +++ b/Client/xmlwriter.cpp @@ -27,12 +27,19 @@ XmlWriter::~XmlWriter() } /** - *@brief Writes registration items into tags. - *@param netbuf a buffer where xmlstreamwriter writes to. - *@param usr for user name. - *@param psswd for password. - *@param email. + * @brief Writes registration items into tags. + * @param netbuf a buffer where xmlstreamwriter writes to. + * @param usr for user name. + * @param psswd for password. + * @param email. + * @param . + * @param . + * @param . + * @param . + * @param . */ +//void XmlWriter::writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QString email) +//void XmlWriter::writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QString email, QString manufacturer, QString type, QString model, QString description, QString picture) void XmlWriter::writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QString email, QString description) { qDebug() << "_writeRegistering"; @@ -42,18 +49,22 @@ void XmlWriter::writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QS xmlwriter.writeStartDocument(); xmlwriter.writeStartElement("user"); + //test827 xmlwriter.writeStartElement("login"); xmlwriter.writeCharacters(usr); xmlwriter.writeEndElement(); + //thisisaveryinsecurepassword xmlwriter.writeStartElement("password"); xmlwriter.writeCharacters(psswd); xmlwriter.writeEndElement(); + //test@example.com xmlwriter.writeStartElement("email"); xmlwriter.writeCharacters(email); xmlwriter.writeEndElement(); + //manufacturer;type;model;description xmlwriter.writeStartElement("description"); xmlwriter.writeCharacters(description); xmlwriter.writeEndElement(); @@ -90,14 +101,15 @@ void XmlWriter::writeGpsTrack(QBuffer *netbuf, int counter, int start, int stop, { qDebug() << "_writeGpsTrack"; - double *ptrValue; + // Unused variables + //double *ptrValue; //ptrValue = ptrTable; - double tmp = 0; + //double tmp = 0; + int sTart = start; + int sTop = stop; xmlwriter.setDevice(netbuf); - xmlwriter.writeStartDocument(); - xmlwriter.writeStartElement("Route"); xmlwriter.writeAttribute("starttime", QDateTime::currentDateTime().toString()); xmlwriter.writeAttribute("endtime", QDateTime::currentDateTime().toString()); diff --git a/Client/xmlwriter.h b/Client/xmlwriter.h index 0d20d4b..e2ea6ca 100644 --- a/Client/xmlwriter.h +++ b/Client/xmlwriter.h @@ -36,6 +36,8 @@ private: QXmlStreamWriter xmlwriter; public slots: + //void writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QString email); + //void writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QString email, QString manufacturer, QString type, QString model, QString description, QString picture); void writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QString email, QString description); void writeResult(QBuffer *netbuf, double result); void writeGpsTrack(QBuffer *netbuf, int counter, int start, int stop, int lat, int lon, int alt, int speed, int time);