#4722 Summary Plot Editor : Update current item in tree view

Make sure the current selected item in the tree view is updated with the value in the underlying field.
This commit is contained in:
Magne Sjaastad 2019-09-20 09:44:26 +02:00
parent 4d82a65d8b
commit cba51615d8

View File

@ -354,6 +354,26 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
m_treeView->setRootIsDecorated(m_model->hasGrandChildren());
m_model->resetUiValueCache();
if (m_attributes.fieldToReceiveCurrentItemValue)
{
PdmUiFieldHandle* uiFieldHandle = m_attributes.fieldToReceiveCurrentItemValue->uiCapability();
if (uiFieldHandle)
{
QModelIndexList indices = allVisibleSourceModelIndices();
QVariant currentItemValue = uiFieldHandle->uiValue();
for (const auto& mi : indices)
{
QVariant itemValue = m_model->data(mi, PdmUiTreeSelectionQModel::optionItemValueRole());
if (currentItemValue == itemValue)
{
QModelIndex treeViewIndex = m_proxyModel->mapFromSource(mi);
m_treeView->setCurrentIndex(treeViewIndex);
}
}
}
}
}
//--------------------------------------------------------------------------------------------------