Attica

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

KDE's Doxygen guidelines are available online.