fix stack before warning

This commit is contained in:
王劲鹏 2021-02-24 14:10:22 +08:00 committed by osborn
parent 8ffc0753ef
commit 0f0b0b0756

View File

@ -54,12 +54,16 @@ void DoricGroupNode::configChildNode() {
newNode->setId(id);
newNode->init(this);
newNode->blend(model.property("props"));
mChildNodes.insert(idx, newNode);
int minIndex = qMin(idx, mView->childItems().size());
if (idx >= mChildNodes.size()) {
mChildNodes.append(newNode);
newNode->getNodeView()->setParentItem(mView);
} else {
mChildNodes.insert(idx, newNode);
newNode->getNodeView()->setParentItem(mView);
newNode->getNodeView()->stackBefore(
mView->childItems().at(minIndex));
mView->childItems().at(idx));
}
}
}
} else {
@ -75,19 +79,8 @@ void DoricGroupNode::configChildNode() {
}
if (position >= 0) {
// Found swap idx,position
DoricViewNode *reused = mChildNodes.at(position);
DoricViewNode *abandoned = mChildNodes.at(idx);
mChildNodes.swapItemsAt(position, idx);
// View swap index
reused->getNodeView()->setParentItem(nullptr);
int minIndex = qMin(idx, mView->childItems().size());
reused->getNodeView()->setParentItem(mView);
reused->getNodeView()->stackBefore(
mView->childItems().at(minIndex));
abandoned->getNodeView()->stackBefore(
mView->childItems().at(position));
mView->childItems().swapItemsAt(position, idx);
} else {
// Not found,insert
DoricViewNode *newNode = DoricViewNode::create(getContext(), type);
@ -95,12 +88,16 @@ void DoricGroupNode::configChildNode() {
newNode->setId(id);
newNode->init(this);
newNode->blend(model.property("props"));
mChildNodes.insert(idx, newNode);
int minIndex = qMin(idx, mView->childItems().size());
if (idx >= mChildNodes.size()) {
mChildNodes.append(newNode);
newNode->getNodeView()->setParentItem(mView);
} else {
mChildNodes.insert(idx, newNode);
newNode->getNodeView()->setParentItem(mView);
newNode->getNodeView()->stackBefore(
mView->childItems().at(minIndex));
mView->childItems().at(idx));
}
}
}
}
@ -112,11 +109,15 @@ void DoricGroupNode::configChildNode() {
newNode->setId(id);
newNode->init(this);
newNode->blend(model.property("props"));
mChildNodes.append(newNode);
int minIndex = qMin(idx, mView->childItems().size());
if (idx >= mChildNodes.size()) {
mChildNodes.append(newNode);
newNode->getNodeView()->setParentItem(mView);
newNode->getNodeView()->stackBefore(mView->childItems().at(minIndex));
} else {
mChildNodes.insert(idx, newNode);
newNode->getNodeView()->setParentItem(mView);
newNode->getNodeView()->stackBefore(mView->childItems().at(idx));
}
}
}
}