From c579c614043655cefe1f6b6d3f8535d0961aace1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 1 Aug 2014 13:35:28 +0200 Subject: [PATCH] Fwk: Update enabled state for icons based on object toggle field --- Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp | 12 ++++++++++++ Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp index d752765d8e..d32c20c4fa 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.cpp @@ -464,5 +464,17 @@ void PdmObject::addUiTreeChildren(PdmUiTreeOrdering* root, QString uiConfigName } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmObject::updateUiIconFromToggleField() +{ + if (objectToggleField()) + { + bool active = objectToggleField()->uiValue().toBool(); + updateUiIconFromState(active); + } +} + } //End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h index 94eb759c48..457a8b1371 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h @@ -174,6 +174,8 @@ public: /// Return object editor specific parameters used to customize the editor behavior. void objectEditorAttribute(QString uiConfigName, PdmUiEditorAttribute* attribute); + void updateUiIconFromToggleField(); + // Virtual interface to override in subclasses to support special behaviour if needed public: // Virtual virtual PdmFieldHandle* userDescriptionField() { return NULL; } @@ -196,7 +198,8 @@ public: protected: // Virtual /// Method gets called from PdmDocument after all objects are read. /// Re-implement to set up internal pointers etc. in your data structure - virtual void initAfterRead() {}; + virtual void initAfterRead() { updateUiIconFromToggleField(); }; + /// Method gets called from PdmDocument before saving document. /// Re-implement to make sure your fields have correct data before saving virtual void setupBeforeSave() {};