2023-06-29 15:06:11 +03:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
|
|
#include "effectmakermodel.h"
|
|
|
|
|
|
2023-08-17 13:41:27 +03:00
|
|
|
#include "compositionnode.h"
|
|
|
|
|
|
2023-08-17 15:59:46 +03:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2023-06-29 15:06:11 +03:00
|
|
|
namespace QmlDesigner {
|
|
|
|
|
|
|
|
|
|
EffectMakerModel::EffectMakerModel(QObject *parent)
|
|
|
|
|
: QAbstractListModel{parent}
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<int, QByteArray> EffectMakerModel::roleNames() const
|
|
|
|
|
{
|
|
|
|
|
QHash<int, QByteArray> roles;
|
2023-08-17 13:41:27 +03:00
|
|
|
roles[NameRole] = "nodeName";
|
2023-08-21 11:52:11 +03:00
|
|
|
roles[UniformsRole] = "nodeUniformsModel";
|
2023-06-29 15:06:11 +03:00
|
|
|
return roles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int EffectMakerModel::rowCount(const QModelIndex &parent) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(parent)
|
|
|
|
|
|
2023-08-17 13:41:27 +03:00
|
|
|
return m_nodes.count();
|
2023-06-29 15:06:11 +03:00
|
|
|
}
|
|
|
|
|
|
2023-08-17 15:59:46 +03:00
|
|
|
QVariant EffectMakerModel::data(const QModelIndex &index, int role) const
|
2023-06-29 15:06:11 +03:00
|
|
|
{
|
2023-08-17 15:59:46 +03:00
|
|
|
QTC_ASSERT(index.isValid() && index.row() < m_nodes.size(), return {});
|
|
|
|
|
QTC_ASSERT(roleNames().contains(role), return {});
|
2023-06-29 15:06:11 +03:00
|
|
|
|
2023-08-17 15:59:46 +03:00
|
|
|
return m_nodes.values().at(index.row())->property(roleNames().value(role));
|
2023-06-29 15:06:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EffectMakerModel::resetModel()
|
|
|
|
|
{
|
|
|
|
|
beginResetModel();
|
|
|
|
|
endResetModel();
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-17 13:41:27 +03:00
|
|
|
void EffectMakerModel::addNode(const QString &nodeQenPath)
|
|
|
|
|
{
|
|
|
|
|
static int id = 0;
|
|
|
|
|
|
2023-08-17 15:59:46 +03:00
|
|
|
beginInsertRows({}, m_nodes.size(), m_nodes.size());
|
2023-08-17 13:41:27 +03:00
|
|
|
auto *node = new CompositionNode(nodeQenPath);
|
|
|
|
|
m_nodes.insert(id++, node);
|
2023-08-17 15:59:46 +03:00
|
|
|
endInsertRows();
|
2023-08-17 13:41:27 +03:00
|
|
|
}
|
|
|
|
|
|
2023-06-29 15:06:11 +03:00
|
|
|
void EffectMakerModel::selectEffect(int idx, bool force)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(idx)
|
|
|
|
|
Q_UNUSED(force)
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EffectMakerModel::applyToSelected(qint64 internalId, bool add)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(internalId)
|
|
|
|
|
Q_UNUSED(add)
|
|
|
|
|
|
|
|
|
|
// TODO: remove?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace QmlDesigner
|