Merge branch 'development/profiledialog'
authorToni Jussila <toni.jussila@fudeco.com>
Thu, 6 May 2010 06:45:57 +0000 (09:45 +0300)
committerToni Jussila <toni.jussila@fudeco.com>
Thu, 6 May 2010 06:45:57 +0000 (09:45 +0300)
25 files changed:
Client/categorylist.cpp
Client/creditsdialog.ui
Client/helpresultsdialog.ui
Client/httpclient.cpp
Client/httpclient.h
Client/mainwindow.cpp
Client/mainwindow.h
Client/profiledialog.cpp
Client/profiledialog.h
Client/profiledialog.ui
Client/routedialog.cpp
Client/routedialog.h
Client/routesavedialog.cpp
Client/routesavedialog.h
Client/settingsdialog.cpp
Client/settingsdialog.h
Client/settingsdialog.ui
Client/speedfreak.pro
Client/speedfreak.pro.user
Client/topresultdialog.cpp
Client/topresultdialog.ui
Client/xmlreader.cpp
Client/xmlreader.h
Client/xmlwriter.cpp
Client/xmlwriter.h

index 5ec3703..1f05ffb 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * Categorylist
  *
- * @author     Olavi Pulkkinen <olavi.pulkkinena@fudeco.com>
+ * @author     Olavi Pulkkinen  <olavi.pulkkinena@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
  */
@@ -51,6 +52,7 @@ QStringList CategoryList::getCategoryList()
   */
 void CategoryList::appendCategoryList(QString item)
 {
+    qDebug() << "__appendCategoryList";
     categoryList.append(item);
 }
 
@@ -61,6 +63,7 @@ void CategoryList::appendCategoryList(QString item)
   */
 void CategoryList::fillCategoryList(int index, QString item)
 {
+    qDebug() << "__fillCategoryList";
     categoryList.insert(index, item);
 }
 
@@ -70,6 +73,7 @@ void CategoryList::fillCategoryList(int index, QString item)
   */
 QString CategoryList::itemOfCategoryList(int index)
 {
+    qDebug() << "__itemOfCategoryList";
     return categoryList.at(index);
 }
 
@@ -78,6 +82,7 @@ QString CategoryList::itemOfCategoryList(int index)
   */
 void CategoryList::clearCategoryList()
 {
+    qDebug() << "__clearCategoryList";
     categoryList.clear();
 }
 
@@ -86,6 +91,7 @@ void CategoryList::clearCategoryList()
   */
 int CategoryList::sizeOfCategoryList()
 {
+    qDebug() << "__sizeOfCategoryList";
     return categoryList.size();
 }
 
