1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef ARROWSMODEL_H
5#define ARROWSMODEL_H
6
7#include <QObject>
8#include <QAbstractListModel>
9#include <QtQml/qqmlregistration.h>
10
11class ArrowsModel : public QAbstractListModel
12{
13 Q_OBJECT
14 Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged)
15
16public:
17 struct Arrow {
18 float startX = 0;
19 float startY = 0;
20 float endX = 0;
21 float endY = 0;
22 int startNodeId = 0;
23 int endNodeId = 1;
24 bool operator==(const Arrow& rhs) const noexcept
25 {
26 return this->startNodeId == rhs.startNodeId;
27 }
28 };
29
30 enum NodesModelRoles {
31 Type = Qt::UserRole + 1,
32 StartX,
33 StartY,
34 EndX,
35 EndY,
36 StartNodeId,
37 EndNodeId
38 };
39
40 explicit ArrowsModel(QObject *parent = nullptr);
41
42 int rowCount(const QModelIndex & = QModelIndex()) const final;
43 QVariant data(const QModelIndex &index, int role) const final;
44 QHash<int, QByteArray> roleNames() const final;
45
46signals:
47 void rowCountChanged();
48
49private:
50 friend class NodeView;
51 friend class EffectManager;
52 QList<Arrow> m_arrowsList;
53
54};
55
56#endif // ARROWSMODEL_H
57

source code of qtquickeffectmaker/tools/qqem/arrowsmodel.h