blob: 8f7479a4b1f3afcefa594822ff2196988a1ad0f6 (
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
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef ADDNODEMODEL_H
#define ADDNODEMODEL_H
#include <QAbstractListModel>
#include <QList>
#include <QString>
#include <QVariant>
class EffectManager;
struct NodeDataProperty {
Q_GADGET
Q_PROPERTY(QString name MEMBER m_name)
Q_PROPERTY(QString type MEMBER m_type)
public:
QString m_name;
QString m_type;
};
class AddNodeModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged)
public:
struct NodeData {
QString name;
QString description;
QString file;
QString group;
QStringList requiredNodes;
// Properties as variant list to get access from QML
QVariantList properties;
// False when node would overlap with existing node in view
bool canBeAdded = true;
bool show = false;
};
enum AddNodeModelRoles {
Name = Qt::UserRole + 1,
Description,
File,
Group,
Properties,
CanBeAdded,
Show,
RequiredNodes
};
explicit AddNodeModel(QObject *effectManager);
int rowCount(const QModelIndex & = QModelIndex()) const final;
QVariant data(const QModelIndex &index, int role) const final;
QHash<int, QByteArray> roleNames() const final;
void updateCanBeAdded(const QStringList &propertyNames);
void updateShowHide(const QString &groupName, bool show);
void updateNodesList();
signals:
void rowCountChanged();
private:
void loadNodesFromPath(const QString &path);
QList<NodeData> m_modelList;
EffectManager *m_effectManager = nullptr;
};
bool operator==(const AddNodeModel::NodeData &a, const AddNodeModel::NodeData &b) noexcept;
Q_DECLARE_METATYPE(NodeDataProperty);
#endif // ADDNODEMODEL_H
|