Fix selecting component by part id

master
Jeremy HU 2022-10-06 23:18:03 +11:00
parent 19748816fe
commit 78893729b4
1 changed files with 2 additions and 0 deletions

View File

@ -126,6 +126,7 @@ void PartManageWidget::selectComponentByPartId(const dust3d::Uuid &partId)
QModelIndex index = m_componentPreviewGridWidget->componentListModel()->componentIdToIndex(componentId); QModelIndex index = m_componentPreviewGridWidget->componentListModel()->componentIdToIndex(componentId);
if (index.isValid()) { if (index.isValid()) {
m_componentPreviewGridWidget->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect); m_componentPreviewGridWidget->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
m_componentPreviewGridWidget->scrollTo(index);
return; return;
} }
const auto &component = m_document->findComponent(componentId); const auto &component = m_document->findComponent(componentId);
@ -135,6 +136,7 @@ void PartManageWidget::selectComponentByPartId(const dust3d::Uuid &partId)
index = m_componentPreviewGridWidget->componentListModel()->componentIdToIndex(componentId); index = m_componentPreviewGridWidget->componentListModel()->componentIdToIndex(componentId);
if (index.isValid()) { if (index.isValid()) {
m_componentPreviewGridWidget->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect); m_componentPreviewGridWidget->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
m_componentPreviewGridWidget->scrollTo(index);
return; return;
} }
dust3dDebug << "Unable to select component:" << componentId.toString(); dust3dDebug << "Unable to select component:" << componentId.toString();