QmlDesigner: Prepare composition model for adding a node

Change-Id: If4d7fda3956ce4e7f6060e827329b1e8698d5b2f
Reviewed-by: Amr Elsayed <amr.elsayed@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
Mahmoud Badri
2023-08-17 13:41:27 +03:00
parent b4d153562b
commit d11f3202a2
8 changed files with 45 additions and 30 deletions

View File

@@ -3,6 +3,8 @@
#include "effectmakermodel.h"
#include "compositionnode.h"
namespace QmlDesigner {
EffectMakerModel::EffectMakerModel(QObject *parent)
@@ -13,8 +15,7 @@ EffectMakerModel::EffectMakerModel(QObject *parent)
QHash<int, QByteArray> EffectMakerModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[CategoryRole] = "categoryName";
roles[EffectsRole] = "effectNames";
roles[NameRole] = "nodeName";
return roles;
}
@@ -22,12 +23,12 @@ int EffectMakerModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return m_categories.count();
return m_nodes.count();
}
QVariant EffectMakerModel::data(const QModelIndex &index, int /*role*/) const
{
if (index.row() < 0 || index.row() >= m_categories.count())
if (index.row() < 0 || index.row() >= m_nodes.count())
return {};
// TODO
@@ -41,6 +42,15 @@ void EffectMakerModel::resetModel()
endResetModel();
}
void EffectMakerModel::addNode(const QString &nodeQenPath)
{
static int id = 0;
auto *node = new CompositionNode(nodeQenPath);
m_nodes.insert(id++, node);
// TODO: update model
}
void EffectMakerModel::selectEffect(int idx, bool force)
{
Q_UNUSED(idx)