File indexing completed on 2024-04-21 15:02:24

0001 /*
0002     SPDX-FileCopyrightText: 2016 Dan Leinir Turthra Jensen <admin@leinir.dk>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef DOWNLOADLINKINFO_H
0008 #define DOWNLOADLINKINFO_H
0009 
0010 #include <QObject>
0011 
0012 #include "KNSCore/EntryInternal"
0013 
0014 #include <memory>
0015 
0016 class DownloadLinkInfoPrivate;
0017 /**
0018  * @short One downloadable item as contained within one content item
0019  *
0020  * A simple data container which wraps a KNSCore::EntryInternal::DownloadLinkInformation
0021  * instance and provides property accessors for each of the pieces of information stored
0022  * in it.
0023  */
0024 class DownloadLinkInfo : public QObject
0025 {
0026     Q_OBJECT
0027     Q_PROPERTY(QString name READ name NOTIFY dataChanged)
0028     Q_PROPERTY(QString priceAmount READ priceAmount NOTIFY dataChanged)
0029     Q_PROPERTY(QString distributionType READ distributionType NOTIFY dataChanged)
0030     Q_PROPERTY(QString descriptionLink READ descriptionLink NOTIFY dataChanged)
0031     Q_PROPERTY(int id READ id NOTIFY dataChanged)
0032     Q_PROPERTY(bool isDownloadtypeLink READ isDownloadtypeLink NOTIFY dataChanged)
0033     Q_PROPERTY(quint64 size READ size NOTIFY dataChanged)
0034     Q_PROPERTY(QString formattedSize READ formattedSize NOTIFY dataChanged)
0035     Q_PROPERTY(QString icon READ icon NOTIFY dataChanged)
0036 
0037 public:
0038     explicit DownloadLinkInfo(QObject *parent = nullptr);
0039     ~DownloadLinkInfo() override;
0040 
0041     void setData(const KNSCore::EntryInternal::DownloadLinkInformation &data);
0042     Q_SIGNAL void dataChanged();
0043 
0044     QString name() const;
0045     QString priceAmount() const;
0046     QString distributionType() const;
0047     QString descriptionLink() const;
0048     int id() const;
0049     bool isDownloadtypeLink() const;
0050     quint64 size() const;
0051     QString formattedSize() const;
0052     QString icon() const;
0053 
0054 private:
0055     const std::unique_ptr<DownloadLinkInfoPrivate> d;
0056 };
0057 
0058 #endif // DOWNLOADLINKINFO_H