Attica

cloudparser.cpp
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
12using namespace Attica;
13
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")) {
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
48QStringList Cloud::Parser::xmlElement() const
49{
50 return QStringList(QLatin1String("cloud"));
51}
Represents a cloud service.
Definition cloud.h:27
void setUrl(const QString &url)
Sets the url of the Cloud service.
Definition cloud.cpp:56
void setQuota(qulonglong quota)
Sets the quota of the Cloud service.
Definition cloud.cpp:76
void setRelative(float relative)
Sets the relative of the Cloud service.
Definition cloud.cpp:106
void setUsed(qulonglong used)
Sets the used amount of the Cloud service.
Definition cloud.cpp:96
void setKey(const QString &privateKey)
Sets the private key of the Cloud service.
Definition cloud.cpp:116
void setName(const QString &name)
Sets the name of the Cloud service.
Definition cloud.cpp:46
void setFree(qulonglong free)
Sets the free amount of the Cloud service.
Definition cloud.cpp:86
void setIcon(const QUrl &icon)
Sets the icon of the Cloud service.
Definition cloud.cpp:66
The Attica namespace,.
float toFloat(bool *ok) const const
qulonglong toULongLong(bool *ok, int base) const const
bool atEnd() const const
bool isEndElement() const const
bool isStartElement() const const
QStringView name() const const
QString readElementText(ReadElementTextBehaviour behaviour)
TokenType readNext()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:04:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.