1 | /* |
2 | This file is part of KDE. |
3 | |
4 | SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
7 | */ |
8 | |
9 | #ifndef ATTICA_CONTENT_H |
10 | #define ATTICA_CONTENT_H |
11 | |
12 | #include <QList> |
13 | #include <QMap> |
14 | #include <QSharedDataPointer> |
15 | #include <QString> |
16 | #include <QUrl> |
17 | |
18 | #include "attica_export.h" |
19 | #include "downloaddescription.h" |
20 | #include "homepageentry.h" |
21 | #include "icon.h" |
22 | |
23 | class QDateTime; |
24 | |
25 | namespace Attica |
26 | { |
27 | /*! |
28 | * \class Attica::Content |
29 | * \inheaderfile Attica/Content |
30 | * \inmodule Attica |
31 | * |
32 | * \brief Represents a single content. |
33 | */ |
34 | class ATTICA_EXPORT Content |
35 | { |
36 | public: |
37 | /*! |
38 | * |
39 | */ |
40 | typedef QList<Content> List; |
41 | class Parser; |
42 | |
43 | /*! |
44 | * Creates an empty Content |
45 | */ |
46 | Content(); |
47 | |
48 | Content(const Content &other); |
49 | |
50 | Content &operator=(const Content &other); |
51 | |
52 | ~Content(); |
53 | |
54 | /*! |
55 | * Sets the id of the Content. |
56 | * |
57 | * The id uniquely identifies a Content with the OCS API. |
58 | * |
59 | * \a id the new id |
60 | */ |
61 | void setId(const QString &id); |
62 | |
63 | /*! |
64 | * Returns the id of the Content. |
65 | * |
66 | * The id uniquely identifies a Content with the OCS API. |
67 | */ |
68 | QString id() const; |
69 | |
70 | /*! |
71 | * Sets the name of the Content. |
72 | * |
73 | * \a name the new name |
74 | */ |
75 | void setName(const QString &name); |
76 | |
77 | /*! |
78 | * Returns the name of the Content. |
79 | */ |
80 | QString name() const; |
81 | |
82 | /*! |
83 | * Sets the rating of the Content. |
84 | * |
85 | * \a rating the new rating, has to be in the range 0-100 |
86 | */ |
87 | void setRating(int rating); |
88 | |
89 | /*! |
90 | * Returns the rating of the Content, in the range 0-100 |
91 | */ |
92 | int rating() const; |
93 | |
94 | /*! |
95 | * Sets the number of downloads for the Content. |
96 | * |
97 | * \a downloads the new number of downloads |
98 | */ |
99 | void setDownloads(int downloads); |
100 | |
101 | /*! |
102 | * Returns the number of downloads for the Content (how often this has been downloaded from the server). |
103 | */ |
104 | int downloads() const; |
105 | |
106 | /*! |
107 | * Sets the number of comments for the Content. |
108 | * |
109 | * \a numComments the new number of downloads |
110 | */ |
111 | void (int ); |
112 | |
113 | /*! |
114 | * Returns the number of comments for the Content. |
115 | */ |
116 | int () const; |
117 | |
118 | /*! |
119 | * Sets the date and time the Content has been created. |
120 | * |
121 | * \a created the new creation date and time |
122 | */ |
123 | void setCreated(const QDateTime &created); |
124 | |
125 | /*! |
126 | * Returns the date and time the Content has been created. |
127 | */ |
128 | QDateTime created() const; |
129 | |
130 | /*! |
131 | * Sets the time the Content has been last updated. |
132 | * |
133 | * \a updated the new date and time of the last update |
134 | */ |
135 | void setUpdated(const QDateTime &updated); |
136 | |
137 | /*! |
138 | * Returns the date and time the Content has been last updated. |
139 | */ |
140 | QDateTime updated() const; |
141 | |
142 | /*! |
143 | * A summary description of this content. |
144 | */ |
145 | QString summary() const; |
146 | |
147 | /*! |
148 | * A description of this content. |
149 | */ |
150 | QString description() const; |
151 | |
152 | /*! |
153 | * A webpage with the detailed description of this content. |
154 | */ |
155 | QUrl detailpage() const; |
156 | |
157 | /*! |
158 | * |
159 | */ |
160 | QString changelog() const; |
161 | |
162 | /*! |
163 | * |
164 | */ |
165 | QString version() const; |
166 | |
167 | /*! |
168 | * |
169 | */ |
170 | QString depend() const; |
171 | |
172 | /*! |
173 | Get the details about a download (a content can have multiple links, eg for different distros). |
174 | This is not very helpful if we don't know the allowed numbers. |
175 | */ |
176 | DownloadDescription downloadUrlDescription(int number) const; |
177 | |
178 | /*! |
179 | Get all possible downloads. |
180 | This is slow searching through lots of strings, so beware and don't call it too often. |
181 | */ |
182 | QList<DownloadDescription> downloadUrlDescriptions() const; |
183 | |
184 | /*! |
185 | Get the details about a home page (a content can have multiple home pages, blog, bugs, ...). |
186 | This is not very helpful if we don't know the allowed numbers. |
187 | */ |
188 | HomePageEntry homePageEntry(int number) const; |
189 | |
190 | /*! |
191 | Get all home pages for this content. |
192 | This is slow searching through lots of strings, so beware and don't call it too often. |
193 | */ |
194 | QList<HomePageEntry> homePageEntries(); |
195 | |
196 | /*! |
197 | * |
198 | */ |
199 | QString previewPicture(const QString &number = QStringLiteral("1" )) const; |
200 | |
201 | /*! |
202 | * |
203 | */ |
204 | QString smallPreviewPicture(const QString &number = QStringLiteral("1" )) const; |
205 | |
206 | /*! |
207 | * |
208 | */ |
209 | QString license() const; |
210 | |
211 | /*! |
212 | * |
213 | */ |
214 | QString licenseName() const; |
215 | |
216 | /*! |
217 | * |
218 | */ |
219 | QString author() const; |
220 | |
221 | /*! |
222 | Get all icons for this content. |
223 | */ |
224 | QList<Icon> icons(); |
225 | |
226 | /*! |
227 | Get all icons for this content. |
228 | */ |
229 | QList<Icon> icons() const; |
230 | |
231 | /*! |
232 | * Set list of icons. |
233 | * |
234 | * \a icons list of icons for this content |
235 | */ |
236 | void setIcons(QList<Icon> icons); |
237 | |
238 | /*! |
239 | Get all videos for this content. |
240 | */ |
241 | QList<QUrl> videos(); |
242 | /*! |
243 | * Set list of videos. |
244 | * |
245 | * \a videos list of videos for this content |
246 | */ |
247 | void setVideos(QList<QUrl> videos); |
248 | |
249 | /*! |
250 | * Get all the tags for this content |
251 | * \since 5.50 |
252 | */ |
253 | QStringList tags() const; |
254 | /*! |
255 | * Set the list of tags |
256 | * |
257 | * \a tags list of tags for this content |
258 | * \since 5.50 |
259 | */ |
260 | void setTags(const QStringList &tags); |
261 | |
262 | /*! |
263 | * Add an attribute that is not included in the basis set of attributes exposed by the Content class. |
264 | * If the attribute already exists it gets overwritten. |
265 | * |
266 | * \a key the key of the attribute |
267 | * |
268 | * \a value the value of the attribute |
269 | */ |
270 | void addAttribute(const QString &key, const QString &value); |
271 | |
272 | /*! |
273 | * Get an attribute that is not included in the basis set of attributes exposed by the Content class. |
274 | * |
275 | * \a key the key of the attribute |
276 | * |
277 | * Returns the value of the attribute with the specified key, or an empty string, if the key has not been found |
278 | */ |
279 | QString attribute(const QString &key) const; |
280 | |
281 | /*! |
282 | * Get all attributes that are not included in the basis set of attributes exposed by the Content class. |
283 | */ |
284 | QMap<QString, QString> attributes() const; |
285 | |
286 | /*! |
287 | * Checks whether this Content has an id |
288 | * Returns \c true if an id has been set, \c false otherwise |
289 | */ |
290 | bool isValid() const; |
291 | |
292 | private: |
293 | class Private; |
294 | QSharedDataPointer<Private> d; |
295 | }; |
296 | |
297 | } |
298 | |
299 | #endif |
300 | |