Attica

cloudparser.cpp
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2012 Laszlo Papp <[email protected]>
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 
14 Cloud 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 
48 QStringList Cloud::Parser::xmlElement() const
49 {
50  return QStringList(QLatin1String("cloud"));
51 }
bool atEnd() const const
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
qulonglong toULongLong(bool *ok, int base) const const
QXmlStreamReader::TokenType readNext()
bool isStartElement() const const
float toFloat(bool *ok) const const
QStringRef name() const const
bool isEndElement() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 03:59:44 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.