File indexing completed on 2024-04-14 14:16:53

0001 /*
0002     This file is part of KDE.
0003 
0004     SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef ATTICA_CONTENT_H
0010 #define ATTICA_CONTENT_H
0011 
0012 #include <QList>
0013 #include <QMap>
0014 #include <QSharedDataPointer>
0015 #include <QString>
0016 #include <QUrl>
0017 
0018 #include "attica_export.h"
0019 #include "downloaddescription.h"
0020 #include "homepageentry.h"
0021 #include "icon.h"
0022 
0023 class QDateTime;
0024 
0025 namespace Attica
0026 {
0027 /**
0028  * @class Content content.h <Attica/Content>
0029  *
0030  * Represents a single content
0031  */
0032 class ATTICA_EXPORT Content
0033 {
0034 public:
0035     typedef QList<Content> List;
0036     class Parser;
0037 
0038     /**
0039      * Creates an empty Content
0040      */
0041     Content();
0042 
0043     /**
0044      * Copy constructor.
0045      * @param other the Content to copy from
0046      */
0047     Content(const Content &other);
0048 
0049     /**
0050      * Assignment operator.
0051      * @param other the Content to assign from
0052      * @return pointer to this Content
0053      */
0054     Content &operator=(const Content &other);
0055 
0056     /**
0057      * Destructor.
0058      */
0059     ~Content();
0060 
0061     /**
0062      * Sets the id of the Content.
0063      * The id uniquely identifies a Content with the OCS API.
0064      * @param id the new id
0065      */
0066     void setId(const QString &id);
0067 
0068     /**
0069      * Gets the id of the Content.
0070      * The id uniquely identifies a Content with the OCS API.
0071      * @return the id
0072      */
0073     QString id() const;
0074 
0075     /**
0076      * Sets the name of the Content.
0077      * @param name the new name
0078      */
0079     void setName(const QString &name);
0080 
0081     /**
0082      * Gets the name of the Content.
0083      * @return the name
0084      */
0085     QString name() const;
0086 
0087     /**
0088      * Sets the rating of the Content.
0089      * @param rating the new rating, has to be in the range 0-100
0090      */
0091     void setRating(int rating);
0092 
0093     /**
0094      * Gets the rating of the Content.
0095      * @return the rating in the range 0-100
0096      */
0097     int rating() const;
0098 
0099     /**
0100      * Sets the number of downloads for the Content.
0101      * @param downloads the new number of downloads
0102      */
0103     void setDownloads(int downloads);
0104 
0105     /**
0106      * Gets the number of downloads for the Content (how often this has been downloaded from the server).
0107      * @return the number of downloads
0108      */
0109     int downloads() const;
0110 
0111     /**
0112      * Sets the number of comments for the Content.
0113      * @param numComments the new number of downloads
0114      */
0115     void setNumberOfComments(int numComments);
0116 
0117     /**
0118      * Gets the number of comments for the Content.
0119      * @return the number of comments
0120      */
0121     int numberOfComments() const;
0122 
0123     /**
0124      * Sets the date and time the Content has been created.
0125      * @param created the new creation date and time
0126      */
0127     void setCreated(const QDateTime &created);
0128 
0129     /**
0130      * Gets the date and time the Content has been created.
0131      * @return the date and time of the last update
0132      */
0133     QDateTime created() const;
0134 
0135     /**
0136      * Sets the time the Content has been last updated.
0137      * @param updated the new date and time of the last update
0138      */
0139     void setUpdated(const QDateTime &updated);
0140 
0141     /**
0142      * Gets the date and time the Content has been last updated.
0143      * @return the date and time of the last update
0144      */
0145     QDateTime updated() const;
0146 
0147     /**
0148      * A summary description of this content.
0149      */
0150     QString summary() const;
0151 
0152     /**
0153      * A description of this content.
0154      */
0155     QString description() const;
0156 
0157     /**
0158      * A webpage with the detailed description of this content.
0159      */
0160     QUrl detailpage() const;
0161 
0162     QString changelog() const;
0163     QString version() const;
0164     QString depend() const;
0165 
0166     /**
0167       Get the details about a download (a content can have multiple links, eg for different distros).
0168       This is not very helpful if we don't know the allowed numbers.
0169       */
0170     DownloadDescription downloadUrlDescription(int number) const;
0171 
0172     /**
0173       Get all possible downloads.
0174       This is slow searching through lots of strings, so beware and don't call it too often.
0175       */
0176     QList<DownloadDescription> downloadUrlDescriptions() const;
0177 
0178     /**
0179       Get the details about a home page (a content can have multiple home pages, blog, bugs, ...).
0180       This is not very helpful if we don't know the allowed numbers.
0181       */
0182     HomePageEntry homePageEntry(int number) const;
0183 
0184     /**
0185       Get all home pages for this content.
0186       This is slow searching through lots of strings, so beware and don't call it too often.
0187       */
0188     QList<HomePageEntry> homePageEntries();
0189 
0190     QString previewPicture(const QString &number = QStringLiteral("1")) const;
0191     QString smallPreviewPicture(const QString &number = QStringLiteral("1")) const;
0192     QString license() const;
0193     QString licenseName() const;
0194     QString author() const;
0195 
0196     /**
0197       Get all icons for this content.
0198       */
0199     QList<Icon> icons();
0200 
0201     /**
0202       Get all icons for this content.
0203       */
0204     QList<Icon> icons() const;
0205 
0206     /**
0207      * Set list of icons.
0208      * @param icons list of icons for this content
0209      */
0210     void setIcons(QList<Icon> icons);
0211 
0212     /**
0213       Get all videos for this content.
0214       */
0215     QList<QUrl> videos();
0216     /**
0217      * Set list of videos.
0218      * @param videos list of videos for this content
0219      */
0220     void setVideos(QList<QUrl> videos);
0221 
0222     /**
0223      * Get all the tags for this content
0224      * @since 5.50
0225      */
0226     QStringList tags() const;
0227     /**
0228      * Set the list of tags
0229      * @param tags list of tags for this content
0230      * @since 5.50
0231      */
0232     void setTags(const QStringList &tags);
0233 
0234     /**
0235      * Add an attribute that is not included in the basis set of attributes exposed by the Content class.
0236      * If the attribute already exists it gets overwritten.
0237      * @param key the key of the attribute
0238      * @param value the value of the attribute
0239      */
0240     void addAttribute(const QString &key, const QString &value);
0241 
0242     /**
0243      * Get an attribute that is not included in the basis set of attributes exposed by the Content class.
0244      * @param key the key of the attribute
0245      * @return the value of the attribute with the specified key, or an empty string, if the key has not been found
0246      */
0247     QString attribute(const QString &key) const;
0248 
0249     /**
0250      * Get all attributes that are not included in the basis set of attributes exposed by the Content class.
0251      * @return the attribute mappings
0252      */
0253     QMap<QString, QString> attributes() const;
0254 
0255     /**
0256      * Checks whether this Content has an id
0257      * @return @c true if an id has been set, @c false otherwise
0258      */
0259     bool isValid() const;
0260 
0261 private:
0262     class Private;
0263     QSharedDataPointer<Private> d;
0264 };
0265 
0266 }
0267 
0268 #endif