@@ -98,6 +104,7 @@ int CategoryList::sizeOfCategoryList()
   */
 void CategoryList::appendCats(int ind, QString des, QString uni, QString cat)
 {
+    qDebug() << "__appendCats";
     cats[ind].description = des;
     cats[ind].unit = uni;
     cats[ind].category = cat;
@@ -109,6 +116,7 @@ void CategoryList::appendCats(int ind, QString des, QString uni, QString cat)
   */
 QString CategoryList::getRecentDescription(int ind)
 {
+    qDebug() << "__getRecentDescription";
     return cats[ind].description;
 }
 
@@ -118,6 +126,7 @@ QString CategoryList::getRecentDescription(int ind)
   */
 QString CategoryList::getRecentCategory(int ind)
 {
+    qDebug() << "__getRecentCategory";
     return cats[ind].category;
 }
 
@@ -126,6 +135,7 @@ QString CategoryList::getRecentCategory(int ind)
   */
 void CategoryList::clearCats()
 {
+    qDebug() << "__clearCats";
     for(int i = 0; i < 20; i++)
     {
         cats[i].description.clear();
index 6c4e306..c326ba2 100644 (file)
   <property name="windowTitle">
    <string>Dialog</string>
   </property>
-  <widget class="QLabel" name="label">
-   <property name="geometry">
-    <rect>
-     <x>20</x>
-     <y>10</y>
-     <width>761</width>
-     <height>61</height>
-    </rect>
-   </property>
-   <property name="font">
-    <font>
-     <pointsize>40</pointsize>
-    </font>
-   </property>
-   <property name="text">
-    <string>SpeedFreak</string>
-   </property>
-   <property name="alignment">
-    <set>Qt::AlignCenter</set>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_10">
+  <widget class="QLabel" name="labelTheFollowing">
    <property name="geometry">
     <rect>
      <x>70</x>
@@ -50,7 +29,7 @@
     <set>Qt::AlignCenter</set>
    </property>
   </widget>
-  <widget class="QLabel" name="label_11">
+  <widget class="QLabel" name="labelGraphicAndIconsBy">
    <property name="geometry">
     <rect>
      <x>70</x>
@@ -77,7 +56,7 @@
    </property>
    <layout class="QGridLayout" name="gridLayout">
     <item row="0" column="0">
-     <widget class="QLabel" name="label_2">
+     <widget class="QLabel" name="labelKaiRasilainen">
       <property name="font">
        <font>
         <pointsize>10</pointsize>
@@ -92,7 +71,7 @@
      </widget>
     </item>
     <item row="0" column="1">
-     <widget class="QLabel" name="label_6">
+     <widget class="QLabel" name="labelArtemDaniliants">
       <property name="font">
        <font>
         <pointsize>10</pointsize>
      </widget>
     </item>
     <item row="0" column="2">
-     <widget class="QLabel" name="label_8">
+     <widget class="QLabel" name="labelTiinaKivilinnaKorhola">
       <property name="font">
        <font>
         <pointsize>10</pointsize>
      </widget>
     </item>
     <item row="0" column="3">
-     <widget class="QLabel" name="label_5">
+     <widget class="QLabel" name="labelJanneAnakkala">
       <property name="font">
        <font>
         <pointsize>10</pointsize>
      </widget>
     </item>
     <item row="1" column="0">
-     <widget class="QLabel" name="label_3">
+     <widget class="QLabel" name="labelRikhardKuutti">
       <property name="font">
        <font>
         <pointsize>10</pointsize>
      </widget>
     </item>
     <item row="1" column="1">
-     <widget class="QLabel" name="label_7">
+     <widget class="QLabel" name="labelToniJussila">
       <property name="font">
        <font>
         <pointsize>10</pointsize>
      </widget>
     </item>
     <item row="1" column="2">
-     <widget class="QLabel" name="label_9">
+     <widget class="QLabel" name="labelOlaviPulkkinen">
       <property name="font">
        <font>
         <pointsize>10</pointsize>
      </widget>
     </item>
     <item row="1" column="3">
-     <widget class="QLabel" name="label_4">
+     <widget class="QLabel" name="labelJukkaKurttila">
       <property name="font">
        <font>
         <pointsize>10</pointsize>
     </item>
    </layout>
   </widget>
+  <widget class="QLabel" name="labelSpeedFreak">
+   <property name="geometry">
+    <rect>
+     <x>170</x>
+     <y>-20</y>
+     <width>461</width>
+     <height>121</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string/>
+   </property>
+   <property name="pixmap">
+    <pixmap resource="graphics.qrc">:/new/prefix1/Graphics/speedfreak.png</pixmap>
+   </property>
+   <property name="scaledContents">
+    <bool>true</bool>
+   </property>
+  </widget>
+  <zorder>labelSpeedFreak</zorder>
+  <zorder>labelTheFollowing</zorder>
+  <zorder>labelGraphicAndIconsBy</zorder>
+  <zorder>layoutWidget</zorder>
+  <zorder>layoutWidget</zorder>
  </widget>
- <resources/>
+ <resources>
+  <include location="graphics.qrc"/>
+ </resources>
  <connections/>
 </ui>
index 7c870e8..15aae92 100644 (file)
@@ -57,7 +57,10 @@ list seeking from server.</string>
    </property>
    <property name="text">
     <string>2. Choose the category from drop box
-which results you want to see. </string>
+which results you want to see.</string>
+   </property>
+   <property name="textFormat">
+    <enum>Qt::AutoText</enum>
    </property>
   </widget>
  </widget>
index 9c32c38..d4c723c 100644 (file)
@@ -32,6 +32,11 @@ HttpClient::HttpClient(MainWindow *myCarw)
 HttpClient::~HttpClient()
 {
     qDebug() << "__~HttpClient" ;
+
+    if(myXmlwriter)
+        delete myXmlwriter;
+    if(myXmlreader)
+        delete myXmlreader;
 }
 
 /**
@@ -145,7 +150,8 @@ void HttpClient::sendRouteXml()
   */
 void HttpClient::requestTopList(QString category, QString limit)
 {
-    qDebug() << "_requestTopList" ;
+    qDebug() << "_requestTopList";
+    qDebug() << category;
 
     QString urlBase = "http://api.speedfreak-app.com/api/results/";
     QUrl qurl(urlBase + category + "/" + limit);
@@ -377,7 +383,6 @@ void HttpClient::ackOfLogin()
                myMainw->settingsDialog->usernameOk(true);
                myMainw->settingsDialog->close();    
        }
-
     }
 }
 
@@ -407,20 +412,141 @@ void HttpClient::ackOfToplist()
 {
     qDebug() << "_ackOfToplist";
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
-    myXmlreader->xmlReadTop10Results(reply);
+    myXmlreader->xmlReadTop10Results(reply,myMainw->settingsDialog->getUserName());
 
     QNetworkReply::NetworkError errorcode;
     errorcode = reply->error();
     if(errorcode != 0) {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
-        //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list",reply->errorString());
+        //Indicating user
         if(myMainw->topResultDialog)
-            myMainw->topResultDialog->setLabelInfoToUser("Error");
+        {
+            //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list",reply->errorString());
+            myMainw->topResultDialog->setLabelInfoToUser("No results ;(");
+        }
     }
     else {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
-        //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list", "OK " + reply->readAll());
+        //Indicating user
         if(myMainw->topResultDialog)
+        {
+            //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list", "OK " + reply->readAll());
             myMainw->topResultDialog->setLabelInfoToUser("");
+        }
+    }
+}
+
+/**
+  * This function sends profile to the server in xml format.
+  * Send authentication information in the header.
+  */
+void HttpClient::sendProfileXml()
+{
+    qDebug() << "_sendProfileXml";
+
+    QString userName = myMainw->settingsDialog->getUserName();
+    QString filename = userName + "_profile.xml";
+    QFile file(filename);
+    if (!file.open(QFile::ReadWrite | QFile::Text))
+    {
+        qDebug() << "_xmlWrite fail";
+        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());
+
+    //Indicating user
+    if(myMainw->settingsDialog->profileDialog)
+        myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Profile saved to phone");
+
+    QUrl qurl("http://api.speedfreak-app.com/api/profile");
+    QNetworkRequest request(qurl);
+    qDebug() << qurl.toString();
+    QNetworkReply *currentDownload;
+
+    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()));
+    bool error = connect(currentDownload, SIGNAL(finished()), this, SLOT(ackOfProfile()));
+
+    file.close();
+
+    // Send picture
+    if(myMainw->settingsDialog->profileDialog->getPicture() != "" && error == false)
+    {
+        QFile pictureFile( myMainw->settingsDialog->profileDialog->getPicture() );
+        if (!pictureFile.open(QIODevice::ReadOnly))
+        {
+            qDebug() << "__picture read fail";
+            return;
+        }
+        currentDownload = netManager->post(request, pictureFile.readAll());
+        connect(currentDownload, SIGNAL(finished()), this, SLOT(ackOfSendingPicture()));
+        pictureFile.close();
+    }
+}
+
+/**
+  * This slot function react to servers responce after request of profile has been sent.
+  */
+bool HttpClient::ackOfProfile()
+{
+    qDebug() << "__ackOfProfile";
+    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
+    QNetworkReply::NetworkError errorcode;
+    errorcode = reply->error();
+    if(errorcode != 0) {
+        qDebug() <<  "errorcode:" << errorcode << reply->errorString();
+        //Indicating user
+        if(myMainw->settingsDialog->profileDialog)
+        {
+            //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting profile",reply->errorString());
+            myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Profile save to server - fail");
+            return true;
+        }
+    }
+    else {
+        qDebug() <<  "errorcode:" << errorcode << reply->errorString();
+        //Indicating user
+        if(myMainw->settingsDialog->profileDialog)
+        {
+            //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting profile", "OK " + reply->readAll());
+            myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Profile saved to server");
+            return false;
+        }
+    }
+}
+/**
+  * This slot function react to servers responce after request of picture has been sent.
+  */
+void HttpClient::ackOfSendingPicture()
+{
+    qDebug() << "__ackOfSendingPicture";
+    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
+    QNetworkReply::NetworkError errorcode;
+    errorcode = reply->error();
+    if(errorcode != 0) {
+        qDebug() <<  "errorcode:" << errorcode << reply->errorString();
+        //Indicating user
+        if(myMainw->settingsDialog->profileDialog)
+        {
+            //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting picture",reply->errorString());
+            myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Picture save to server - fail");
+        }
+    }
+    else {
+        qDebug() <<  "errorcode:" << errorcode << reply->errorString();
+        //Indicating user
+        if(myMainw->settingsDialog->profileDialog)
+        {
+            //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting picture", "OK " + reply->readAll());
+            myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Picture saved to server");
+        }
     }
 }
index 772d1b8..2c4bd84 100644 (file)
@@ -48,7 +48,10 @@ public slots:
     void ackOfCategories();
     void ackOfToplist();
     void ackOfLogin();
+    bool ackOfProfile();
+    void ackOfSendingPicture();
     void errorFromServer(QNetworkReply::NetworkError);
+    void sendProfileXml();
 
 };
 
index 2341248..56c7238 100644 (file)
@@ -16,6 +16,9 @@
 #include <QDebug>
 #include "usersettings.h"
 
+/**
+  *
+  */
 MainWindow::MainWindow(QWidget *parent) :
     QMainWindow(parent),
     ui(new Ui::MainWindow)
@@ -32,9 +35,10 @@ MainWindow::MainWindow(QWidget *parent) :
     topResultDialog = NULL;
 
     settingsDialog = new SettingsDialog;
