1 /* 2 This file is part of KDE. 3 4 SPDX-FileCopyrightText: 2012 Laszlo Papp <lpapp@kde.org> 5 6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 7 */ 8 9 #include "cloudparser.h" 10 #include "atticautils.h" 11 12 using namespace Attica; 13 parseXml(QXmlStreamReader & xml)14Cloud Cloud::Parser::parseXml(QXmlStreamReader &xml) 15 { 16 Cloud cloud; 17 18 while (!xml.atEnd()) { 19 xml.readNext(); 20 21 if (xml.isStartElement()) { 22 if (xml.name() == QLatin1String("name")) { 23 cloud.setName(xml.readElementText()); 24 } else if (xml.name() == QLatin1String("url")) { 25 cloud.setUrl(xml.readElementText()); 26 // TODO: there should be usage for the attica icon class 27 } else if (xml.name() == QLatin1String("icon")) { 28 cloud.setIcon(QUrl(xml.readElementText())); 29 } else if (xml.name() == QLatin1String("quota")) { 30 cloud.setQuota(xml.readElementText().toULongLong()); 31 } else if (xml.name() == QLatin1String("free")) { 32 cloud.setFree(xml.readElementText().toULongLong()); 33 } else if (xml.name() == QLatin1String("used")) { 34 cloud.setUsed(xml.readElementText().toULongLong()); 35 } else if (xml.name() == QLatin1String("relative")) { 36 cloud.setRelative(xml.readElementText().toFloat()); 37 } else if (xml.name() == QLatin1String("key")) { 38 cloud.setKey(xml.readElementText()); 39 } 40 } else if (xml.isEndElement() && xml.name() == QLatin1String("cloud")) { 41 break; 42 } 43 } 44 45 return cloud; 46 } 47 xmlElement() const48QStringList Cloud::Parser::xmlElement() const 49 { 50 return QStringList(QLatin1String("cloud")); 51 } 52