Attica

achievement.cpp
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2011 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 "achievement.h"
10 
11 using namespace Attica;
12 
13 Achievement::Type Achievement::stringToAchievementType(const QString &achievementTypeString)
14 {
15  if (achievementTypeString == QLatin1String("flowing")) {
16  return Achievement::FlowingAchievement;
17  } else if (achievementTypeString == QLatin1String("stepped")) {
18  return Achievement::SteppedAchievement;
19  } else if (achievementTypeString == QLatin1String("namedsteps")) {
20  return Achievement::NamedstepsAchievement;
21  } else if (achievementTypeString == QLatin1String("set")) {
22  return Achievement::SetAchievement;
23  }
24 
25  Q_ASSERT(false);
26  return Achievement::FlowingAchievement;
27 }
28 
29 QString Achievement::achievementTypeToString(const Achievement::Type type)
30 {
31  switch (type) {
32  case Achievement::FlowingAchievement:
33  return QStringLiteral("flowing");
34  case Achievement::SteppedAchievement:
35  return QStringLiteral("stepped");
36  case Achievement::NamedstepsAchievement:
37  return QStringLiteral("namedsteps");
38  case Achievement::SetAchievement:
39  return QStringLiteral("set");
40  }
41 
42  Q_ASSERT(false);
43  return QString();
44 }
45 
46 Achievement::Visibility Achievement::stringToAchievementVisibility(const QString &achievementVisibilityString)
47 {
48  if (achievementVisibilityString == QLatin1String("visible")) {
49  return Achievement::VisibleAchievement;
50  } else if (achievementVisibilityString == QLatin1String("dependents")) {
51  return Achievement::DependentsAchievement;
52  } else if (achievementVisibilityString == QLatin1String("secret")) {
53  return Achievement::SecretAchievement;
54  }
55 
56  Q_ASSERT(false);
57  return Achievement::VisibleAchievement;
58 }
59 
60 QString Achievement::achievementVisibilityToString(const Achievement::Visibility visibility)
61 {
62  switch (visibility) {
63  case Achievement::VisibleAchievement:
64  return QStringLiteral("visible");
65  case Achievement::DependentsAchievement:
66  return QStringLiteral("dependents");
67  case Achievement::SecretAchievement:
68  return QStringLiteral("secret");
69  }
70 
71  Q_ASSERT(false);
72  return QString();
73 }
74 
75 class Achievement::Private : public QSharedData
76 {
77 public:
78  QString m_id;
79  QString m_contentId;
80  QString m_name;
81  QString m_description;
82  QString m_explanation;
83  int m_points;
84  QUrl m_image;
85  QStringList m_dependencies;
86  Achievement::Visibility m_visibility;
87  Achievement::Type m_type;
88  QStringList m_options;
89  int m_steps;
90  QVariant m_progress;
91 
92  Private()
93  : m_points(0),
94  m_steps(0)
95  {
96  }
97 };
98 
99 Achievement::Achievement()
100  : d(new Private)
101 {
102 }
103 
104 Achievement::Achievement(const Achievement &other)
105  : d(other.d)
106 {
107 }
108 
109 Achievement &Achievement::operator=(const Attica::Achievement &other)
110 {
111  d = other.d;
112  return *this;
113 }
114 
115 Achievement::~Achievement()
116 {
117 }
118 
119 void Achievement::setId(const QString &id)
120 {
121  d->m_id = id;
122 }
123 
124 QString Achievement::id() const
125 {
126  return d->m_id;
127 }
128 
129 void Achievement::setContentId(const QString &contentId)
130 {
131  d->m_contentId = contentId;
132 }
133 
134 QString Achievement::contentId() const
135 {
136  return d->m_contentId;
137 }
138 
139 void Achievement::setName(const QString &name)
140 {
141  d->m_name = name;
142 }
143 
144 QString Achievement::name() const
145 {
146  return d->m_name;
147 }
148 
149 void Achievement::setDescription(const QString &description)
150 {
151  d->m_description = description;
152 }
153 
154 QString Achievement::description() const
155 {
156  return d->m_description;
157 }
158 
159 void Achievement::setExplanation(const QString &explanation)
160 {
161  d->m_explanation = explanation;
162 }
163 
164 QString Achievement::explanation() const
165 {
166  return d->m_explanation;
167 }
168 
169 void Achievement::setPoints(const int points)
170 {
171  d->m_points = points;
172 }
173 
174 int Achievement::points() const
175 {
176  return d->m_points;
177 }
178 
179 void Achievement::setImage(const QUrl &image)
180 {
181  d->m_image = image;
182 }
183 
184 QUrl Achievement::image() const
185 {
186  return d->m_image;
187 }
188 
189 void Achievement::setDependencies(const QStringList &dependencies)
190 {
191  d->m_dependencies = dependencies;
192 }
193 
194 void Achievement::addDependency(const QString &dependency)
195 {
196  d->m_dependencies.append(dependency);
197 }
198 
199 void Achievement::removeDependency(const QString &dependency)
200 {
201  d->m_dependencies.removeOne(dependency);
202 }
203 
204 QStringList Achievement::dependencies() const
205 {
206  return d->m_dependencies;
207 }
208 
209 void Achievement::setVisibility(Achievement::Visibility visibility)
210 {
211  d->m_visibility = visibility;
212 }
213 
214 Achievement::Visibility Achievement::visibility() const
215 {
216  return d->m_visibility;
217 }
218 
219 void Achievement::setType(Achievement::Type type)
220 {
221  d->m_type = type;
222 }
223 
224 Achievement::Type Achievement::type() const
225 {
226  return d->m_type;
227 }
228 
229 void Achievement::setOptions(const QStringList &options)
230 {
231  d->m_options = options;
232 }
233 
234 void Achievement::addOption(const QString &option)
235 {
236  d->m_options.append(option);
237 }
238 
239 void Achievement::removeOption(const QString &option)
240 {
241  d->m_options.removeOne(option);
242 }
243 
244 QStringList Achievement::options() const
245 {
246  return d->m_options;
247 }
248 
249 void Achievement::setSteps(const int steps)
250 {
251  d->m_steps = steps;
252 }
253 
254 int Achievement::steps() const
255 {
256  return d->m_steps;
257 }
258 
259 void Achievement::setProgress(const QVariant &progress)
260 {
261  d->m_progress = progress;
262 }
263 
264 QVariant Achievement::progress() const
265 {
266  return d->m_progress;
267 }
268 
269 bool Achievement::isValid() const
270 {
271  return !(d->m_id.isEmpty());
272 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 25 2021 23:06:24 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.