4 * @author Toni Jussila <toni.jussila@fudeco.com>
5 * @author Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
6 * @copyright (c) 2010 Speed Freak team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 #include "xmlreader.h"
15 *Constructor of this class.
17 XmlReader::XmlReader()
23 *Destructor of this class. Should be used to release all allocated resources.
25 XmlReader::~XmlReader()
36 *This function is used to parsing xml file.
38 void XmlReader::xmlRead(QIODevice *device)
40 qDebug() << "_xmlRead";
42 xmlreader.addData(device->readAll());
44 //Go trough the xml document
45 while(!xmlreader.atEnd())
49 //Check if this element is starting element
50 if(xmlreader.isStartElement())
52 if(xmlreader.name() == "results")
54 qDebug() << xmlreader.name();
55 attr = xmlreader.attributes();
57 category = attr.value("category").toString();
58 unit = attr.value("unit").toString();
59 description = attr.value("description").toString();
61 top10List << category;
62 qDebug() << top10List << unit << description;
65 if(xmlreader.name() == "result")
68 attr = xmlreader.attributes();
70 position = attr.value("position").toString();
71 user = attr.value("user").toString();
72 value = attr.value("value").toString();
74 if (category == "acceleration-0-100")
76 top10AccelerationList.append(position + "\t" +
83 if(category == "top10speed")
85 top10SpeedList.append(position + "\t" +
92 if(category == "top10gforce")
94 top10GforceList.append(position + "\t" +
100 qDebug() << position << user << value << unit;
107 *This function is used to read example xml file (results.xml).
108 *@todo Read real xml.
110 void XmlReader::xmlShow()
112 QString filename = "results.xml";
113 QFile file(filename);
115 if (!file.open(QFile::ReadOnly))
117 qDebug() << "_xmlShow fail";
126 *This is return function.
127 *@todo Read real top 10 category list
128 *@return QStringList top10List
130 QStringList XmlReader::getTop10List()
136 *This is return function.
137 *@return QString top10AccelerationList
139 QString XmlReader::getTop10AccelerationList()
141 return top10AccelerationList;
145 *This is return function.
146 *@return QString top10SpeedList
148 QString XmlReader::getTop10SpeedList()
150 return top10SpeedList;
154 *This is return function.
155 *@return QString top10GforceList
157 QString XmlReader::getTop10GforceList()
159 return top10GforceList;