From 2ccabc45895c2e531b657cfa72b745d2e27dd5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 9 Feb 2017 13:15:36 +0100 Subject: [PATCH] Caf: Added asserts to make it clearer that "useOptionsOnly" == false is unsupported yet. --- Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp | 8 +++----- .../cafUserInterface/cafPdmUiDefaultObjectEditor.cpp | 1 + Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp | 4 +++- Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp | 2 +- Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp | 5 ++++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp index a360b886a3..7a30762c9e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp @@ -77,12 +77,10 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName) { m_comboBox->setEnabled(!field()->isUiReadOnly(uiConfigName)); - // Demo code for attribute retreival when becoming relevant - // PdmUiComboBoxEditorAttribute attributes; - // field()->ownerObject()->editorAttribute(field(), uiConfigName, &attributes); - - bool fromMenuOnly = false; + bool fromMenuOnly = true; QList options = field()->valueOptions(&fromMenuOnly); + assert(fromMenuOnly); // Not supported + m_comboBox->blockSignals(true); m_comboBox->clear(); if (!options.isEmpty()) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp index c1575db075..be8064f98e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp @@ -435,6 +435,7 @@ caf::PdmUiFieldEditorHandle* PdmUiFieldEditorHelper::fieldEditorForField(PdmUiFi bool useOptionsOnly = true; QList options = field->valueOptions(&useOptionsOnly); + assert(fromMenuOnly); // Not supported if (!options.empty()) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index e46d513fcf..3d66262da3 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -215,8 +215,10 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName) } - bool fromMenuOnly = false; + bool fromMenuOnly = true; QList enumNames = field()->valueOptions(&fromMenuOnly); + assert(fromMenuOnly); // Not supported + if (!enumNames.isEmpty() && fromMenuOnly == true) { int enumValue = field()->uiValue().toInt(); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp index 82acc77eef..15314628f6 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp @@ -99,7 +99,7 @@ CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiListEditor); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -PdmUiListEditor::PdmUiListEditor(): m_optionsOnly(false) +PdmUiListEditor::PdmUiListEditor(): m_optionsOnly(true) { } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp index 6ce04aca82..160bdfb001 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp @@ -219,6 +219,7 @@ QVariant PdmUiTableViewModel::data(const QModelIndex &index, int role /*= Qt::Di QList options; bool useOptionsOnly = true; options = uiFieldHandle->valueOptions(&useOptionsOnly); + assert(useOptionsOnly); // Not supported for (QVariant v : valuesSelectedInField) { @@ -238,8 +239,10 @@ QVariant PdmUiTableViewModel::data(const QModelIndex &index, int role /*= Qt::Di return displayText; } - bool useOptionsOnly = false; + bool useOptionsOnly = true; QList valueOptions = uiFieldHandle->valueOptions(&useOptionsOnly); + assert(useOptionsOnly); // Not supported + if (!valueOptions.isEmpty()) { int listIndex = uiFieldHandle->uiValue().toInt();