From 681e5031e735d69d117095fac7fc77e26210b2a8 Mon Sep 17 00:00:00 2001
From: Otmane Lahlou <otmane.lahlou@c-s.fr>
Date: Fri, 14 Oct 2011 11:42:11 +0200
Subject: [PATCH] ENH: checkbox status follow its parameter activity status

---
 .../QtWidget/otbWrapperQtWidgetParameterBase.cxx         | 9 ++++++++-
 Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.h | 3 +++
 .../QtWidget/otbWrapperQtWidgetParameterGroup.cxx        | 6 ++++--
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.cxx
index b8342ffcef..7138c930e4 100644
--- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.cxx
+++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.cxx
@@ -38,9 +38,16 @@ void QtWidgetParameterBase::CreateWidget()
 
 void QtWidgetParameterBase::UpdateGUI()
 {
-  this->DoUpdateGUI();
+  //
+ this->DoUpdateGUI();
+
+ // Emit State of the Parameter to update this paramter checkbox
+ bool state = m_Param->GetActive();
+ emit ParameterActiveStatus(state);
 }
 
+
+
 void QtWidgetParameterBase::ParameterChanged(const QString& key)
 {
 
diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.h
index 9292ab5fbe..d77e24c58c 100644
--- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.h
+++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.h
@@ -46,6 +46,9 @@ public slots:
 protected slots:
   void ParameterChanged(const QString& key);
 
+signals:
+  virtual void ParameterActiveStatus(bool value);
+
 protected:
   QtWidgetModel* GetModel();
 
diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx
index ccff492417..8b53478716 100644
--- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx
+++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx
@@ -73,9 +73,11 @@ void QtWidgetParameterGroup::DoCreateWidget()
 
         // CheckBox (col 1)
         QCheckBox * checkBox = new QCheckBox;
-        connect(checkBox, SIGNAL(clicked(bool)), specificWidget, SLOT(SetActivationState(bool)));
+        connect( checkBox, SIGNAL(clicked(bool)), specificWidget, SLOT(SetActivationState(bool)));
         connect( checkBox, SIGNAL(clicked(bool)), GetModel(), SLOT(NotifyUpdate()) );
-        
+        connect( specificWidget, SIGNAL(ParameterActiveStatus(bool)), checkBox, SLOT(setChecked(bool)));
+        connect( specificWidget, SIGNAL(ParameterActiveStatus(bool)), specificWidget, SLOT(SetActivationState(bool)));
+    
         if (param->IsRoot())
            {
           // if Mandatory make the checkbox checked and deactivated
-- 
GitLab