aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexture.h
blob: 8f7197bc72ef204e9cd3c4850cc8ede8ba085738 (plain)
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
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <QFileInfo>
#include <QObject>
#include <QSize>
#include <QUrl>

namespace QmlDesigner {

class ContentLibraryTexture : public QObject
{
    Q_OBJECT

    Q_PROPERTY(QString textureIconPath MEMBER m_iconPath CONSTANT)
    Q_PROPERTY(QString textureParentPath READ parentDirPath CONSTANT)
    Q_PROPERTY(QString textureToolTip MEMBER m_toolTip NOTIFY textureToolTipChanged)
    Q_PROPERTY(QUrl textureIcon MEMBER m_icon CONSTANT)
    Q_PROPERTY(bool textureVisible MEMBER m_visible NOTIFY textureVisibleChanged)
    Q_PROPERTY(QString textureUrl MEMBER m_textureUrl CONSTANT)
    Q_PROPERTY(QString textureIconUrl MEMBER m_iconUrl CONSTANT)
    Q_PROPERTY(bool textureHasUpdate WRITE setHasUpdate READ hasUpdate NOTIFY hasUpdateChanged)
    Q_PROPERTY(bool textureIsNew MEMBER m_isNew CONSTANT)
    Q_PROPERTY(QString textureKey MEMBER m_textureKey CONSTANT)
    Q_PROPERTY(QString itemType MEMBER m_itemType CONSTANT)

public:
    ContentLibraryTexture(QObject *parent, const QFileInfo &iconFileInfo, const QString &dirPath,
                          const QString &suffix, const QSize &dimensions, const qint64 sizeInBytes,
                          const QString &key = {}, const QString &textureUrl = {},
                          const QString &iconUrl = {}, bool hasUpdate = false, bool isNew = false);

    Q_INVOKABLE bool isDownloaded() const;
    Q_INVOKABLE void setDownloaded();

    bool filter(const QString &searchText);

    QUrl icon() const;
    QString iconPath() const;
    QString texturePath() const;
    QString parentDirPath() const;
    QString textureKey() const;

    void setHasUpdate(bool value);
    bool hasUpdate() const;

signals:
    void textureVisibleChanged();
    void textureToolTipChanged();
    void hasUpdateChanged();

private:
    QString resolveSuffix();
    QString resolveToolTipText();
    void doSetDownloaded();

    QString m_iconPath;
    QString m_dirPath;
    QString m_textureUrl;
    QString m_iconUrl;
    QString m_toolTip;
    QString m_baseName;
    QString m_suffix;
    QString m_textureKey;
    QUrl m_icon;
    QSize m_dimensions;
    qint64 m_sizeInBytes = -1;
    bool m_isDownloaded = false;

    bool m_visible = true;
    bool m_hasUpdate = false;
    bool m_isNew = false;
    const QString m_itemType = "texture";
};

} // namespace QmlDesigner