#4924 AppFwk : Add support for editable combo box

This commit is contained in:
Magne Sjaastad
2019-10-24 21:03:17 +02:00
parent 580d826922
commit 32128f0bf3
7 changed files with 168 additions and 24 deletions
@@ -20,6 +20,8 @@ void caf::PdmFieldUiCap<FieldType>::setValueFromUiEditor(const QVariant& uiValue
{
QVariant oldUiBasedQVariant = toUiBasedQVariant();
bool setUiValueDirectly = false;
// Check whether we are handling selections of values or actual values
if (m_optionEntryCache.size())
{
@@ -77,17 +79,22 @@ void caf::PdmFieldUiCap<FieldType>::setValueFromUiEditor(const QVariant& uiValue
}
else
{
// We are not getting indexes as expected from the UI. For now assert, to catch this condition
// but it should possibly be handled as setting the values explicitly. The code for that is below the assert
CAF_ASSERT(false);
typename FieldType::FieldDataType value;
PdmUiFieldSpecialization<typename FieldType::FieldDataType>::setFromVariant(uiValue, value);
m_field->setValue(value);
m_optionEntryCache.clear();
// We are not getting indexes as usually expected when an option cache is present.
// This situation can occur if a text field is edited by a combobox allowing user defined input
// when a history of recently used strings are stored in a field of string
setUiValueDirectly = true;
}
}
else
{ // Not an option based GUI, the uiValue is a real field value
{
// Not an option based GUI, the uiValue is a real field value
setUiValueDirectly = true;
}
if (setUiValueDirectly)
{
typename FieldType::FieldDataType value;
PdmUiFieldSpecialization<typename FieldType::FieldDataType>::setFromVariant(uiValue, value);
m_field->setValue(value);