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)
39 void XmlReader::xmlRead(QNetworkReply* device)
41 qDebug() << "_xmlRead";
43 xmlreader.addData(device->readAll());
45 //Go trough the xml document
46 while(!xmlreader.atEnd())
50 //Check if this element is starting element
51 if(xmlreader.isStartElement())
53 if(xmlreader.name() == "results")
55 qDebug() << xmlreader.name();
56 attr = xmlreader.attributes();
58 category = attr.value("category").toString();
59 unit = attr.value("unit").toString();
60 description = attr.value("description").toString();
62 top10List << category;
63 qDebug() << top10List << unit << description;
66 if(xmlreader.name() == "result")
69 attr = xmlreader.attributes();
71 position = attr.value("position").toString();
72 user = attr.value("user").toString();
73 value = attr.value("value").toString();
75 if (category == "acceleration-0-100")
77 top10AccelerationList.append(position + "\t" +
84 if(category == "top10speed")
86 top10SpeedList.append(position + "\t" +
93 if(category == "top10gforce")
95 top10GforceList.append(position + "\t" +
101 qDebug() << position << user << value << unit;
108 *This function is used to read example xml file (results.xml).
109 *@todo Read real xml.
111 void XmlReader::xmlShow()
113 QString filename = "results.xml";
114 QFile file(filename);
116 if (!file.open(QFile::ReadOnly))
118 qDebug() << "_xmlShow fail";
127 *This is return function.
128 *@todo Read real top 10 category list
129 *@return QStringList top10List
131 QStringList XmlReader::getTop10List()
137 *This is return function.
138 *@return QString top10AccelerationList
140 QString XmlReader::getTop10AccelerationList()
142 return top10AccelerationList;
146 *This is return function.
147 *@return QString top10SpeedList
149 QString XmlReader::getTop10SpeedList()
151 return top10SpeedList;
155 *This is return function.
156 *@return QString top10GforceList
158 QString XmlReader::getTop10GforceList()
160 return top10GforceList;