SnapResource.h 3.17 KB
Newer Older
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/***************************************************************************
 *   Copyright © 2013 Aleix Pol Gonzalez <aleixpol@blue-systems.com>       *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU General Public License as        *
 *   published by the Free Software Foundation; either version 2 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 14 of version 3 of the license.                    *
 *                                                                         *
 *   This program 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 General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ***************************************************************************/

#ifndef SNAPRESOURCE_H
#define SNAPRESOURCE_H

#include <resources/AbstractResource.h>
25
#include <QJsonObject>
26
#include <Snapd/Snap>
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
27
#include <QSharedPointer>
28
29

class SnapBackend;
30
class QAbstractItemModel;
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
31
32
33
34

class SnapResource : public AbstractResource
{
Q_OBJECT
35
Q_PROPERTY(QStringList objects MEMBER m_objects CONSTANT)
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
36
public:
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
37
38
    explicit SnapResource(QSharedPointer<QSnapdSnap> snap, AbstractResource::State state, SnapBackend* parent);
    ~SnapResource() override = default;
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
39
40
41
42
43
44
45
46
47
48
49
50

    QString section() override;
    QString origin() const override;
    QString longDescription() override;
    QString availableVersion() const override;
    QString installedVersion() const override;
    QString license() override;
    int size() override;
    QStringList categories() override;
    AbstractResource::State state() override;
    QVariant icon() const override;
    QString comment() override;
51
    QString name() const override;
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
52
    QString packageName() const override;
53
    bool isTechnical() const override;
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
54
55
56
57
    bool canExecute() const override { return true; }
    void invokeApplication() const override;
    void fetchChangelog() override;
    void fetchScreenshots() override;
58
    QList<PackageState> addonsInformation() override { return {}; }
59
    void setSnap(const QSharedPointer<QSnapdSnap> &snap);
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
60

61
    void setState(AbstractResource::State state);
62
    QString sourceIcon() const override { return QStringLiteral("snap"); }
63

64
65
    QDate releaseDate() const override;

66
    Q_SCRIPTABLE QAbstractItemModel* plugs(QObject* parents);
67
    QString appstreamId() const override;
68

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
69
public:
70
    void gotIcon();
71
    AbstractResource::State m_state;
72

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
73
    QSharedPointer<QSnapdSnap> m_snap;
74
    mutable QVariant m_icon;
75
    static const QStringList m_objects;
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
76
77
78
};

#endif // SNAPRESOURCE_H