Add auto scroll to new added component
parent
eb96caa0e6
commit
e370bd5392
|
@ -730,12 +730,14 @@ void PartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTreeWidgetIt
|
||||||
if (nullptr == parentComponent)
|
if (nullptr == parentComponent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const QTreeWidgetItem *scrollToItem = nullptr;
|
||||||
for (const auto &childId: parentComponent->childrenIds) {
|
for (const auto &childId: parentComponent->childrenIds) {
|
||||||
const Component *component = m_document->findComponent(childId);
|
const Component *component = m_document->findComponent(childId);
|
||||||
if (nullptr == component)
|
if (nullptr == component)
|
||||||
continue;
|
continue;
|
||||||
if (!component->linkToPartId.isNull()) {
|
if (!component->linkToPartId.isNull()) {
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
|
scrollToItem = item;
|
||||||
parentItem->addChild(item);
|
parentItem->addChild(item);
|
||||||
item->setData(0, Qt::UserRole, QVariant(component->id.toString()));
|
item->setData(0, Qt::UserRole, QVariant(component->id.toString()));
|
||||||
item->setFlags(item->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable));
|
item->setFlags(item->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable));
|
||||||
|
@ -747,6 +749,7 @@ void PartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTreeWidgetIt
|
||||||
m_partItemMap[partId] = item;
|
m_partItemMap[partId] = item;
|
||||||
} else {
|
} else {
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(component->name));
|
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(component->name));
|
||||||
|
scrollToItem = item;
|
||||||
parentItem->addChild(item);
|
parentItem->addChild(item);
|
||||||
item->setData(0, Qt::UserRole, QVariant(component->id.toString()));
|
item->setData(0, Qt::UserRole, QVariant(component->id.toString()));
|
||||||
item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
|
item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
|
||||||
|
@ -757,6 +760,9 @@ void PartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTreeWidgetIt
|
||||||
}
|
}
|
||||||
updateComponentSelectState(childId, isComponentSelected(childId));
|
updateComponentSelectState(childId, isComponentSelected(childId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nullptr != scrollToItem)
|
||||||
|
QTreeWidget::scrollToItem(scrollToItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartTreeWidget::deleteItemChildren(QTreeWidgetItem *item)
|
void PartTreeWidget::deleteItemChildren(QTreeWidgetItem *item)
|
||||||
|
|
Loading…
Reference in New Issue