9#include "achievementparser.h"
10#include "atticautils.h"
16 Achievement achievement;
18 while (!xml.
atEnd()) {
22 if (xml.
name() == QLatin1String(
"id")) {
24 }
else if (xml.
name() == QLatin1String(
"content_id")) {
26 }
else if (xml.
name() == QLatin1String(
"name")) {
28 }
else if (xml.
name() == QLatin1String(
"description")) {
30 }
else if (xml.
name() == QLatin1String(
"explanation")) {
32 }
else if (xml.
name() == QLatin1String(
"points")) {
34 }
else if (xml.
name() == QLatin1String(
"image")) {
36 }
else if (xml.
name() == QLatin1String(
"dependencies")) {
37 QStringList dependencies = parseXmlDependencies(xml);
38 achievement.setDependencies(dependencies);
39 }
else if (xml.
name() == QLatin1String(
"visibility")) {
40 achievement.setVisibility(Achievement::stringToAchievementVisibility(xml.
readElementText()));
41 }
else if (xml.
name() == QLatin1String(
"type")) {
42 achievement.setType(Achievement::stringToAchievementType(xml.
readElementText()));
43 }
else if (xml.
name() == QLatin1String(
"options")) {
44 QStringList options = parseXmlOptions(xml);
45 achievement.setOptions(options);
46 }
else if (xml.
name() == QLatin1String(
"steps")) {
48 }
else if (xml.
name() == QLatin1String(
"progress")) {
49 switch (achievement.type()) {
50 case Achievement::FlowingAchievement:
53 case Achievement::SteppedAchievement:
56 case Achievement::NamedstepsAchievement:
59 case Achievement::SetAchievement: {
60 QVariant progress = parseXmlProgress(xml);
61 achievement.setProgress(progress);
68 }
else if (xml.
isEndElement() && xml.
name() == QLatin1String(
"achievement")) {
76QStringList Achievement::Parser::parseXmlDependencies(QXmlStreamReader &xml)
78 QStringList dependencies;
80 while (!xml.
atEnd()) {
84 if (xml.
name() == QLatin1String(
"achievement_id")) {
87 }
else if (xml.
isEndElement() && xml.
name() == QLatin1String(
"dependencies")) {
95QStringList Achievement::Parser::parseXmlOptions(QXmlStreamReader &xml)
99 while (!xml.
atEnd()) {
103 if (xml.
name() == QLatin1String(
"option")) {
114QVariant Achievement::Parser::parseXmlProgress(QXmlStreamReader &xml)
116 QStringList progress;
118 while (!xml.
atEnd()) {
122 if (xml.
name() == QLatin1String(
"reached")) {
133QStringList Achievement::Parser::xmlElement()
const
135 return QStringList(QStringLiteral(
"achievement"));
Represents an achievement.
float toFloat(bool *ok) const const
int toInt(bool *ok, int base) const const
bool isEndElement() const const
bool isStartElement() const const
QStringView name() const const
QString readElementText(ReadElementTextBehaviour behaviour)