Measurement resetting added in carmainwindow.cpp.
[speedfreak] / Client / xmlreader.cpp
index c3a439c..6067038 100644 (file)
@@ -1,11 +1,11 @@
-/**
-  * Parse xml file
-  *
-  * @author     Toni Jussila <toni.jussila@fudeco.com>
-  * @author     Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
-  * @copyright  (c) 2010 Speed Freak team
-  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
-  */
+/*
+ * Parse xml file
+ *
+ * @author     Toni Jussila <toni.jussila@fudeco.com>
+ * @author     Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
+ * @copyright  (c) 2010 Speed Freak team
+ * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
 
 #include <QFile>
 #include <QDebug>
@@ -35,9 +35,9 @@ XmlReader::~XmlReader()
 /**
   *This function is used to parsing xml file.
   */
-void XmlReader::xmlRead(QIODevice *device)
+void XmlReader::xmlReadTop10Results(QNetworkReply *device)
 {
-    qDebug() << "_xmlRead";
+    qDebug() << "_xmlReadTop10Results";
 
     xmlreader.addData(device->readAll());
 
@@ -103,13 +103,49 @@ void XmlReader::xmlRead(QIODevice *device)
     }
 }
 
+void XmlReader::xmlReadCategories(QNetworkReply *device)
+//void XmlReader::xmlReadCategories(QIODevice *device)
+{
+    qDebug() << "_xmlReadCategories";
+
+    int i = 0;
+
+    QByteArray array = device->readAll();
+    qDebug() << array;
+    xmlreader.addData(array);
+
+    //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() == "categories")
+            {
+                qDebug() << xmlreader.name();
+            }
+            if(xmlreader.name() == "category")
+            {
+                qDebug() << xmlreader.name();
+                categoryList.insert(i, xmlreader.readElementText());
+                qDebug() << "i=" << i << categoryList.at(i);
+                i++;
+            }
+        }
+    }
+}
+
 /**
   *This function is used to read example xml file (results.xml).
   *@todo Read real xml.
   */
 void XmlReader::xmlShow()
 {
-    QString filename = "results.xml";
+    //QString filename = "results.xml";
+    QString filename = "xmlcategoryfile.xml";
     QFile file(filename);
 
     if (!file.open(QFile::ReadOnly))
@@ -118,43 +154,8 @@ void XmlReader::xmlShow()
         return;
     }
 
-    xmlRead(&file);
+    //xmlReadTop10Results(&file);
+    //xmlReadCategories(&file);
     file.close();
 }
 
-/**
-  *This is return function.
-  *@todo Read real top 10 category list
-  *@return QStringList top10List
-  */
-QStringList XmlReader::getTop10List()
-{
-    return top10List;
-}
-
-/**
-  *This is return function.
-  *@return QString top10AccelerationList
-  */
-QString XmlReader::getTop10AccelerationList()
-{
-    return top10AccelerationList;
-}
-
-/**
-  *This is return function.
-  *@return QString top10SpeedList
-  */
-QString XmlReader::getTop10SpeedList()
-{
-    return top10SpeedList;
-}
-
-/**
-  *This is return function.
-  *@return QString top10GforceList
-  */
-QString XmlReader::getTop10GforceList()
-{
-    return top10GforceList;
-}