Measurement resetting added in carmainwindow.cpp.
[speedfreak] / Client / xmlwriter.cpp
index 4d4c112..dac4d62 100644 (file)
@@ -6,16 +6,6 @@
  * license     http://opensource.org/licenses/gpl-license.php GNU Public License
  */
 
-#include <QtGui>
-#include <QNetworkRequest>
-#include <QIODevice>
-#include <QFile>
-#include <QMessageBox>
-#include <QDebug>
-#include <QDateTime>
-#include <QDate>
-#include <QTime>
-#include <QApplication>
 #include "xmlwriter.h"
 
 
@@ -26,7 +16,7 @@
   */
 XmlWriter::XmlWriter()
 {
-
+    tmpvalue = 10;
 }
 
 /**
@@ -36,6 +26,7 @@ XmlWriter::~XmlWriter()
 {
 
 }
+
 /**
   *@brief Writes registration items into tags.
   *@param netbuf a buffer where xmlstreamwriter writes to.
@@ -44,8 +35,9 @@ XmlWriter::~XmlWriter()
   *@param email.
   */
 void XmlWriter::writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QString email)
-//void XmlWriter::writeRegistering(QIODevice *netbuf, QString usr, QString psswd, QString email)
 {
+    qDebug() << "_writeRegistering";
+
     xmlwriter.setDevice(netbuf);
 
     xmlwriter.writeStartDocument();
@@ -74,13 +66,16 @@ void XmlWriter::writeRegistering(QBuffer *netbuf, QString usr, QString psswd, QS
   *@todo Replace test value to finally used variables.
   */
 void XmlWriter::writeResult(QBuffer *netbuf)
-//void XmlWriter::writeResult(QIODevice *netbuf)
 {
+    qDebug() << "_writeResult";
+
     xmlwriter.setDevice(netbuf);
 
     xmlwriter.writeStartDocument();
     xmlwriter.writeStartElement("result");
-    xmlwriter.writeAttribute("value", QString::number(14));
+    tmpvalue++;
+    qDebug() << tmpvalue;
+    xmlwriter.writeAttribute("value", QString::number(tmpvalue));
     xmlwriter.writeAttribute("unit", "seconds");
     xmlwriter.writeAttribute("date", QDateTime::currentDateTime().toString());
     xmlwriter.writeEndElement();
@@ -96,9 +91,10 @@ void XmlWriter::writeResult(QBuffer *netbuf)
   *@param email.
   *@todo Replace hardcoced filename to finally GUI entry widget.
   */
-void XmlWriter::writeXml(QString usr, QString psswd, QString email)
+//void XmlWriter::writeXml(QString usr, QString psswd, QString email)
+void XmlWriter::writeXml()
 {
-    QString filename = "xmlfile.xml";
+    QString filename = "xmlcategoryfile.xml";
     QFile file(filename);
     if (!file.open(QFile::WriteOnly | QFile::Text)) {
         qDebug() << "_xmlWrite fail";
@@ -124,6 +120,7 @@ bool XmlWriter::writeXmlFile(QIODevice *device)
     xmlwriter.setDevice(device);
     xmlwriter.writeStartDocument();
     writeItems();
+    //serverWritesXml();
     xmlwriter.writeEndDocument();
 
     return true;
@@ -148,12 +145,14 @@ void XmlWriter::writeItems()
 /**
   *@brief A temp function during development, used to create a "serverfile".
   */
-void XmlWriter::serverWritesTop()
+void XmlWriter::serverWritesXml()
 {
+    /* Server sends to client */
+    /*
     int i = 0;
     int n = 5;
 
-    /* Server sends to client */
+    //Write top 10 Results
     xmlwriter.writeStartElement("results");
     xmlwriter.writeAttribute("category", "acceleration-0-40");
     xmlwriter.writeAttribute("unit", "seconds");
@@ -167,4 +166,21 @@ void XmlWriter::serverWritesTop()
         xmlwriter.writeAttribute("value", QString::number(i+i+1));
         xmlwriter.writeEndElement();
     }
+    */
+    //Write categories
+    xmlwriter.writeStartElement("categories");
+
+    xmlwriter.writeStartElement("category");
+    xmlwriter.writeCharacters("acceleration-0-10");
+    xmlwriter.writeEndElement();
+
+    xmlwriter.writeStartElement("category");
+    xmlwriter.writeCharacters("acceleration-0-60");
+    xmlwriter.writeEndElement();
+
+    xmlwriter.writeStartElement("category");
+    xmlwriter.writeCharacters("acceleration-0-100");
+    xmlwriter.writeEndElement();
+
+    xmlwriter.writeEndElement();
 }