Added new Register dialog.
authorToni Jussila <toni.jussila@gmail.com>
Thu, 27 May 2010 07:06:42 +0000 (10:06 +0300)
committerToni Jussila <toni.jussila@gmail.com>
Thu, 27 May 2010 07:06:42 +0000 (10:06 +0300)
12 files changed:
Client/httpclient.cpp
Client/profiledialog.cpp
Client/registerdialog.cpp [new file with mode: 0644]
Client/registerdialog.h [new file with mode: 0644]
Client/registerdialog.ui [new file with mode: 0644]
Client/settingsdialog.cpp
Client/settingsdialog.h
Client/settingsdialog.ui
Client/speedfreak.pro
Client/usersettings.cpp
Client/xmlwriter.cpp
Client/xmlwriter.h

index 08e1695..3169730 100644 (file)
@@ -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<QNetworkReply*>(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");
         }
     }
 }
index 82707cd..276c209 100644 (file)
@@ -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 (file)
index 0000000..b3fcd33
--- /dev/null
@@ -0,0 +1,313 @@
+#include "registerdialog.h"
+#include "ui_registerdialog.h"
+#include <QMessageBox>
+#include <QDebug>
+#include <QString>
+#include <QFileDialog>
+#include <QImage>
+#include <QPixmap>
+#include <QSize>
+#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 (file)
index 0000000..7e39209
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef REGISTERDIALOG_H
+#define REGISTERDIALOG_H
+
+#include <QDialog>
+
+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 (file)
index 0000000..5d18b66
--- /dev/null
@@ -0,0 +1,265 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RegisterDialog</class>
+ <widget class="QDialog" name="RegisterDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>380</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QPushButton" name="registratePushButton">
+   <property name="geometry">
+    <rect>
+     <x>670</x>
+     <y>270</y>
+     <width>120</width>
+     <height>60</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Register</string>
+   </property>
+  </widget>
+  <widget class="QWidget" name="layoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>200</x>
+     <y>0</y>
+     <width>401</width>
+     <height>341</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="0" column="0">
+     <widget class="QLabel" name="regUsernameLabel">
+      <property name="text">
+       <string>Username:</string>
+      </property>
+     </widget>
+    </item>
+    <item row="0" column="1">
+     <widget class="QLineEdit" name="regUserNameLineEdit">
+      <property name="font">
+       <font>
+        <family>Bitstream Charter</family>
+        <pointsize>14</pointsize>
+       </font>
+      </property>
+      <property name="maxLength">
+       <number>12</number>
+      </property>
+     </widget>
+    </item>
+    <item row="1" column="0">
+     <widget class="QLabel" name="regPasswordLabel">
+      <property name="text">
+       <string>Password:</string>
+      </property>
+     </widget>
+    </item>
+    <item row="1" column="1">
+     <widget class="QLineEdit" name="regPasswordLineEdit">
+      <property name="font">
+       <font>
+        <family>Bitstream Charter</family>
+        <pointsize>14</pointsize>
+       </font>
+      </property>
+      <property name="maxLength">
+       <number>255</number>
+      </property>
+      <property name="echoMode">
+       <enum>QLineEdit::Password</enum>
+      </property>
+     </widget>
+    </item>
+    <item row="2" column="0">
+     <widget class="QLabel" name="regEMailLabel">
+      <property name="text">
+       <string>Email:</string>
+      </property>
+     </widget>
+    </item>
+    <item row="2" column="1">
+     <widget class="QLineEdit" name="regEMailLineEdit">
+      <property name="font">
+       <font>
+        <family>Bitstream Charter</family>
+        <pointsize>14</pointsize>
+       </font>
+      </property>
+      <property name="maxLength">
+       <number>255</number>
+      </property>
+     </widget>
+    </item>
+    <item row="3" column="0">
+     <widget class="QLabel" name="labelManufacturer">
+      <property name="text">
+       <string>Manufacturer:</string>
+      </property>
+     </widget>
+    </item>
+    <item row="3" column="1">
+     <widget class="QLineEdit" name="lineEditManufacturer">
+      <property name="font">
+       <font>
+        <family>Bitstream Charter</family>
+        <pointsize>14</pointsize>
+       </font>
+      </property>
+      <property name="maxLength">
+       <number>12</number>
+      </property>
+     </widget>
+    </item>
+    <item row="4" column="0">
+     <widget class="QLabel" name="labelType">
+      <property name="text">
+       <string>Type:</string>
+      </property>
+     </widget>
+    </item>
+    <item row="4" column="1">
+     <widget class="QLineEdit" name="lineEditType">
+      <property name="font">
+       <font>
+        <family>Bitstream Charter</family>
+        <pointsize>14</pointsize>
+       </font>
+      </property>
+      <property name="maxLength">
+       <number>12</number>
+      </property>
+     </widget>
+    </item>
+    <item row="5" column="0">
+     <widget class="QLabel" name="labelModel">
+      <property name="text">
+       <string>Model:</string>
+      </property>
+     </widget>
+    </item>
+    <item row="5" column="1">
+     <widget class="QLineEdit" name="lineEditModel">
+      <property name="font">
+       <font>
+        <family>Bitstream Charter</family>
+        <pointsize>14</pointsize>
+       </font>
+      </property>
+      <property name="maxLength">
+       <number>10</number>
+      </property>
+     </widget>
+    </item>
+    <item row="6" column="0">
+     <widget class="QLabel" name="labelDescription">
+      <property name="text">
+       <string>Description:</string>
+      </property>
+     </widget>
+    </item>
+    <item row="6" column="1">
+     <widget class="QTextEdit" name="textEditDescription">
+      <property name="font">
+       <font>
+        <family>Bitstream Charter</family>
+        <pointsize>14</pointsize>
+       </font>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QLabel" name="labelImage">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>30</y>
+     <width>120</width>
+     <height>120</height>
+    </rect>
+   </property>
+   <property name="styleSheet">
+    <string notr="true">background-color: rgb(99, 99, 99);</string>
+   </property>
+   <property name="frameShape">
+    <enum>QFrame::Box</enum>
+   </property>
+   <property name="midLineWidth">
+    <number>0</number>
+   </property>
+   <property name="text">
+    <string>No image</string>
+   </property>
+   <property name="alignment">
+    <set>Qt::AlignCenter</set>
+   </property>
+   <property name="margin">
+    <number>0</number>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="buttonImage">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>160</y>
+     <width>120</width>
+     <height>60</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Load image</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="labelInfoToUser">
+   <property name="geometry">
+    <rect>
+     <x>110</x>
+     <y>340</y>
+     <width>681</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Label info to user</string>
+   </property>
+   <property name="alignment">
+    <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>230</y>
+     <width>150</width>
+     <height>150</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string/>
+   </property>
+   <property name="pixmap">
+    <pixmap resource="graphics.qrc">:/new/prefix1/Graphics/sf_2.png</pixmap>
+   </property>
+  </widget>
+  <zorder>label</zorder>
+  <zorder>registratePushButton</zorder>
+  <zorder>layoutWidget</zorder>
+  <zorder>labelImage</zorder>
+  <zorder>buttonImage</zorder>
+  <zorder>labelInfoToUser</zorder>
+ </widget>
+ <resources>
+  <include location="graphics.qrc"/>
+ </resources>
+ <connections/>
+</ui>
index cf6e26d..935b88d 100644 (file)
 #include <QMessageBox>
 #include <QDebug>
 