-    connect(settingsDialog,SIGNAL(sendregistration()),this,SLOT(clientRegUserToServer()));
-    connect(settingsDialog,SIGNAL(userNameChanged()),this,SLOT(clientUserLogin()));
-    connect(settingsDialog, SIGNAL(logout()), this, SLOT(setUsernameToMainPanel()));
+    connect(settingsDialog, SIGNAL(sendregistration()), this, SLOT(clientRegUserToServer()));
+    connect(settingsDialog, SIGNAL(userNameChanged()),  this, SLOT(clientUserLogin()));
+    connect(settingsDialog, SIGNAL(logout()),           this, SLOT(setUsernameToMainPanel()));
+    connect(settingsDialog, SIGNAL(saveprofile()),      this, SLOT(saveProfile()));
 
     httpClient = new HttpClient(this);
     connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
@@ -99,6 +103,9 @@ MainWindow::MainWindow(QWidget *parent) :
     customButtonResults->show();
 }
 
+/**
+  *
+  */
 MainWindow::~MainWindow()
 {
     delete ui;
@@ -133,6 +140,9 @@ MainWindow::~MainWindow()
 
 }
 
+/**
+  *
+  */
 void MainWindow::changeEvent(QEvent *e)
 {
     QMainWindow::changeEvent(e);
@@ -280,6 +290,7 @@ void MainWindow::clientSendResult(QString category, double result)
             httpClient->sendResultXml(category, result);
     }
 }
+
 /**
   * This slot function called when ever dialog rejected.
   */
@@ -316,6 +327,7 @@ void MainWindow::killDialog()
         helpDialog = NULL;
     }
 }
+
 /**
   *
   */
@@ -368,3 +380,12 @@ void MainWindow::OpenResultDialog()
     connect(topResultDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
     topResultDialog->show();
 }
+
+/**
+  * This slot function save user profile data to server
+  */
+void MainWindow::saveProfile()
+{
+    if(httpClient)
+        httpClient->sendProfileXml();
+}
index 4fbdb0d..548c339 100644 (file)
@@ -77,6 +77,7 @@ private slots:
     void OpenAccStartDialog();
     void OpenRouteDialog();
     void OpenResultDialog();
+    void saveProfile();
 
 };
 
index f6ae507..4870b8a 100644 (file)
@@ -1,18 +1,89 @@
+/*
+ * Profile dialog class
+ *
+ * @author     Toni Jussila <toni.jussila@fudeco.com>
+ * @copyright  (c) 2010 Speed Freak team
+ * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+#include <QString>
+#include <QFileDialog>
+#include <QImage>
+#include <QMessageBox>
+#include <QPixmap>
+#include <QSize>
+#include <QDebug>
 #include "profiledialog.h"
 #include "ui_profiledialog.h"
+#include "usersettings.h"
+#include "settingsdialog.h"
+#include "xmlreader.h"
 
-ProfileDialog::ProfileDialog(QWidget *parent) :
-    QDialog(parent),
-    ui(new Ui::ProfileDialog)
+/**
+  * Constructor of this class.
+  * @param QWidget pointer to parent object. By default the value is NULL.
+  */
+ProfileDialog::ProfileDialog(SettingsDialog *parent) : QDialog(parent), ui(new Ui::ProfileDialog)
 {
+    qDebug() << "__ProfileDialog";
     ui->setupUi(this);
+
+    if (loginSaved())
+    {
+        this->setWindowTitle("Profile - " + parent->getUserName());
+    }
+    else
+    {
+        this->setWindowTitle("Profile");
+    }
+
+    // User info label
+    ui->labelInfoToUser->setVisible(0);
+    ui->labelInfoToUser->setText("");
+
+    // Button
+    imageButtonState = false;
+
+    manufacturer="";
+    type="";
+    model="";
+    description="";
+    picture="";
+
+    // Read user profile xml
+    QString filename = 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. Deletes all dynamic objects and sets them to NULL.
+  */
 ProfileDialog::~ProfileDialog()
 {
-    delete ui;
+    qDebug() << "__~ProfileDialog";
+
+    if(ui)
+        delete ui;
+
+    if(xmlReader)
+        delete xmlReader;
 }
 
+/**
+  *
+  */
 void ProfileDialog::changeEvent(QEvent *e)
 {
     QDialog::changeEvent(e);
@@ -24,3 +95,162 @@ void ProfileDialog::changeEvent(QEvent *e)
         break;
     }
 }
