Merge branch 'development/carmainwindow'
authorToni Jussila <toni.jussila@fudeco.com>
Fri, 5 Mar 2010 12:32:01 +0000 (14:32 +0200)
committerToni Jussila <toni.jussila@fudeco.com>
Fri, 5 Mar 2010 12:32:01 +0000 (14:32 +0200)
Client/carmainwindow.cpp
Client/carmainwindow.ui
Client/loginwindow.cpp
Client/loginwindow.h
Client/measuredialog.cpp
Client/measures.cpp
Client/registration.cpp
Client/registration.h
Client/resultdialog.cpp

index 9b54df5..26cb811 100644 (file)
@@ -229,3 +229,14 @@ void CarMainWindow::on_comboBoxTopCategory_activated(QString category)
 {
     setListViewTopList(category);
 }
+
+/**
+  *This slot function is called when set/change user button is clicked.
+  */
+void CarMainWindow::on_setUserPushButton_clicked()
+{
+    myLogin->show();
+
+    ui->userNameLabel->setText( "User: " + myLogin->getUserName());
+    ui->setUserPushButton->setText( "Change User");
+}
index 43adb32..0df2dae 100644 (file)
@@ -24,7 +24,7 @@
      </rect>
     </property>
     <property name="currentIndex">
-     <number>0</number>
+     <number>2</number>
     </property>
     <widget class="QWidget" name="StartTab">
      <attribute name="title">
      <attribute name="title">
       <string>Settings</string>
      </attribute>
+     <widget class="QLabel" name="userNameLabel">
+      <property name="geometry">
+       <rect>
+        <x>20</x>
+        <y>30</y>
+        <width>141</width>
+        <height>17</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>User:</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="setUserPushButton">
+      <property name="geometry">
+       <rect>
+        <x>20</x>
+        <y>60</y>
+        <width>93</width>
+        <height>27</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Set User</string>
+      </property>
+     </widget>
     </widget>
    </widget>
    <widget class="QWidget" name="layoutWidget">
      </item>
     </layout>
    </widget>
-   <widget class="QPushButton" name="loginLogoutButton">
-    <property name="geometry">
-     <rect>
-      <x>690</x>
-      <y>0</y>
-      <width>93</width>
-      <height>27</height>
-     </rect>
-    </property>
-    <property name="text">
-     <string>Login</string>
-    </property>
-   </widget>
    <widget class="QPushButton" name="registratePushButton">
     <property name="geometry">
      <rect>
-      <x>580</x>
+      <x>690</x>
       <y>0</y>
       <width>93</width>
       <height>27</height>
index 0b4e6cf..e8b816b 100644 (file)
@@ -32,14 +32,36 @@ void LoginWindow::on_cancelPushButton_clicked()
     close();
 }
 
+void setUser(QString uN, QString pW);
+
 void LoginWindow::on_loginPushButton_clicked()
 {
-    // To do
-    //loginToServer(ui->userNameLineEdit->text(),
-    //              ui->passwordLineEdit->text());
-    //close();
-    QMessageBox::about(this,"Login",ui->userNameLineEdit->text()+ui->passwordLineEdit->text());
+    this->username = ui->userNameLineEdit->text();
+    this->password = ui->passwordLineEdit->text();
+    close();
+}
+
+void LoginWindow::setUserName(QString username)
+{
+    this->username = username;
+}
+
+void LoginWindow::setPassword(QString password)
+{
+    this->password = password;
 }
 