-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();
 }
index 0cef1d9..4c62817 100644 (file)
@@ -12,7 +12,7 @@
 #include <QDialog>
 #include "instructionsdialog.h"
 #include <helpsettingsdialog.h>
-#include <profiledialog.h>
+#include <registerdialog.h>
 
 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
index dc0caae..eadfa97 100644 (file)
@@ -16,8 +16,8 @@
   <widget class="QLabel" name="setUserLabel">
    <property name="geometry">
     <rect>
-     <x>50</x>
-     <y>210</y>
+     <x>60</x>
+     <y>20</y>
      <width>371</width>
      <height>31</height>
     </rect>
   <widget class="QPushButton" name="setUserPushButton">
    <property name="geometry">
     <rect>
-     <x>540</x>
-     <y>270</y>
-     <width>221</width>
-     <height>51</height>
+     <x>580</x>
+     <y>70</y>
+     <width>140</width>
+     <height>60</height>
     </rect>
    </property>
    <property name="text">
     <string>Log in</string>
    </property>
   </widget>
-  <widget class="QLabel" name="registrateLabel">
-   <property name="geometry">
-    <rect>
-     <x>40</x>
-     <y>0</y>
-     <width>271</width>
-     <height>31</height>
-    </rect>
-   </property>
-   <property name="font">
-    <font>
-     <pointsize>13</pointsize>
-    </font>
-   </property>
-   <property name="text">
-    <string>Register new user:</string>
-   </property>
-  </widget>
   <widget class="QPushButton" name="registratePushButton">
    <property name="geometry">
     <rect>
-     <x>540</x>
-     <y>80</y>
-     <width>221</width>
-     <height>51</height>
+     <x>580</x>
+     <y>240</y>
+     <width>140</width>
+     <height>60</height>
     </rect>
    </property>
    <property name="text">
-    <string>Register</string>
+    <string>Register
+new user</string>
    </property>
   </widget>
   <widget class="QWidget" name="layoutWidget">
    <property name="geometry">
     <rect>