+
+/**
+  * This slot function called when image button clicked.
+  *
+  */
+void ProfileDialog::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 ProfileDialog::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;
+    }
+}
+
+/**
+  * This slot function called when save button clicked.
+  * @todo server connection
+  */
+void ProfileDialog::on_buttonSave_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();
+}
+
+/**
+  * This get function return manufacturer
+  * @return QString
+  */
+QString ProfileDialog::getManufacturer()
+{
+    return manufacturer;
+}
+
+/**
+  * This get function return type
+  * @return QString
+  */
+QString ProfileDialog::getType()
+{
+    return type;
+}
+
+/**
+  * This get function return model
+  * @return QString
+  */
+QString ProfileDialog::getModel()
+{
+    return model;
+}
+
+/**
+  * This get function return description
+  * @return QString
+  */
+QString ProfileDialog::getDescription()
+{
+    return description;
+}
+
+/**
+  * This get function return description
+  * @return QString
+  */
+QString ProfileDialog::getPicture()
+{
+    return picture;
+}
+
+/**
+  * This set function set manufacturer
+  * @param QString
+  */
+void ProfileDialog::setManufacturer(QString m)
+{
+    manufacturer = m;
+    ui->lineEditManufacturer->setText(m);
+}
+
+/**
+  * This set function set type
+  * @param QString
+  */
+void ProfileDialog::setType(QString t)
+{
+    type = t;
+    ui->lineEditType->setText(t);
+}
+
+/**
+  * This set function set model
+  * @param QString
+  */
+void ProfileDialog::setModel(QString m)
+{
+    model = m;
+    ui->lineEditModel->setText(m);
+}
+
+/**
+  * This set function set description
+  * @param QString
+  */
+void ProfileDialog::setDescription(QString d)
+{
+    description = d;
+    ui->textEditDescription->setText(d);
+}
+
+/**
+  * This set function set description
+  * @param QString
+  */
+void ProfileDialog::setPicture(QString p)
+{
+    picture = p;
+    loadPicture(p);
+}
+
+/**
+  * This function set label info text to user
+  * @param QString
+  */
+void ProfileDialog::setLabelInfoToUser(QString infoText)
+{
+    ui->labelInfoToUser->setVisible(1);
+    this->ui->labelInfoToUser->setText(infoText);
+}
index 7a0451a..a040090 100644 (file)
@@ -1,23 +1,62 @@
+/*
+ * Profile dialog class
+ *
+ * @author     Toni Jussila <toni.jussila@fudeco.com>
+ * @copyright  (c) 2010 Speed Freak team
+ * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
 #ifndef PROFILEDIALOG_H
 #define PROFILEDIALOG_H
 
 #include <QDialog>
 
-namespace Ui {
+class SettingsDialog;
+class XmlReader;
+
+namespace Ui
+{
     class ProfileDialog;
 }
 
-class ProfileDialog : public QDialog {
+class ProfileDialog : public QDialog
+{
     Q_OBJECT
 public:
-    ProfileDialog(QWidget *parent = 0);
+    ProfileDialog(SettingsDialog *parent = 0);
     ~ProfileDialog();
+    XmlReader *xmlReader;
+    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::ProfileDialog *ui;
+    bool imageButtonState;
+    void loadPicture(QString);
+    QString manufacturer;
+    QString type;
+    QString model;
+    QString description;
+    QString picture;
+
+private slots:
+    void on_buttonSave_clicked();
+    void on_buttonImage_clicked();
+
+signals:
+    void saveprofile();
 };
 
 #endif // PROFILEDIALOG_H
index 153e5bf..763f367 100644 (file)
   <property name="windowTitle">
    <string>Dialog</string>
   </property>
+  <widget class="QPushButton" name="buttonSave">
+   <property name="geometry">
+    <rect>
+     <x>660</x>
+     <y>130</y>
+     <width>120</width>
+     <height>120</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Save</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="labelImage">
+   <property name="geometry">
+    <rect>
+     <x>370</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>510</x>
+     <y>30</y>
+     <width>120</width>
+     <height>120</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Load image</string>
+   </property>
+  </widget>
+  <widget class="Line" name="line">
+   <property name="geometry">
+    <rect>
+     <x>630</x>
+     <y>10</y>
+     <width>20</width>
+     <height>361</height>
+    </rect>
+   </property>
+   <property name="orientation">
+    <enum>Qt::Vertical</enum>
+   </property>
+  </widget>
+  <widget class="QWidget" name="layoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>190</y>
+     <width>621</width>
+     <height>131</height>
+    </rect>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout_3">
+    <item>
+     <widget class="QLabel" name="labelDescription">
+      <property name="text">
+       <string>Description:</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QTextEdit" name="textEditDescription"/>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWidget" name="layoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>10</y>
+     <width>351</width>
+     <height>171</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="0" column="0">
+     <widget class="QLabel" name="labelManufacturer">
+      <property name="text">
+       <string>Manufacturer:</string>
+      </property>
+     </widget>
+    </item>
+    <item row="0" column="1">
+     <widget class="QLineEdit" name="lineEditManufacturer">
+      <property name="maxLength">
+       <number>12</number>
+      </property>
+     </widget>
+    </item>
+    <item row="1" column="0">
+     <widget class="QLabel" name="labelType">
+      <property name="text">
+       <string>Type:</string>
+      </property>
+     </widget>
+    </item>
+    <item row="1" column="1">
+     <widget class="QLineEdit" name="lineEditType">
+      <property name="maxLength">
+       <number>12</number>
+      </property>
+     </widget>
+    </item>
+    <item row="2" column="0">
+     <widget class="QLabel" name="labelModel">
+      <property name="text">
+       <string>Model:</string>
+      </property>
+     </widget>
+    </item>
+    <item row="2" column="1">
+     <widget class="QLineEdit" name="lineEditModel">
+      <property name="maxLength">
+       <number>10</number>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QLabel" name="labelInfoToUser">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>330</y>
+     <width>621</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Label info to user</string>
+   </property>
+  </widget>
  </widget>
  <resources/>
  <connections/>
index dbe0772..35f232f 100644 (file)
@@ -176,11 +176,11 @@ RouteDialog::RouteDialog(RouteSaveDialog *parent) :
     qDebug() << "__RouteDialog";
     ui->setupUi(this);
 
-    helpRoutingDialog = NULL;
-
     this->setWindowTitle("Route");
     left = 5; top = 5; right = 495; bottom = 295; // Limits in screen coordinates
 
+    helpRoutingDialog = NULL;
+
     // Button settings
     ui->sendPushButton->setAutoFillBackground(true);
     ui->sendPushButton->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
@@ -196,7 +196,8 @@ RouteDialog::RouteDialog(RouteSaveDialog *parent) :
     checkLogin();
 
     // Set average speed
-    ui->avgSpeedValueLabel->setText(QString::number(parent->getAverageSpeed()) + " km/h");
+    QString average;
+    ui->avgSpeedValueLabel->setText(average.sprintf("%.1f", parent->getAverageSpeed()) + " km/h");
     ui->distanceValueLabel->setText(parent->getDistanceTraveled() + " km");
 }
 
@@ -208,6 +209,8 @@ RouteDialog::~RouteDialog()
     qDebug() << "__~RouteDialog";
     if(ui)
         delete ui;
+    if(calibrateDialog)
+        delete calibrateDialog;
 }
 
 /**
@@ -429,13 +432,17 @@ void RouteDialog::paintEvent(QPaintEvent *)
 /**
   *
   */
