aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/effectcomposer/effectcomposeruniformsmodel.h
blob: 44f1dc7224d0e5f3cc7a1a6453d1132740f6397b (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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <QStandardItemModel>

namespace EffectComposer {

class Uniform;

class EffectComposerUniformsModel : public QAbstractListModel
{
    Q_OBJECT

public:
    enum Roles {
        NameRole = Qt::UserRole + 1,
        DisplayNameRole,
        DescriptionRole,
        ValueRole,
        BackendValueRole,
        DefaultValueRole,
        MaxValueRole,
        MinValueRole,
        TypeRole,
        ControlTypeRole,
        UseCustomValueRole,
        UserAdded,
        IsInUse
    };

    EffectComposerUniformsModel(QObject *parent = nullptr);

    QHash<int, QByteArray> roleNames() const override;
    int rowCount(const QModelIndex & parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    bool setData(const QModelIndex &index, const QVariant &value, int role) override;
    Q_INVOKABLE bool resetData(int row);
    Q_INVOKABLE bool remove(int row);
    Q_INVOKABLE QStringList displayNames() const;
    Q_INVOKABLE QStringList uniformNames() const;

    void resetModel();

    void addUniform(Uniform *uniform);
    void updateUniform(int uniformIndex, Uniform *uniform);

    QList<Uniform *> uniforms() const;

signals:
    void uniformRenamed(QString oldName, QString newName);

private:
    QList<Uniform *> m_uniforms;
};

} // namespace EffectComposer