+QString LoginWindow::getUserName()
+{
+    return this->username;
+}
+
+QString LoginWindow::getPassword()
+{
+    return this->password;
+}
+
+
+
 
 
index b5f9c1b..51c5a2c 100644 (file)
@@ -12,12 +12,18 @@ class LoginWindow : public QDialog {
 public:
     LoginWindow(QWidget *parent = 0);
     ~LoginWindow();
+    void setUserName(QString username);
+    void setPassword(QString password);
+    QString getUserName();
+    QString getPassword();
 
 protected:
     void changeEvent(QEvent *e);
 
 private:
     Ui::LoginWindow *ui;
+    QString username;
+    QString password;
 
 private slots:
     void on_loginPushButton_clicked();
index 038116a..7e65537 100644 (file)
@@ -3,8 +3,8 @@
 
 
 /**
-  *Constructor of this class.
-  *@param QWidget pointer to parent object. By default the value is NULL.
+  * Constructor of this class.
+  * @param QWidget pointer to parent object. By default the value is NULL.
   */
 MeasureDialog::MeasureDialog(QWidget *parent) :
     QDialog(parent),
@@ -49,7 +49,8 @@ void MeasureDialog::changeEvent(QEvent *e)
 }
 
 /**
-  *This slot function is called when timer gives timeout signal.
+  * This slot function is called when timer gives timeout signal. Checks current speed
+  * and stores times in measure class.
   */
 void MeasureDialog::after_timeout()
 {
@@ -59,7 +60,7 @@ void MeasureDialog::after_timeout()
     speed = accelerometer->getCurrentSpeed();
     //speed = speed +10;
 
-    if(speed > 9.7 && speed < 10.3)
+    if (speed > 9.7 && speed < 10.3)
     {
         measures->setTime10kmh(time);
     }
@@ -139,7 +140,7 @@ void MeasureDialog::after_timeout()
 }
 
 /**
-  *This slot function is called when Abort button is clicked.
+  * This slot function is called when Abort button is clicked.
   */
 void MeasureDialog::on_pushButtonAbort_clicked()
 {
@@ -160,6 +161,9 @@ void MeasureDialog::on_pushButtonAbort_clicked()
     this->close();
 }
 