-bool RouteDialog::readRouteFromFile( QString &routeFile)
- {
+bool RouteDialog::readRouteFromFile( QString &routeFile , CalibrateDialog *calibrateDialog)
+{
     QString rFile = routeFile; //Not used
     Vector temp;
     QString rivi;
     QFile file;
 
+    progresbar = calibrateDialog;
+    int progresbarValue = 0;
+    progresbar->setProgressValue(++progresbarValue);
+
     //QString fileName = QFileDialog::getOpenFileName(this,
     //     tr("Read Route"), "./", tr("Route Files (*.txt)"));
 
@@ -444,6 +451,7 @@ bool RouteDialog::readRouteFromFile( QString &routeFile)
     if (!file.open(QIODevice::ReadOnly))
     {
         QMessageBox::about(0, "Error", "File not found");
+        progresbar->setProgressValue(100);
         return false;
     }
 
@@ -559,7 +567,7 @@ bool RouteDialog::readRouteFromFile( QString &routeFile)
      */
 
      return true;
- }
+}
 
 /**
   * Find out data range for x-, y- and z-coordinates
index b3250d7..81e3584 100644 (file)
@@ -13,6 +13,7 @@
 #include <QDialog>
 #include <helproutingdialog.h>
 class RouteSaveDialog;
+class CalibrateDialog;
 
 namespace Ui {
     class RouteDialog;
@@ -24,7 +25,7 @@ class RouteDialog : public QDialog {
 public:
     RouteDialog(RouteSaveDialog *parent = 0);
     ~RouteDialog();
-    bool readRouteFromFile( QString &routeFile);
+    bool readRouteFromFile( QString &routeFile, CalibrateDialog *calibrateDialog);
     int getLeft();
     int getTop();
     int getRight();
@@ -42,6 +43,7 @@ protected:
 
 private:
     Ui::RouteDialog *ui;
+    CalibrateDialog *progresbar;
     int left, top, right, bottom;       // Limits in screen coordinates in route dialog
     void checkLogin();
 
index 6d355e6..fcccd5f 100644 (file)
@@ -11,8 +11,8 @@
 #include <QDebug>
 
 /**
-  *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.
   */
 RouteSaveDialog::RouteSaveDialog(QWidget *parent) :
     QDialog(parent), ui(new Ui::RouteSaveDialog){
@@ -25,6 +25,7 @@ RouteSaveDialog::RouteSaveDialog(QWidget *parent) :
     location = NULL;
     gpsData = NULL;
     helpRoutingDialog = NULL;
+    calibrateDialog = NULL;
 
     //Clear variables
     averageSpeed = 0.0;
@@ -62,6 +63,8 @@ RouteSaveDialog::RouteSaveDialog(QWidget *parent) :
     ui->labelGpsAvgSpeed->setVisible(0); //GPS average speed label
     ui->labelDistance->setVisible(0); //GPS distance label
     ui->labelSignalStrength->setText(""); //GPS signal strength label
+
+    // Timer
     timerRoutePicture = new QTimer();
     timerRoutePicture->setInterval(400);
     connect(timerRoutePicture, SIGNAL(timeout()),this, SLOT(timerRoutePictureTimeout()));
@@ -73,7 +76,7 @@ RouteSaveDialog::RouteSaveDialog(QWidget *parent) :
 }
 
 /**
-  *Destructor of this class. Deletes all dynamic objects and sets them to NULL.
+  * Destructor of this class. Deletes all dynamic objects and sets them to NULL.
   */
 RouteSaveDialog::~RouteSaveDialog()
 {
@@ -111,7 +114,7 @@ void RouteSaveDialog::changeEvent(QEvent *e)
 }
 
 /**
-  *This slot function is called when route start/stop button clicked.
+  * This slot function is called when route start/stop button clicked.
   */
 void RouteSaveDialog::on_buttonRouteStartStop_clicked()
 {
@@ -148,14 +151,36 @@ void RouteSaveDialog::on_buttonRouteStartStop_clicked()
         timerRoutePicture->stop();
         location->stopPollingGPS();
 
+        // Progres bar
+        if(!calibrateDialog)
+            calibrateDialog = new CalibrateDialog();
+
+        calibrateDialog->show();
+        calibrateDialog->resetProgressValue();
+        int points = 100;
+        int iteration = 0;
+        calibrateDialog->setMaxValue( points + 1 );
+
+        /*do {
+            calibrateDialog->setProgressValue(iteration);
+            iteration++;
+
+        } while(iteration != points);*/
+
         QString routeFile = QString("routetemp.xml");
-        if (routeDialog->readRouteFromFile( routeFile ) == true)
+        if (routeDialog->readRouteFromFile( routeFile , calibrateDialog) == true)
         {
             if(!routeDialog)
                 routeDialog = new RouteDialog(this);
             connect(routeDialog, SIGNAL(sendroute()), this, SLOT(sendRoute()));
+
+            calibrateDialog->close();
             routeDialog->show();
         }
+        else
+        {
+            calibrateDialog->close();
+        }
 
         //Set GPS speed labels in visible
         ui->labelGpsSpeed->setVisible(0);
@@ -173,7 +198,7 @@ void RouteSaveDialog::on_buttonRouteStartStop_clicked()
 }
 
 /**
-  *This slot function is called when satellite picture timer timeout(400ms).
+  * This slot function is called when satellite picture timer timeout(400ms).
   */
 void RouteSaveDialog::timerSatellitePictureTimeout()
 {
@@ -192,7 +217,7 @@ void RouteSaveDialog::timerSatellitePictureTimeout()
 }
 
 /**
-  *This slot function is called when route picture timer timeout(400ms).
+  * This slot function is called when route picture timer timeout(400ms).
   */
 void RouteSaveDialog::timerRoutePictureTimeout()
 {
index bb1f189..ed35e68 100644 (file)
@@ -18,6 +18,7 @@
 #include "gpsdata.h"
 #include "routedialog.h"
 #include <helproutingdialog.h>
+#include "calibratedialog.h"
 
 namespace Ui {
     class RouteSaveDialog;
@@ -42,6 +43,7 @@ private:
     QTimer *timerRoutePicture;
     GPSData *gpsData;
     Maemo5Location *location;
+    CalibrateDialog *calibrateDialog;
     QString gpsSpeed;
     QString distanceString;
     QPixmap *pixmapRouteStop;
index a50a681..cf6e26d 100644 (file)
@@ -19,10 +19,13 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
     ui->setupUi(this);
 
     helpSettingsDialog = NULL;
+    profileDialog = NULL;
 
     this->setWindowTitle("Settings");
     this->ui->regEMailLineEdit->setText("@");
 
+    ui->pushButtonProfile->setDisabled(true);
+
     if (loginSaved())
     {
         QString uName, pWord;
@@ -43,7 +46,11 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
         // Button settings
         ui->pushButtonInfo->setAutoFillBackground(true);
         ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+        ui->pushButtonProfile->setDisabled(false);
     }
+
+    ui->pushButtonInfo->setAutoFillBackground(true);
+    ui->pushButtonInfo->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
 }
 
 SettingsDialog::~SettingsDialog()
@@ -135,6 +142,7 @@ void SettingsDialog::on_setUserPushButton_clicked()
         this->password = ui->setUserPasswordLineEdit->text();
         ui->setUserPushButton->setText("Log in");
         saveLogin( this->username, this->password);
+        ui->pushButtonProfile->setDisabled(true);
         emit logout();
     }
     else
@@ -211,6 +219,7 @@ void SettingsDialog::usernameOk(bool isOk)
         ui->setUserPushButton->setText("Log out");
         ui->setUserUsernameLineEdit->setDisabled(true);
         ui->setUserPasswordLineEdit->setDisabled(true);
+        ui->pushButtonProfile->setDisabled(false);
     }
 
     else
@@ -221,6 +230,7 @@ void SettingsDialog::usernameOk(bool isOk)
         this->username = ui->setUserUsernameLineEdit->text();
         this->password = ui->setUserPasswordLineEdit->text();
         saveLogin( this->username, this->password);
+        ui->pushButtonProfile->setDisabled(true);
     }
 }
 
@@ -240,14 +250,14 @@ void SettingsDialog::on_pushButtonInfo_clicked()
     {
         helpSettingsDialog = new HelpSettingsDialog;
     }
-    connect(helpSettingsDialog, SIGNAL(rejected()), this, SLOT(killHelpDialog()));
+    connect(helpSettingsDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
     helpSettingsDialog->show();
 }
 
 /**
   * This slot function called when ever dialog rejected.
   */
-void SettingsDialog::killHelpDialog()
+void SettingsDialog::killDialog()
 {
     if(helpSettingsDialog)
     {
@@ -255,4 +265,30 @@ void SettingsDialog::killHelpDialog()
         delete helpSettingsDialog;
         helpSettingsDialog = NULL;
     }
+    if(profileDialog)
+    {
+        qDebug() << "__Settings kill: profileDialog";
+        delete profileDialog;
+        profileDialog = NULL;
+    }
+}
+
+/**
+  * This slot function called when ever profile button clicked.
+  * Open profile dialog.
+  */
+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()
+{
+    emit saveprofile();
 }
index 4f5858b..0cef1d9 100644 (file)
@@ -12,6 +12,7 @@
 #include <QDialog>
 #include "instructionsdialog.h"
 #include <helpsettingsdialog.h>
