aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/contentlibrary/contentlibrarymaterial.h
blob: 90d8468fa16e0f61df4ee7d2a814ee09c5e8e133 (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
// 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 "nodeinstanceglobal.h"

#include <QObject>
#include <QUrl>

namespace QmlDesigner {

class ContentLibraryMaterial : public QObject
{
    Q_OBJECT

    Q_PROPERTY(QString bundleMaterialName MEMBER m_name CONSTANT)
    Q_PROPERTY(QUrl bundleMaterialIcon MEMBER m_icon CONSTANT)
    Q_PROPERTY(bool bundleMaterialVisible MEMBER m_visible NOTIFY materialVisibleChanged)
    Q_PROPERTY(bool bundleMaterialImported READ imported WRITE setImported NOTIFY materialImportedChanged)
    Q_PROPERTY(QString bundleMaterialBaseWebUrl MEMBER m_baseWebUrl CONSTANT)
    Q_PROPERTY(QString bundleMaterialParentPath READ parentDirPath CONSTANT)
    Q_PROPERTY(QStringList bundleMaterialFiles READ allFiles CONSTANT)

public:
    ContentLibraryMaterial(QObject *parent,
                           const QString &name,
                           const QString &qml,
                           const TypeName &type,
                           const QUrl &icon,
                           const QStringList &files,
                           const QString &downloadPath,
                           const QString &baseWebUrl);

    bool filter(const QString &searchText);

    Q_INVOKABLE bool isDownloaded() const;

    QUrl icon() const;
    QString qml() const;
    TypeName type() const;
    QStringList files() const;
    bool visible() const;
    QString qmlFilePath() const;

    bool setImported(bool imported);
    bool imported() const;
    QString parentDirPath() const;
    QStringList allFiles() const;

signals:
    void materialVisibleChanged();
    void materialImportedChanged();

private:
    QString m_name;
    QString m_qml;
    TypeName m_type;
    QUrl m_icon;
    QStringList m_files;

    bool m_visible = true;
    bool m_imported = false;

    QString m_downloadPath;
    QString m_baseWebUrl;
    QStringList m_allFiles;
};

} // namespace QmlDesigner