X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=blobdiff_plain;f=Client%2Fxmlreader.cpp;h=9c7766b03640d29e7f2cced3fdd6ad87a3b6e27a;hp=b6c16536e6194882879ee67e3e2ef164a7c6fab1;hb=3fa5091583bdd9421a4ecd5851d954e9bed58731;hpb=ca99897dbd880fee2f7a7d77e4db8eef1fd00fe9 diff --git a/Client/xmlreader.cpp b/Client/xmlreader.cpp index b6c1653..9c7766b 100644 --- a/Client/xmlreader.cpp +++ b/Client/xmlreader.cpp @@ -10,6 +10,7 @@ #include #include #include "xmlreader.h" +#include "profiledialog.h" /** *Constructor of this class. @@ -39,7 +40,7 @@ XmlReader::~XmlReader() /** *This function is used to parse top 10 results of a certain category. */ -void XmlReader::xmlReadTop10Results(QNetworkReply *device) +void XmlReader::xmlReadTop10Results(QNetworkReply *device, QString userName) { qDebug() << "_xmlReadTop10Results"; @@ -48,7 +49,7 @@ void XmlReader::xmlReadTop10Results(QNetworkReply *device) xmlreader.clear(); QByteArray array = device->readAll(); - //qDebug() << "array: " << array; + qDebug() << "array: " << array; xmlreader.addData(array); //xmlreader.addData(device->readAll()); @@ -66,11 +67,12 @@ void XmlReader::xmlReadTop10Results(QNetworkReply *device) { if(xmlreader.name() == "results") { - //qDebug() << xmlreader.name(); + qDebug() << xmlreader.name(); } + if(xmlreader.name() == "result") { - //qDebug() << xmlreader.name(); + qDebug() << xmlreader.name(); attr = xmlreader.attributes(); user = attr.value("username").toString(); @@ -80,13 +82,30 @@ void XmlReader::xmlReadTop10Results(QNetworkReply *device) unit = "s"; value = attr.value("value").toString(); + if (userName.toUpper() == user.toUpper())//If user name match highlight result + { + myCategoryList->top10List.append("" + position + "" + + user + "" + + value + " " + + unit + "" + + date + ""); + } + else//If user name not match + { + myCategoryList->top10List.append("" + position + "" + + user + "" + + value + " " + + unit + "" + + date + ""); + } + /* Old way, no highlight myCategoryList->top10List.append(position + "\t" + user + "\t" + value + " " + unit + "\t" + - date + "\n"); + date + "\n");*/ - //qDebug() << position << user << value << unit << date; + qDebug() << position << user << value << unit << date; i++; receivedFlag = 1; } @@ -100,6 +119,10 @@ void XmlReader::xmlReadTop10Results(QNetworkReply *device) } } +/** + * + * + */ void XmlReader::xmlReadCategories(QNetworkReply *device) //void XmlReader::xmlReadCategories(QIODevice *device) { @@ -110,7 +133,7 @@ void XmlReader::xmlReadCategories(QNetworkReply *device) xmlreader.clear(); QByteArray array = device->readAll(); - //qDebug() << "array: " << array; + qDebug() << "array: " << array; xmlreader.addData(array); //xmlreader.addData(device->readAll()); @@ -127,17 +150,17 @@ void XmlReader::xmlReadCategories(QNetworkReply *device) { if(xmlreader.name() == "categories") { - //qDebug() << xmlreader.name(); + qDebug() << xmlreader.name(); } if(xmlreader.name() == "category") { - //qDebug() << xmlreader.name(); + qDebug() << xmlreader.name(); attr = xmlreader.attributes(); description = attr.value("description").toString(); unit = attr.value("unit").toString(); category = xmlreader.readElementText(); myCategoryList->appendCats(i, description, unit, category); - //qDebug() << "description: " << description << "unit: " << unit << "category: " << category; + qDebug() << "description: " << description << "unit: " << unit << "category: " << category; i++; receivedFlag = 1; } @@ -170,5 +193,73 @@ void XmlReader::xmlShow() //xmlReadTop10Results(&file); //xmlReadCategories(&file); + //xmlReadProfile(&file); file.close(); } + +/** + * This function is used to read profile xml. + * @param QIODevice device: target of reading, here filename. + * @param ProfileDialog *profileDialog + */ +void XmlReader::xmlReadProfile(QIODevice *device, ProfileDialog *profileDialog) +{ + qDebug() << "_xmlReadProfile"; + + profile = profileDialog; + + xmlreader.clear(); + QByteArray array = device->readAll(); + + xmlreader.addData(array); + + QString login; + QString picture; + + // 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() == "profile") + { + qDebug() << xmlreader.name(); + attr = xmlreader.attributes(); + login = attr.value("login").toString(); + picture = attr.value("picture").toString(); + } + if(xmlreader.name() == "manufacturer") + { + qDebug() << xmlreader.name(); + profile->setManufacturer(xmlreader.readElementText()); + } + if(xmlreader.name() == "type") + { + qDebug() << xmlreader.name(); + profile->setType(xmlreader.readElementText()); + + } + if(xmlreader.name() == "model") + { + qDebug() << xmlreader.name(); + profile->setModel(xmlreader.readElementText()); + + } + if(xmlreader.name() == "description") + { + qDebug() << xmlreader.name(); + profile->setDescription(xmlreader.readElementText()); + } + if(xmlreader.name() == "picture" && picture == "yes") + { + qDebug() << xmlreader.name(); + profile->setPicture(xmlreader.readElementText()); + } + } + } + profile = NULL; +}