+#include <profiledialog.h>
 
 namespace Ui {
     class SettingsDialog;
@@ -23,6 +24,7 @@ public:
     SettingsDialog(QWidget *parent = 0);
     ~SettingsDialog();
     HelpSettingsDialog *helpSettingsDialog;
+    ProfileDialog *profileDialog;
     void setRegUserName(QString username);
     void setRegPassword(QString password);
     void setRegEmail(QString email);
@@ -41,6 +43,7 @@ signals:
     void sendregistration();
     void userNameChanged();
     void logout();
+    void saveprofile();
 
 protected:
     void changeEvent(QEvent *e);
@@ -54,10 +57,12 @@ private:
     QString password;
 
 private slots:
+    void on_pushButtonProfile_clicked();
     void on_pushButtonInfo_clicked();
     void on_setUserPushButton_clicked();
     void on_registratePushButton_clicked();
-    void killHelpDialog();
+    void killDialog();
+    void saveProfile();
 };
 
 #endif // SETTINGSDIALOG_H
index bf6e945..dc0caae 100644 (file)
     </size>
    </property>
   </widget>
+  <widget class="QPushButton" name="pushButtonProfile">
+   <property name="geometry">
+    <rect>
+     <x>640</x>
+     <y>180</y>
+     <width>93</width>
+     <height>27</height>
+    </rect>
+   </property>
+   <property name="text">
+    <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>
  </widget>
  <tabstops>
   <tabstop>regUserNameLineEdit</tabstop>
index 74cc7e2..d3d50a2 100644 (file)
@@ -38,7 +38,8 @@ SOURCES += main.cpp \
     helpaccelerationdialog.cpp \
     helproutingdialog.cpp \
     helpsettingsdialog.cpp \
-    custombutton.cpp
+    custombutton.cpp \
+    profiledialog.cpp
 HEADERS += mainwindow.h \
     creditsdialog.h \
     routedialog.h \
@@ -67,7 +68,8 @@ HEADERS += mainwindow.h \
     helpaccelerationdialog.h \
     helproutingdialog.h \
     helpsettingsdialog.h \
-    custombutton.h
+    custombutton.h \
+    profiledialog.h
 FORMS += mainwindow.ui \
     creditsdialog.ui \
     routedialog.ui \
@@ -84,7 +86,8 @@ FORMS += mainwindow.ui \
     helpresultsdialog.ui \
     helpaccelerationdialog.ui \
     helproutingdialog.ui \
-    helpsettingsdialog.ui
+    helpsettingsdialog.ui \
+    profiledialog.ui
 RESOURCES += graphics.qrc
 contains(QT_CONFIG, hildon):CONFIG += hildon
 CONFIG += link_pkgconfig
index 37bd8d7..d4093ca 100644 (file)
   <variable>buildconfiguration-Debug-buildstep0</variable>
   <valuemap type="QVariantMap">
    <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
+   <valuelist key="abstractProcess.Environment" type="QVariantList">
+    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-qiZb4Pleu0,guid=dfa9e6bbffd50dabf30f2a694bda6acd</value>
+    <value type="QString">DESKTOP_SESSION=gnome</value>
+    <value type="QString">DISPLAY=:0.0</value>
+    <value type="QString">GDMSESSION=gnome</value>
+    <value type="QString">GDM_KEYBOARD_LAYOUT=fi</value>
+    <value type="QString">GDM_LANG=fi_FI.UTF-8</value>
+    <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
+    <value type="QString">GNOME_KEYRING_PID=1664</value>
+    <value type="QString">GNOME_KEYRING_SOCKET=/tmp/keyring-BU1Ggo/socket</value>
+    <value type="QString">GTK_MODULES=canberra-gtk-module</value>
+    <value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/oppilas/.gtkrc-1.2-gnome2</value>
+    <value type="QString">HOME=/home/oppilas</value>
+    <value type="QString">LANG=fi_FI.UTF-8</value>
+    <value type="QString">LD_LIBRARY_PATH=/opt/qtsdk-2010.02/lib/qtcreator:</value>
+    <value type="QString">LOGNAME=oppilas</value>
+    <value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-oppilas</value>
+    <value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
+    <value type="QString">PWD=/home/oppilas</value>
+    <value type="QString">QTDIR=/usr/share/qt4</value>
+    <value type="QString">SESSION_MANAGER=local/ubuntu:@/tmp/.ICE-unix/1679,unix/ubuntu:/tmp/.ICE-unix/1679</value>
+    <value type="QString">SHELL=/bin/bash</value>
+    <value type="QString">SPEECHD_PORT=7560</value>
+    <value type="QString">SSH_AGENT_PID=1719</value>
+    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-BU1Ggo/socket.ssh</value>
+    <value type="QString">USER=oppilas</value>
+    <value type="QString">USERNAME=oppilas</value>
+    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-oppilas-CUBiAz/database</value>
+    <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
+    <value type="QString">XDG_SESSION_COOKIE=7bed32bdbfbd7579c7bbdbcd4bbc8b02-1272605389.226561-886088294</value>
+   </valuelist>
+   <valuelist key="abstractProcess.arguments" type="QVariantList">
+    <value type="QString">/scratchbox/users/oppilas/home/oppilas/qt_codes/garage.git/speedfreak/Client/speedfreak.pro</value>
+    <value type="QString">-spec</value>
+    <value type="QString">linux-g++</value>
+    <value type="QString">-r</value>
+    <value type="QString">CONFIG+=debug</value>
+   </valuelist>
+   <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value>
+   <value key="abstractProcess.enabled" type="bool">false</value>
+   <value key="abstractProcess.workingDirectory" type="QString">/scratchbox/users/oppilas/home/oppilas/qt_codes/garage.git/speedfreak/Client</value>
   </valuemap>
  </data>
  <data>
   <variable>buildconfiguration-Debug-buildstep1</variable>
   <valuemap type="QVariantMap">
    <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
+   <valuelist key="abstractProcess.Environment" type="QVariantList">
+    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-qiZb4Pleu0,guid=dfa9e6bbffd50dabf30f2a694bda6acd</value>
+    <value type="QString">DESKTOP_SESSION=gnome</value>
+    <value type="QString">DISPLAY=:0.0</value>
+    <value type="QString">GDMSESSION=gnome</value>
+    <value type="QString">GDM_KEYBOARD_LAYOUT=fi</value>
+    <value type="QString">GDM_LANG=fi_FI.UTF-8</value>
+    <value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
+    <value type="QString">GNOME_KEYRING_PID=1664</value>
+    <value type="QString">GNOME_KEYRING_SOCKET=/tmp/keyring-BU1Ggo/socket</value>
+    <value type="QString">GTK_MODULES=canberra-gtk-module</value>
+    <value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/oppilas/.gtkrc-1.2-gnome2</value>
+    <value type="QString">HOME=/home/oppilas</value>
+    <value type="QString">LANG=fi_FI.UTF-8</value>
+    <value type="QString">LD_LIBRARY_PATH=/opt/qtsdk-2010.02/lib/qtcreator:</value>
+    <value type="QString">LOGNAME=oppilas</value>
+    <value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-oppilas</value>
+    <value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
+    <value type="QString">PWD=/home/oppilas</value>
+    <value type="QString">QTDIR=/usr/share/qt4</value>
+    <value type="QString">SESSION_MANAGER=local/ubuntu:@/tmp/.ICE-unix/1679,unix/ubuntu:/tmp/.ICE-unix/1679</value>
+    <value type="QString">SHELL=/bin/bash</value>
+    <value type="QString">SPEECHD_PORT=7560</value>
+    <value type="QString">SSH_AGENT_PID=1719</value>
+    <value type="QString">SSH_AUTH_SOCK=/tmp/keyring-BU1Ggo/socket.ssh</value>
+    <value type="QString">USER=oppilas</value>
+    <value type="QString">USERNAME=oppilas</value>
+    <value type="QString">XAUTHORITY=/var/run/gdm/auth-for-oppilas-CUBiAz/database</value>
+    <value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
+    <value type="QString">XDG_SESSION_COOKIE=7bed32bdbfbd7579c7bbdbcd4bbc8b02-1272605389.226561-886088294</value>
+   </valuelist>
+   <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
+   <valuelist key="abstractProcess.arguments" type="QVariantList">
+    <value type="QString">-w</value>
+   </valuelist>
+   <value key="abstractProcess.command" type="QString">/usr/bin/make</value>
+   <value key="abstractProcess.enabled" type="bool">true</value>
+   <value key="abstractProcess.workingDirectory" type="QString">/scratchbox/users/oppilas/home/oppilas/qt_codes/garage.git/speedfreak/Client</value>
   </valuemap>
  </data>
  <data>
