impl blend in group, super & view

This commit is contained in:
王劲鹏
2021-02-20 16:20:18 +08:00
committed by osborn
parent ea0b87df24
commit 65d6f97908
11 changed files with 119 additions and 17 deletions

View File

@@ -1,11 +1,53 @@
#include <QJSValueIterator>
#include "DoricSuperNode.h"
void DoricSuperNode::blend(QQuickItem *view, QString name, QJSValue prop) {
if (name == "subviews") {
if (prop.isArray()) {
qDebug() << prop.toString();
const int length = prop.property("length").toInt();
for (int i = 0; i < length; ++i) {
QJSValue subNode = prop.property(i);
mixinSubNode(subNode);
blendSubNode(subNode);
}
}
} else {
qCritical() << "super node blend";
DoricViewNode::blend(view, name, prop);
}
}
void DoricSuperNode::mixinSubNode(QJSValue subNode) {
QString id = subNode.property("id").toString();
qCritical() << id;
QList<QString> keys = subNodes.keys();
if (keys.contains(id)) {
subNodes.insert(id, subNode);
} else {
mixin(subNode, subNodes.value(id));
}
}
void DoricSuperNode::mixin(QJSValue src, QJSValue target) {
QJSValue srcProps = src.property("props");
QJSValue targetProps = target.property("props");
QJSValueIterator it(srcProps);
while (it.hasNext()) {
it.next();
if (it.name() == "subviews" && it.value().isArray()) {
} else {
targetProps.setProperty(it.name(), it.value());
}
}
}
QJSValue DoricSuperNode::getSubModel(QString id) {
if (subNodes.keys().contains(id)) {
return subNodes.value(id);
} else {
return QJSValue::UndefinedValue;
}
}