Caf: Added asserts to make it clearer that "useOptionsOnly" == false is unsupported yet.

This commit is contained in:
Jacob Støren 2017-02-09 13:15:36 +01:00
parent 5df94a1e18
commit 2ccabc4589
5 changed files with 12 additions and 8 deletions

View File

@ -77,12 +77,10 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
{ {
m_comboBox->setEnabled(!field()->isUiReadOnly(uiConfigName)); m_comboBox->setEnabled(!field()->isUiReadOnly(uiConfigName));
// Demo code for attribute retreival when becoming relevant bool fromMenuOnly = true;
// PdmUiComboBoxEditorAttribute attributes;
// field()->ownerObject()->editorAttribute(field(), uiConfigName, &attributes);
bool fromMenuOnly = false;
QList<PdmOptionItemInfo> options = field()->valueOptions(&fromMenuOnly); QList<PdmOptionItemInfo> options = field()->valueOptions(&fromMenuOnly);
assert(fromMenuOnly); // Not supported
m_comboBox->blockSignals(true); m_comboBox->blockSignals(true);
m_comboBox->clear(); m_comboBox->clear();
if (!options.isEmpty()) if (!options.isEmpty())

View File

@ -435,6 +435,7 @@ caf::PdmUiFieldEditorHandle* PdmUiFieldEditorHelper::fieldEditorForField(PdmUiFi
bool useOptionsOnly = true; bool useOptionsOnly = true;
QList<PdmOptionItemInfo> options = field->valueOptions(&useOptionsOnly); QList<PdmOptionItemInfo> options = field->valueOptions(&useOptionsOnly);
assert(fromMenuOnly); // Not supported
if (!options.empty()) if (!options.empty())
{ {

View File

@ -215,8 +215,10 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName)
} }
bool fromMenuOnly = false; bool fromMenuOnly = true;
QList<PdmOptionItemInfo> enumNames = field()->valueOptions(&fromMenuOnly); QList<PdmOptionItemInfo> enumNames = field()->valueOptions(&fromMenuOnly);
assert(fromMenuOnly); // Not supported
if (!enumNames.isEmpty() && fromMenuOnly == true) if (!enumNames.isEmpty() && fromMenuOnly == true)
{ {
int enumValue = field()->uiValue().toInt(); int enumValue = field()->uiValue().toInt();

View File

@ -99,7 +99,7 @@ CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiListEditor);
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
PdmUiListEditor::PdmUiListEditor(): m_optionsOnly(false) PdmUiListEditor::PdmUiListEditor(): m_optionsOnly(true)
{ {
} }

View File

@ -219,6 +219,7 @@ QVariant PdmUiTableViewModel::data(const QModelIndex &index, int role /*= Qt::Di
QList<PdmOptionItemInfo> options; QList<PdmOptionItemInfo> options;
bool useOptionsOnly = true; bool useOptionsOnly = true;
options = uiFieldHandle->valueOptions(&useOptionsOnly); options = uiFieldHandle->valueOptions(&useOptionsOnly);
assert(useOptionsOnly); // Not supported
for (QVariant v : valuesSelectedInField) for (QVariant v : valuesSelectedInField)
{ {
@ -238,8 +239,10 @@ QVariant PdmUiTableViewModel::data(const QModelIndex &index, int role /*= Qt::Di
return displayText; return displayText;
} }
bool useOptionsOnly = false; bool useOptionsOnly = true;
QList<PdmOptionItemInfo> valueOptions = uiFieldHandle->valueOptions(&useOptionsOnly); QList<PdmOptionItemInfo> valueOptions = uiFieldHandle->valueOptions(&useOptionsOnly);
assert(useOptionsOnly); // Not supported
if (!valueOptions.isEmpty()) if (!valueOptions.isEmpty())
{ {
int listIndex = uiFieldHandle->uiValue().toInt(); int listIndex = uiFieldHandle->uiValue().toInt();