index 3eeb3b4..0c81ced 100644 (file)
@@ -36,6 +36,7 @@ TopResultDialog::TopResultDialog(QWidget *parent) :
 
 TopResultDialog::~TopResultDialog()
 {
+    qDebug() << "__~TopResultDialog";
     delete ui;
 }
 
@@ -66,6 +67,7 @@ void TopResultDialog::setCompoBoxCategories(QStringList list)
 
 void TopResultDialog::showTopList(QString str)
 {
+    qDebug() << "__showTopList";
     ui->labelTopList->setText(str);
 }
 
index b79ce0d..68a25d7 100644 (file)
@@ -61,6 +61,9 @@
    <property name="text">
     <string>Top list label</string>
    </property>
+   <property name="textFormat">
+    <enum>Qt::RichText</enum>
+   </property>
    <property name="alignment">
     <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
    </property>
index b6c1653..9c7766b 100644 (file)
@@ -10,6 +10,7 @@
 #include <QFile>
 #include <QDebug>
 #include "xmlreader.h"
+#include "profiledialog.h"
 
 /**
   *Constructor of this class.
@@ -39,7 +40,7 @@ XmlReader::~XmlReader()
 /**
   *This function is used to parse top 10 results of a certain category.
   */
-void XmlReader::xmlReadTop10Results(QNetworkReply *device)
+void XmlReader::xmlReadTop10Results(QNetworkReply *device,  QString userName)
 {
     qDebug() << "_xmlReadTop10Results";
 
@@ -48,7 +49,7 @@ void XmlReader::xmlReadTop10Results(QNetworkReply *device)
 
     xmlreader.clear();
     QByteArray array = device->readAll();
-    //qDebug() << "array: " << array;
+    qDebug() << "array: " << array;
     xmlreader.addData(array);
     //xmlreader.addData(device->readAll());
 
@@ -66,11 +67,12 @@ void XmlReader::xmlReadTop10Results(QNetworkReply *device)
         {
             if(xmlreader.name() == "results")
             {
-                //qDebug() << xmlreader.name();
+                qDebug() << xmlreader.name();
             }
+
             if(xmlreader.name() == "result")
             {
-                //qDebug() << xmlreader.name();
+                qDebug() << xmlreader.name();
                 attr = xmlreader.attributes();
 
                 user = attr.value("username").toString();
@@ -80,13 +82,30 @@ void XmlReader::xmlReadTop10Results(QNetworkReply *device)
                 unit = "s";
                 value = attr.value("value").toString();
 
+                if (userName.toUpper() == user.toUpper())//If user name match highlight result
+                {
+                    myCategoryList->top10List.append("<tr><td><b>" + position + "</b></td><td><b>" +
+                                                    user + "</b></td><td><b>" +
+                                                    value + " " +
+                                                    unit + "</b></td><td><b>" +
+                                                    date + "</b></td></tr>");
+                }
+                else//If user name not match
+                {
+                    myCategoryList->top10List.append("<tr><td>" + position + "</td><td>" +
+                                                    user + "</td><td>" +
+                                                    value + "&nbsp;" +
+                                                    unit + "</td><td>" +
+                                                    date + "</td></tr>");
+                }
+                /* Old way, no highlight
                 myCategoryList->top10List.append(position + "\t" +
                                                 user + "\t" +
                                                 value + " " +
                                                 unit + "\t" +
-                                                date + "\n");
+                                                date + "\n");*/
 
-                //qDebug() << position << user << value << unit << date;
+                qDebug() << position << user << value << unit << date;
                 i++;
                 receivedFlag = 1;
             }
@@ -100,6 +119,10 @@ void XmlReader::xmlReadTop10Results(QNetworkReply *device)
     }
 }
 
