From b3b0a7ba9bf5db842774cfb1ed90dcb032902c7a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Sep 2017 10:43:19 +0200 Subject: [PATCH] #1895 Curve Creator : Use PdmFieldHandle instead of PdmUiFieldHandle --- .../cafTests/cafTestApplication/MainWindow.cpp | 2 +- .../cafUserInterface/cafPdmUiTreeSelectionEditor.cpp | 12 ++++++++---- .../cafUserInterface/cafPdmUiTreeSelectionEditor.h | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp index 704d49c547..3c3e007cbe 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp @@ -330,7 +330,7 @@ protected: caf::PdmUiTreeSelectionEditorAttribute* attr = dynamic_cast(attribute); if (attr) { - attr->fieldToReceiveCurrentFieldValue = m_highlightedEnum.uiCapability(); + attr->fieldToReceiveCurrentFieldValue = &m_highlightedEnum; } } } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index 7fc59051e1..0d8540482a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -407,13 +407,17 @@ void PdmUiTreeSelectionEditor::slotTextFilterChanged() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiTreeSelectionEditor::slotCurrentChanged(const QModelIndex & current, const QModelIndex & previous) +void PdmUiTreeSelectionEditor::slotCurrentChanged(const QModelIndex& current, const QModelIndex& previous) { - if (m_attributes.fieldToReceiveCurrentFieldValue) + if (m_attributes.fieldToReceiveCurrentItemValue) { - QVariant v = m_proxyModel->data(current, PdmUiTreeSelectionQModel::optionItemValueRole()); + PdmUiFieldHandle* uiFieldHandle = m_attributes.fieldToReceiveCurrentItemValue->uiCapability(); + if (uiFieldHandle) + { + QVariant v = m_proxyModel->data(current, PdmUiTreeSelectionQModel::optionItemValueRole()); - PdmUiCommandSystemProxy::instance()->setUiValueToField(m_attributes.fieldToReceiveCurrentFieldValue, v); + PdmUiCommandSystemProxy::instance()->setUiValueToField(uiFieldHandle, v); + } } } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h index 5256b304af..301285206f 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h @@ -66,7 +66,7 @@ public: /// This is useful when displaying a list of appEnums, and a dependent view is displaying content based on /// the current item in the tree view /// Make sure the type of the receiving field is of the same type as the field used in PdmUiTreeSelectionEditor - caf::PdmUiFieldHandle* fieldToReceiveCurrentFieldValue; + caf::PdmFieldHandle* fieldToReceiveCurrentItemValue; public: PdmUiTreeSelectionEditorAttribute() @@ -74,7 +74,7 @@ public: showTextFilter = true; showToggleAllCheckbox = true; - fieldToReceiveCurrentFieldValue = nullptr; + fieldToReceiveCurrentItemValue = nullptr; } }; @@ -107,7 +107,7 @@ private slots: void slotTextFilterChanged(); - void slotCurrentChanged(const QModelIndex & current, const QModelIndex & previous); + void slotCurrentChanged(const QModelIndex& current, const QModelIndex& previous); private: void checkAllItems();