-     <x>100</x>
-     <y>240</y>
+     <x>110</x>
+     <y>50</y>
      <width>401</width>
      <height>101</height>
     </rect>
     <rect>
      <x>100</x>
      <y>340</y>
-     <width>501</width>
+     <width>691</width>
      <height>41</height>
     </rect>
    </property>
     <string/>
    </property>
   </widget>
-  <widget class="QWidget" name="layoutWidget">
-   <property name="geometry">
-    <rect>
-     <x>100</x>
-     <y>37</y>
-     <width>401</width>
-     <height>141</height>
-    </rect>
-   </property>
-   <layout class="QGridLayout" name="gridLayout">
-    <item row="0" column="0">
-     <widget class="QLabel" name="regUsernameLabel">
-      <property name="text">
-       <string>New username:</string>
-      </property>
-     </widget>
-    </item>
-    <item row="0" column="1">
-     <widget class="QLineEdit" name="regUserNameLineEdit">
-      <property name="font">
-       <font>
-        <family>Bitstream Charter</family>
-        <pointsize>14</pointsize>
-       </font>
-      </property>
-      <property name="maxLength">
-       <number>12</number>
-      </property>
-     </widget>
-    </item>
-    <item row="1" column="0">
-     <widget class="QLabel" name="regPasswordLabel">
-      <property name="text">
-       <string>New password:</string>
-      </property>
-     </widget>
-    </item>
-    <item row="1" column="1">
-     <widget class="QLineEdit" name="regPasswordLineEdit">
-      <property name="font">
-       <font>
-        <family>Bitstream Charter</family>
-        <pointsize>14</pointsize>
-       </font>
-      </property>
-      <property name="maxLength">
-       <number>255</number>
-      </property>
-      <property name="echoMode">
-       <enum>QLineEdit::Password</enum>
-      </property>
-     </widget>
-    </item>
-    <item row="2" column="0">
-     <widget class="QLabel" name="regEMailLabel">
-      <property name="text">
-       <string>Email:</string>
-      </property>
-     </widget>
-    </item>
-    <item row="2" column="1">
-     <widget class="QLineEdit" name="regEMailLineEdit">
-      <property name="font">
-       <font>
-        <family>Bitstream Charter</family>
-        <pointsize>14</pointsize>
-       </font>
-      </property>
-      <property name="maxLength">
-       <number>255</number>
-      </property>
-     </widget>
-    </item>
-   </layout>
-  </widget>
   <widget class="QLabel" name="label">
    <property name="geometry">
     <rect>
   <widget class="QPushButton" name="pushButtonProfile">
    <property name="geometry">
     <rect>
-     <x>640</x>
+     <x>730</x>
      <y>180</y>
-     <width>93</width>
-     <height>27</height>
+     <width>61</width>
+     <height>21</height>
     </rect>
    </property>
    <property name="text">
-    <string>Profile</string>
+    <string>profile</string>
    </property>
   </widget>
   <zorder>label</zorder>
   <zorder>setUserLabel</zorder>
   <zorder>setUserPushButton</zorder>
-  <zorder>registrateLabel</zorder>
   <zorder>registratePushButton</zorder>
   <zorder>layoutWidget</zorder>
-  <zorder>labelInfoToUser</zorder>
-  <zorder>layoutWidget</zorder>
   <zorder>pushButtonInfo</zorder>
   <zorder>pushButtonProfile</zorder>
+  <zorder>labelInfoToUser</zorder>
  </widget>
  <tabstops>
-  <tabstop>regUserNameLineEdit</tabstop>
-  <tabstop>regPasswordLineEdit</tabstop>
-  <tabstop>regEMailLineEdit</tabstop>
   <tabstop>registratePushButton</tabstop>
   <tabstop>setUserUsernameLineEdit</tabstop>
   <tabstop>setUserPasswordLineEdit</tabstop>
index 0c954a7..b5682e5 100644 (file)
@@ -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
index be95562..2c79cad 100644 (file)
@@ -2,6 +2,7 @@
  * UserSettings class
  *
  * @author     Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
+ * @author     Toni Jussila <toni.jussila@fudeco.com>
  * @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.
   */
index cb97457..027e0ba 100644 (file)
@@ -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");
 
+    //<login>test827</login>
     xmlwriter.writeStartElement("login");
     xmlwriter.writeCharacters(usr);
     xmlwriter.writeEndElement();
 
+    //<password>thisisaveryinsecurepassword</password>
     xmlwriter.writeStartElement("password");
     xmlwriter.writeCharacters(psswd);
     xmlwriter.writeEndElement();
 
+    //<email>test@example.com</email>
     xmlwriter.writeStartElement("email");
     xmlwriter.writeCharacters(email);
     xmlwriter.writeEndElement();
 
+    //<description>manufacturer;type;model;description</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());
index 0d20d4b..e2ea6ca 100644 (file)
@@ -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);