+/**
+  *
+  *
+  */
 void XmlReader::xmlReadCategories(QNetworkReply *device)
 //void XmlReader::xmlReadCategories(QIODevice *device)
 {
@@ -110,7 +133,7 @@ void XmlReader::xmlReadCategories(QNetworkReply *device)
 
     xmlreader.clear();
     QByteArray array = device->readAll();
-    //qDebug() << "array: " << array;
+    qDebug() << "array: " << array;
     xmlreader.addData(array);
     //xmlreader.addData(device->readAll());
 
@@ -127,17 +150,17 @@ void XmlReader::xmlReadCategories(QNetworkReply *device)
         {
             if(xmlreader.name() == "categories")
             {
-                //qDebug() << xmlreader.name();
+                qDebug() << xmlreader.name();
             }
             if(xmlreader.name() == "category")
             {
-                //qDebug() << xmlreader.name();
+                qDebug() << xmlreader.name();
                 attr = xmlreader.attributes();
                 description = attr.value("description").toString();
                 unit = attr.value("unit").toString();
                 category = xmlreader.readElementText();
                 myCategoryList->appendCats(i, description, unit, category);
-                //qDebug() << "description: " << description << "unit: " << unit << "category: " << category;
+                qDebug() << "description: " << description << "unit: " << unit << "category: " << category;
                 i++;
                 receivedFlag = 1;
             }
@@ -170,5 +193,73 @@ void XmlReader::xmlShow()
 
     //xmlReadTop10Results(&file);
     //xmlReadCategories(&file);
+    //xmlReadProfile(&file);
     file.close();
 }
+
+/**
+  * This function is used to read profile xml.
+  * @param QIODevice device: target of reading, here filename.
+  * @param ProfileDialog *profileDialog
+  */
+void XmlReader::xmlReadProfile(QIODevice *device, ProfileDialog *profileDialog)
+{
+    qDebug() << "_xmlReadProfile";
+
+    profile = profileDialog;
+
+    xmlreader.clear();
+    QByteArray array = device->readAll();
+
+    xmlreader.addData(array);
+
+    QString login;
+    QString picture;
+
+    // Go trough the xml document
+    while(!xmlreader.atEnd())
+    {
+        // Read next node
+        xmlreader.readNext();
+
+        // Check if this element is starting element
+        if(xmlreader.isStartElement())
+        {
+            if(xmlreader.name() == "profile")
+            {
+                qDebug() << xmlreader.name();
+                attr = xmlreader.attributes();
+                login = attr.value("login").toString();
+                picture = attr.value("picture").toString();
+            }
+            if(xmlreader.name() == "manufacturer")
+            {
+                qDebug() << xmlreader.name();
+                profile->setManufacturer(xmlreader.readElementText());
+            }
+            if(xmlreader.name() == "type")
+            {
+                qDebug() << xmlreader.name();
+                profile->setType(xmlreader.readElementText());
+
+            }
+            if(xmlreader.name() == "model")
+            {
+                qDebug() << xmlreader.name();
+                profile->setModel(xmlreader.readElementText());
+
+            }
+            if(xmlreader.name() == "description")
+            {
+                qDebug() << xmlreader.name();
+                profile->setDescription(xmlreader.readElementText());
+            }
+            if(xmlreader.name() == "picture" && picture == "yes")
+            {
+                qDebug() << xmlreader.name();
+                profile->setPicture(xmlreader.readElementText());
+            }
+        }
+    }
+    profile = NULL;
+}
index 4a751a3..6ba8f66 100644 (file)
 #include <QNetworkReply>
 #include "categorylist.h"
 
+class ProfileDialog;
+
 class XmlReader : public QObject {
     Q_OBJECT
 public:
     XmlReader();
     ~XmlReader();
     CategoryList *myCategoryList;
+    void xmlReadProfile(QIODevice *device, ProfileDialog *profileDialog);
 
 private:
     QXmlStreamReader xmlreader;
-
     QXmlStreamAttributes attr;
+    ProfileDialog *profile;
     QString category;
     QString unit;
     QString date;
@@ -39,7 +42,7 @@ signals:
     void receivedTop10List();
 
 public slots:
-    void xmlReadTop10Results(QNetworkReply *device);
+    void xmlReadTop10Results(QNetworkReply *device, QString userName);
     void xmlReadCategories(QNetworkReply *device);
     //void xmlReadCategories(QIODevice *device);
     void xmlShow();
index 3abe02a..49e9c66 100644 (file)
@@ -167,3 +167,107 @@ void XmlWriter::writeItems()
     xmlwriter.writeAttribute("date", QDateTime::currentDateTime().toString());
     xmlwriter.writeEndElement();
 }
+
+/**
+  * Write profile xml
+  * @param QIODevice device: target of writing, here filename.
+  * @param QString user name
+  * @param QString manufacturer
+  * @param QString type
+  * @param QString model
+  * @param QString description
+  * @param QString picture: filename.
+  */
+void XmlWriter::writeProfileXmlFile(QIODevice *device, QString userName, QString manufacturer,
+                                    QString type, QString model, QString description, QString picture)
+{
+    QString pictureStatus;
+    if(picture != "")
+        pictureStatus = "yes";
+    else
+        pictureStatus = "no";
+
+    /*example of XML:
+    <?xml version="1.0" encoding="UTF-8"?>
+    <profile login="test827" picture="yes">
+            <manufacturer>toyota</manufacturer>
+            <type>corolla</type>
+            <model>1983</model>
+            <description>Fuel efficient, GPS system, only one owner</description>
+    </profile>*/
+
+    xmlwriter.setDevice(device);
+    xmlwriter.writeStartDocument();
+        xmlwriter.writeStartElement("profile");
+        xmlwriter.writeAttribute("login", userName);
+        xmlwriter.writeAttribute("picture", pictureStatus);
+            xmlwriter.writeStartElement("manufacturer");
+                xmlwriter.writeCharacters(manufacturer);
+            xmlwriter.writeEndElement();
+            xmlwriter.writeStartElement("type");
+                xmlwriter.writeCharacters(type);
+            xmlwriter.writeEndElement();
+            xmlwriter.writeStartElement("model");
+                xmlwriter.writeCharacters(model);
+            xmlwriter.writeEndElement();
+            xmlwriter.writeStartElement("description");
+                xmlwriter.writeCharacters(description);
+            xmlwriter.writeEndElement();
+            xmlwriter.writeStartElement("picture");
+                xmlwriter.writeCharacters(picture);
+            xmlwriter.writeEndElement();
+        xmlwriter.writeEndElement();
+    xmlwriter.writeEndDocument();
+}
+
+/**
+  * Write profile xml
+  * @param QIODevice device: target of writing, here netbuf.
+  * @param QString user name
+  * @param QString manufacturer
+  * @param QString type
+  * @param QString model
+  * @param QString description
+  * @param QString picture: filename.
+  */
+void XmlWriter::writeProfileXmlFile(QBuffer *netbuf, QString userName, QString manufacturer,
+                                    QString type, QString model, QString description, QString picture)
+{
+    QString pictureStatus;
+    if(picture != "")
+        pictureStatus = "yes";
+    else
+        pictureStatus = "no";
+
+    /*example of XML:
+    <?xml version="1.0" encoding="UTF-8"?>
+    <profile login="test827" picture="yes">
+            <manufacturer>toyota</manufacturer>
+            <type>corolla</type>
+            <model>1983</model>
+            <description>Fuel efficient, GPS system, only one owner</description>
+    </profile>*/
+
+    xmlwriter.setDevice(netbuf);
+    xmlwriter.writeStartDocument();
+        xmlwriter.writeStartElement("profile");
+        xmlwriter.writeAttribute("login", userName);
+        xmlwriter.writeAttribute("picture", pictureStatus);
+            xmlwriter.writeStartElement("manufacturer");
+                xmlwriter.writeCharacters(manufacturer);
+            xmlwriter.writeEndElement();
+            xmlwriter.writeStartElement("type");
+                xmlwriter.writeCharacters(type);
+            xmlwriter.writeEndElement();
+            xmlwriter.writeStartElement("model");
+                xmlwriter.writeCharacters(model);
+            xmlwriter.writeEndElement();
+            xmlwriter.writeStartElement("description");
+                xmlwriter.writeCharacters(description);
+            xmlwriter.writeEndElement();
+            xmlwriter.writeStartElement("picture");
+                xmlwriter.writeCharacters(picture);
+            xmlwriter.writeEndElement();
+        xmlwriter.writeEndElement();
+    xmlwriter.writeEndDocument();
+}
index ac60175..d98eef4 100644 (file)
@@ -2,6 +2,7 @@
  * Xml writer
  *
  * @author     Tiina Kivilinna-Korhola
+ * @author     Toni Jussila <toni.jussila@fudeco.com>
  * @copyright  (c) 2010 Speed Freak team
  * license     http://opensource.org/licenses/gpl-license.php GNU Public License
  */
 #include <QByteArray>
 #include <QApplication>
 
-
 class XmlWriter : public QObject {
     Q_OBJECT
 public:
     XmlWriter();
     ~XmlWriter();
+    void writeProfileXmlFile(QIODevice *device, QString userName, QString manufacturer, QString type, QString model, QString description, QString picture);
+    void writeProfileXmlFile(QBuffer *netbuf, QString userName, QString manufacturer, QString type, QString model, QString description, QString picture);
 
 private:
     QXmlStreamWriter xmlwriter;
@@ -41,6 +43,7 @@ public slots:
     //void writeXml(QString usr, QString psswd, QString email);
     void writeXml();
     void writeItems();
+
 };
 
 #endif // XMLWRITER_H