File: content.h

package info (click to toggle)
attica 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 644 kB
  • sloc: cpp: 5,227; makefile: 3
file content (263 lines) | stat: -rw-r--r-- 7,149 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/*
    This file is part of KDE.

    Copyright (c) 2008 Cornelius Schumacher <schumacher@kde.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) version 3, or any
    later version accepted by the membership of KDE e.V. (or its
    successor approved by the membership of KDE e.V.), which shall
    act as a proxy defined in Section 6 of version 3 of the license.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library.  If not, see <http://www.gnu.org/licenses/>.

*/
#ifndef ATTICA_CONTENT_H
#define ATTICA_CONTENT_H

#include <QtCore/QList>
#include <QtCore/QString>
#include <QtCore/QMap>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QUrl>

#include "atticaclient_export.h"
#include "downloaddescription.h"
#include "homepageentry.h"
#include "icon.h"

class QDateTime;

namespace Attica {
    
/**
 * Represents a single content
 */
class ATTICA_EXPORT Content
{
  public:
    typedef QList<Content> List;
    class Parser;
  
    /**
     * Creates an empty Content
     */
    Content();

    /**
     * Copy constructor.
     * @param other the Content to copy from
     */
    Content(const Content& other);

    /**
     * Assignment operator.
     * @param other the Content to assign from
     * @return pointer to this Content
     */
    Content& operator=(const Content& other);

    /**
     * Destructor.
     */
    ~Content();

    /**
     * Sets the id of the Content.
     * The id uniquely identifies a Content with the OCS API.
     * @param id the new id
     */
    void setId(const QString& id);

    /**
     * Gets the id of the Content.
     * The id uniquely identifies a Content with the OCS API.
     * @return the id
     */
    QString id() const;

    /**
     * Sets the name of the Content.
     * @param name the new name
     */
    void setName(const QString& name);

    /**
     * Gets the name of the Content.
     * @return the name
     */
    QString name() const;

    /**
     * Sets the rating of the Content.
     * @param rating the new rating, has to be in the range 0-100
     */
    void setRating(int rating);

    /**
     * Gets the rating of the Content.
     * @return the rating in the range 0-100
     */
    int rating() const;
    
    /**
     * Sets the number of downloads for the Content.
     * @param downloads the new number of downloads
     */
    void setDownloads(int downloads);
    
    /**
     * Gets the number of downloads for the Content (how often this has been downloaded from the server).
     * @return the number of downloads
     */
    int downloads() const;

    /**
     * Sets the number of comments for the Content.
     * @param numComments the new number of downloads
     */
    void setNumberOfComments(int numComments);

    /**
     * Gets the number of comments for the Content.
     * @return the number of comments
     */
    int numberOfComments() const;

    /**
     * Sets the date and time the Content has been created.
     * @param created the new creation date and time
     */
    void setCreated(const QDateTime& created);
    
    /**
     * Gets the date and time the Content has been created.
     * @return the date and time of the last update
     */
    QDateTime created() const;

    /**
     * Sets the time the Content has been last updated.
     * @param updated the new date and time of the last update
     */
    void setUpdated(const QDateTime& updated);

    /**
     * Gets the date and time the Content has been last updated.
     * @return the date and time of the last update
     */
    QDateTime updated() const;

    /**
     * A summary description of this content.
     */
    QString summary() const;

    /**
     * A description of this content.
     */
    QString description() const;

    /**
     * A webpage with the detailed description of this content.
     */
    QUrl detailpage() const;

    QString changelog() const;
    QString version() const;
    QString depend() const;

    /**
      Get the details about a download (a content can have multiple links, eg for different distros).
      This is not very helpful if we don't know the allowed numbers.
      */
    DownloadDescription downloadUrlDescription(int number) const;

    /**
      Get all possible downloads.
      This is slow searching through lots of strings, so beware and don't call it too often.
      */
    QList<DownloadDescription> downloadUrlDescriptions() const;

    /**
      Get the details about a home page (a content can have multiple home pages, blog, bugs, ...).
      This is not very helpful if we don't know the allowed numbers.
      */
    HomePageEntry homePageEntry(int number) const;

    /**
      Get all home pages for this content.
      This is slow searching through lots of strings, so beware and don't call it too often.
      */
    QList<HomePageEntry> homePageEntries();

    QString previewPicture(const QString& number = QLatin1String("1")) const;
    QString smallPreviewPicture(const QString& number = QLatin1String("1")) const;
    QString license() const;
    QString licenseName() const;
    QString author() const;

    /**
      Get all icons for this content.
      */
    QList<Icon> icons();
    /**
     * Set list of icons.
     * @param icons list of icons for this content
     */
    void setIcons(QList<Icon> icons);

    /**
      Get all videos for this content.
      */
    QList<QUrl> videos();
    /**
     * Set list of videos.
     * @param videos list of videos for this content
     */
    void setVideos(QList<QUrl> videos);

    /**
     * Add an attribute that is not included in the basis set of attributes exposed by the Content class.
     * If the attribute already exists it gets overwritten.
     * @param key the key of the attribute
     * @param value the value of the attribute
     */
    void addAttribute( const QString &key, const QString &value );

    /**
     * Get an attribute that is not included in the basis set of attributes exposed by the Content class.
     * @param key the key of the attribute
     * @return the value of the attribute with the specified key, or an empty string, if the key has not been found
     */
    QString attribute( const QString &key ) const;

    /**
     * Get all attributes that are not included in the basis set of attributes exposed by the Content class.
     * @return the attribute mappings
     */
    QMap<QString,QString> attributes() const;

    
    /**
     * Checks whether this Content has an id
     * @return @c true if an id has been set, @c false otherwise
     */
    bool isValid() const;

  private:
    class Private;
    QSharedDataPointer<Private> d;
};

}

#endif