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 }
void setFree(qulonglong free)
Sets the free amount of the Cloud service.
Definition: cloud.cpp:86
void setQuota(qulonglong quota)
Sets the quota of the Cloud service.
Definition: cloud.cpp:76
bool isEndElement() const const
QStringRef name() const const
void setUsed(qulonglong used)
Sets the used amount of the Cloud service.
Definition: cloud.cpp:96
qulonglong toULongLong(bool *ok, int base) const const
QXmlStreamReader::TokenType readNext()
float toFloat(bool *ok) const const
void setName(const QString &name)
Sets the name of the Cloud service.
Definition: cloud.cpp:46
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
void setKey(const QString &privateKey)
Sets the private key of the Cloud service.
Definition: cloud.cpp:116
void setRelative(float relative)
Sets the relative of the Cloud service.
Definition: cloud.cpp:106
The Attica namespace,.
void setUrl(const QString &url)
Sets the url of the Cloud service.
Definition: cloud.cpp:56
void setIcon(const QUrl &icon)
Sets the icon of the Cloud service.
Definition: cloud.cpp:66
bool isStartElement() const const
bool atEnd() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 04:05:13 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.