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