/*
* 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
*/
*/
void CategoryList::appendCategoryList(QString item)
{
+ qDebug() << "__appendCategoryList";
categoryList.append(item);
}
*/
void CategoryList::fillCategoryList(int index, QString item)
{
+ qDebug() << "__fillCategoryList";
categoryList.insert(index, item);
}
*/
QString CategoryList::itemOfCategoryList(int index)
{
+ qDebug() << "__itemOfCategoryList";
return categoryList.at(index);
}
*/
void CategoryList::clearCategoryList()
{
+ qDebug() << "__clearCategoryList";
categoryList.clear();
}
*/
int CategoryList::sizeOfCategoryList()
{
+ qDebug() << "__sizeOfCategoryList";
return categoryList.size();
}
*/
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;
*/
QString CategoryList::getRecentDescription(int ind)
{
+ qDebug() << "__getRecentDescription";
return cats[ind].description;
}
*/
QString CategoryList::getRecentCategory(int ind)
{
+ qDebug() << "__getRecentCategory";
return cats[ind].category;
}
*/
void CategoryList::clearCats()
{
+ qDebug() << "__clearCats";
for(int i = 0; i < 20; i++)
{
cats[i].description.clear();
<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>
<set>Qt::AlignCenter</set>
</property>
</widget>
- <widget class="QLabel" name="label_11">
+ <widget class="QLabel" name="labelGraphicAndIconsBy">
<property name="geometry">
<rect>
<x>70</x>
</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>
</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>
</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>
HttpClient::~HttpClient()
{
qDebug() << "__~HttpClient" ;
+
+ if(myXmlwriter)
+ delete myXmlwriter;
+ if(myXmlreader)
+ delete myXmlreader;
}
/**
*/
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);
myMainw->settingsDialog->usernameOk(true);
myMainw->settingsDialog->close();
}
-
}
}
{
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");
+ }
}
}
void ackOfCategories();
void ackOfToplist();
void ackOfLogin();
+ bool ackOfProfile();
+ void ackOfSendingPicture();
void errorFromServer(QNetworkReply::NetworkError);
+ void sendProfileXml();
};
#include <QDebug>
#include "usersettings.h"
+/**
+ *
+ */
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
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()));
customButtonResults->show();
}
+/**
+ *
+ */
MainWindow::~MainWindow()
{
delete ui;
}
+/**
+ *
+ */
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
httpClient->sendResultXml(category, result);
}
}
+
/**
* This slot function called when ever dialog rejected.
*/
helpDialog = NULL;
}
}
+
/**
*
*/
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();
+}
void OpenAccStartDialog();
void OpenRouteDialog();
void OpenResultDialog();
+ void saveProfile();
};
+/*
+ * 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);
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);
+}
+/*
+ * 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
<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/>
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)");
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");
}
qDebug() << "__~RouteDialog";
if(ui)
delete ui;
+ if(calibrateDialog)
+ delete calibrateDialog;
}
/**
/**
*
*/
-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)"));
if (!file.open(QIODevice::ReadOnly))
{
QMessageBox::about(0, "Error", "File not found");
+ progresbar->setProgressValue(100);
return false;
}
*/
return true;
- }
+}
/**
* Find out data range for x-, y- and z-coordinates
#include <QDialog>
#include <helproutingdialog.h>
class RouteSaveDialog;
+class CalibrateDialog;
namespace Ui {
class RouteDialog;
public:
RouteDialog(RouteSaveDialog *parent = 0);
~RouteDialog();
- bool readRouteFromFile( QString &routeFile);
+ bool readRouteFromFile( QString &routeFile, CalibrateDialog *calibrateDialog);
int getLeft();
int getTop();
int getRight();
private:
Ui::RouteDialog *ui;
+ CalibrateDialog *progresbar;
int left, top, right, bottom; // Limits in screen coordinates in route dialog
void checkLogin();
#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){
location = NULL;
gpsData = NULL;
helpRoutingDialog = NULL;
+ calibrateDialog = NULL;
//Clear variables
averageSpeed = 0.0;
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()));
}
/**
- *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()
{
}
/**
- *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()
{
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);
}
/**
- *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()
{
}
/**
- *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()
{
#include "gpsdata.h"
#include "routedialog.h"
#include <helproutingdialog.h>
+#include "calibratedialog.h"
namespace Ui {
class RouteSaveDialog;
QTimer *timerRoutePicture;
GPSData *gpsData;
Maemo5Location *location;
+ CalibrateDialog *calibrateDialog;
QString gpsSpeed;
QString distanceString;
QPixmap *pixmapRouteStop;
ui->setupUi(this);
helpSettingsDialog = NULL;
+ profileDialog = NULL;
this->setWindowTitle("Settings");
this->ui->regEMailLineEdit->setText("@");
+ ui->pushButtonProfile->setDisabled(true);
+
if (loginSaved())
{
QString uName, pWord;
// 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()
this->password = ui->setUserPasswordLineEdit->text();
ui->setUserPushButton->setText("Log in");
saveLogin( this->username, this->password);
+ ui->pushButtonProfile->setDisabled(true);
emit logout();
}
else
ui->setUserPushButton->setText("Log out");
ui->setUserUsernameLineEdit->setDisabled(true);
ui->setUserPasswordLineEdit->setDisabled(true);
+ ui->pushButtonProfile->setDisabled(false);
}
else
this->username = ui->setUserUsernameLineEdit->text();
this->password = ui->setUserPasswordLineEdit->text();
saveLogin( this->username, this->password);
+ ui->pushButtonProfile->setDisabled(true);
}
}
{
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)
{
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();
}
#include <QDialog>
#include "instructionsdialog.h"
#include <helpsettingsdialog.h>
+#include <profiledialog.h>
namespace Ui {
class SettingsDialog;
SettingsDialog(QWidget *parent = 0);
~SettingsDialog();
HelpSettingsDialog *helpSettingsDialog;
+ ProfileDialog *profileDialog;
void setRegUserName(QString username);
void setRegPassword(QString password);
void setRegEmail(QString email);
void sendregistration();
void userNameChanged();
void logout();
+ void saveprofile();
protected:
void changeEvent(QEvent *e);
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
</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>
helpaccelerationdialog.cpp \
helproutingdialog.cpp \
helpsettingsdialog.cpp \
- custombutton.cpp
+ custombutton.cpp \
+ profiledialog.cpp
HEADERS += mainwindow.h \
creditsdialog.h \
routedialog.h \
helpaccelerationdialog.h \
helproutingdialog.h \
helpsettingsdialog.h \
- custombutton.h
+ custombutton.h \
+ profiledialog.h
FORMS += mainwindow.ui \
creditsdialog.ui \
routedialog.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
<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>
TopResultDialog::~TopResultDialog()
{
+ qDebug() << "__~TopResultDialog";
delete ui;
}
void TopResultDialog::showTopList(QString str)
{
+ qDebug() << "__showTopList";
ui->labelTopList->setText(str);
}
<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>
#include <QFile>
#include <QDebug>
#include "xmlreader.h"
+#include "profiledialog.h"
/**
*Constructor of this class.
/**
*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";
xmlreader.clear();
QByteArray array = device->readAll();
- //qDebug() << "array: " << array;
+ qDebug() << "array: " << array;
xmlreader.addData(array);
//xmlreader.addData(device->readAll());
{
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();
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 + " " +
+ 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;
}
}
}
+/**
+ *
+ *
+ */
void XmlReader::xmlReadCategories(QNetworkReply *device)
//void XmlReader::xmlReadCategories(QIODevice *device)
{
xmlreader.clear();
QByteArray array = device->readAll();
- //qDebug() << "array: " << array;
+ qDebug() << "array: " << array;
xmlreader.addData(array);
//xmlreader.addData(device->readAll());
{
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;
}
//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;
+}
#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;
void receivedTop10List();
public slots:
- void xmlReadTop10Results(QNetworkReply *device);
+ void xmlReadTop10Results(QNetworkReply *device, QString userName);
void xmlReadCategories(QNetworkReply *device);
//void xmlReadCategories(QIODevice *device);
void xmlShow();
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();
+}
* 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;
//void writeXml(QString usr, QString psswd, QString email);
void writeXml();
void writeItems();
+
};
#endif // XMLWRITER_H