3 //#include <QApplication>
7 *Constructor of this class.
15 *Destructor of this class. Should be used to release all allocated resources.
17 XmlReader::~XmlReader()
28 *This function is used to parsing xml file.
30 void XmlReader::xmlRead(QIODevice *device)
32 qDebug() << "_xmlRead";
34 xmlreader.addData(device->readAll());
36 //Go trough the xml document
37 while(!xmlreader.atEnd())
41 //Check if this element is starting element
42 if(xmlreader.isStartElement())
44 if(xmlreader.name() == "results")
46 qDebug() << xmlreader.name();
47 attr = xmlreader.attributes();
49 category = attr.value("category").toString();
50 unit = attr.value("unit").toString();
51 description = attr.value("description").toString();
53 top10List << category;
54 qDebug() << top10List << unit << description;
57 if(xmlreader.name() == "result")
60 attr = xmlreader.attributes();
62 position = attr.value("position").toString();
63 user = attr.value("user").toString();
64 value = attr.value("value").toString();
66 if (category == "acceleration-0-100")
68 top10AccelerationList.append(position + "\t" +
75 if(category == "top10speed")
77 top10SpeedList.append(position + "\t" +
84 if(category == "top10gforce")
86 top10GforceList.append(position + "\t" +
92 qDebug() << position << user << value << unit;
99 *This function is used to read example xml file (results.xml).
100 *@todo Read real xml.
102 void XmlReader::xmlShow()
104 QString filename = "results.xml";
105 QFile file(filename);
107 if (!file.open(QFile::ReadOnly))
109 qDebug() << "_xmlShow fail";
118 *This is return function.
119 *@todo Read real top 10 category list
120 *@return QStringList top10List
122 QStringList XmlReader::getTop10List()
128 *This is return function.
129 *@return QString top10AccelerationList
131 QString XmlReader::getTop10AccelerationList()
133 return top10AccelerationList;
137 *This is return function.
138 *@return QString top10SpeedList
140 QString XmlReader::getTop10SpeedList()
142 return top10SpeedList;
146 *This is return function.
147 *@return QString top10GforceList
149 QString XmlReader::getTop10GforceList()
151 return top10GforceList;