+/**
+  * Initializes measures class's member variables.
+  */
 void MeasureDialog::initializeMeasures()
 {
     measures->setTime10kmh(0);
index c840ec0..bf277f8 100644 (file)
@@ -4,6 +4,10 @@ Measures::Measures()
 {
 }
 
+/**
+ * Get the value of time10kmh
+ * @return time10kmh the time in qreal when speed has been 10 km/h
+ */
 qreal Measures::getTime10kmh()
 {
     return time10kmh;
@@ -54,6 +58,10 @@ qreal Measures::getTime100kmh()
     return time100kmh;
 }
 
+/**
+ * Set the given time in to the time10kmh
+ * @param pTime is time in qreal
+ */
 void Measures::setTime10kmh(qreal pTime)
 {
     time10kmh = pTime;
index de79f57..eae469f 100644 (file)
@@ -30,11 +30,11 @@ void Registration::changeEvent(QEvent *e)
 void Registration::on_registratePushButton_clicked()
 {
     // Send username, password and email to SpeedFreak server
-    //close();  // Needs some new signal/slot to go forward or ???
-    //registrateToServer(ui->newUsernameLineEdit->text(),
-    //                   ui->newPasswordLineEdit->text(),
-    //                   ui->eMailLineEdit->text());
-    QMessageBox::about(this,"Registrate",ui->newUsernameLineEdit->text()+ui->newPasswordLineEdit->text()+ui->eMailLineEdit->text());
+    this->username = ui->newUsernameLineEdit->text();
+    this->password = ui->newPasswordLineEdit->text();
+    this->email = ui->eMailLineEdit->text();
+
+    close();
 }
 
 void Registration::on_cancelPushButton_clicked()
@@ -42,3 +42,32 @@ void Registration::on_cancelPushButton_clicked()
     close();
 }
 
+void Registration::setUserName(QString username)
+{
+    this->username = username;
+}
+
+void Registration::setPassword(QString password)
+{
+    this->password = password;
+}
+
+void Registration::setEmail(QString password)
+{
+    this->email = email;
+}
+
+QString Registration::getUserName()
+{
+    return this->username;
+}
+
+QString Registration::getPassword()
+{
+    return this->password;
+}
+
+QString Registration::getEmail()
+{
+    return this->email;
+}
index 6a7df95..87b049d 100644 (file)
@@ -12,12 +12,21 @@ class Registration : public QDialog {
 public:
     Registration(QWidget *parent = 0);
     ~Registration();
+    void setUserName(QString username);
+    void setPassword(QString password);
+    void setEmail(QString email);
+    QString getUserName();
+    QString getPassword();
+    QString getEmail();
 
 protected:
     void changeEvent(QEvent *e);
 
 private:
     Ui::Registration *ui;
+    QString username;
+    QString password;
+    QString email;
 
 private slots:
     void on_cancelPushButton_clicked();
index c3b3a74..e10b46e 100644 (file)
@@ -17,6 +17,10 @@ static const int speedArray[10] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
 // Test point array for the diagram.
 QPoint points[10];
 
+/**
+  * Constructor of this class.
+  * @param QWidget pointer to parent object. By default the value is NULL.
+  */
 ResultDialog::ResultDialog(QWidget *parent) :
     QDialog(parent),
     ui(new Ui::ResultDialog)
@@ -29,6 +33,9 @@ ResultDialog::ResultDialog(QWidget *parent) :
    // ui->labelYLine->setText(ui->labelYLine->text().append(": speed/ km/h"));
 }
 
+/**
+  * Destructor of this class.  Should be used to release all allocated resources.
+  */
 ResultDialog::~ResultDialog()
 {
     delete ui;
@@ -48,7 +55,7 @@ void ResultDialog::changeEvent(QEvent *e)
 
 /**
   * Draws speed diagram to the UI
-  *
+  * @param QPaintEvent
  */
 void ResultDialog::paintEvent(QPaintEvent *)
 {
@@ -64,7 +71,7 @@ void ResultDialog::paintEvent(QPaintEvent *)
         int currentY = diagramStemStart.y();
 
         // Draws diagram's X-axel
-        for(int i = 0; i<13; i++)
+        for (int i = 0; i < 13; i++)
         {
             currentX += diagramGap;
             painter.drawLine(currentX, currentY, currentX, currentY - 10);
@@ -74,7 +81,7 @@ void ResultDialog::paintEvent(QPaintEvent *)
         currentY = diagramStemStart.y();
 
         // Draws diagram's Y-axel
-        for(int i = 0; i<10; i++)
+        for (int i = 0; i < 10; i++)
         {
             currentY -= diagramGap;
             painter.drawLine(currentX, currentY, currentX+10, currentY);
@@ -85,10 +92,10 @@ void ResultDialog::paintEvent(QPaintEvent *)
 }
 
 /**
-  *Change the given speed and time to the point for the diagram.
-  *@param aSpeed is speed which need to change, aTime is time in seconds which need to change.
-  *@return point is calculated from aSpeed and aTime.
-  **/
+  * Change the given speed and time to the point for the diagram.
+  * @param aSpeed is speed which need to change, aTime is time in seconds which need to change.
+  * @return point is calculated from aSpeed and aTime.
+  */
 QPoint ResultDialog::changeMeasuresToDiagramPoint(int aSpeed, qreal aTime)
 {
     QPoint point;
@@ -104,9 +111,9 @@ QPoint ResultDialog::changeMeasuresToDiagramPoint(int aSpeed, qreal aTime)
 }
 
 /**
-  *Saves the given measures to array.
-  *@param pMeasures has information about acceleration.
-  **/
+  * Saves the given measures to array.
+  * @param pMeasures has information about acceleration.
+  */
 void ResultDialog::saveMeasuresToArray(Measures *pMeasures)
 {
     timeArray[0] = pMeasures->getTime10kmh();
@@ -120,7 +127,7 @@ void ResultDialog::saveMeasuresToArray(Measures *pMeasures)
     timeArray[8] = pMeasures->getTime90kmh();
     timeArray[9] = pMeasures->getTime100kmh();
 
-    for(int i = 0; i < 4; i++)
+    for (int i = 0; i < 4; i++)
     {
         points[i] = changeMeasuresToDiagramPoint(speedArray[i], timeArray[i]);
     }
@@ -163,7 +170,7 @@ void ResultDialog::saveMeasuresToArray(Measures *pMeasures)
 
     this->repaint();
 
-    for(int i = 0; i < 10; i++)
+    for (int i = 0; i < 10; i++)
     {
         timeArray[i] = 0;
     }