Skip to content
Snippets Groups Projects
Commit b1635798 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH: - add a pointer to the parameter to be able to modify its activity status

     - connect parameterBase slots to signal emitted from two checkbox,
       then two slots are available, one handling the signal related to a paremeter
       Group checkbox, and the other slot is relative to a simple parameter relative
      checkbox
parent 8ad27472
Branches
Tags
No related merge requests found
......@@ -22,8 +22,8 @@ namespace otb
namespace Wrapper
{
QtWidgetParameterBase::QtWidgetParameterBase(QtWidgetModel* m)
: m_Model(m)
QtWidgetParameterBase::QtWidgetParameterBase(Parameter * param, QtWidgetModel* m)
: m_Param(param), m_Model(m)
{
}
......@@ -51,6 +51,64 @@ QtWidgetModel* QtWidgetParameterBase::GetModel()
return m_Model;
}
// Slot connected to the signal emitted the checkBox relative to
// current widget
void QtWidgetParameterBase::SetValue( int value )
{
switch(value)
{
case Qt::Unchecked:
this->setEnabled(false);
m_Param->SetChecked(false);
m_Param->SetActive(false);
break;
case Qt::PartiallyChecked:
break;
case Qt::Checked:
this->setEnabled(true);
m_Param->SetChecked(true);
m_Param->SetActive(true);
break;
}
}
// A slot connected to a signal emitted by a ParameterGroup
// we need to modify the children availabitily status
void QtWidgetParameterBase::SetValue( bool v)
{
// Update the Group status
this->setEnabled(v);
// Update iteratively the children status
for (unsigned int idx = 0; idx < m_Param->GetChildrenList().size(); ++idx)
{
this->ProcessChild(m_Param->GetChildrenList()[idx], v);
}
}
// Activate iteratively the children
void QtWidgetParameterBase::ProcessChild(Parameter* currentNode, bool status)
{
// Activate the current node if it was checked
if ( currentNode->IsChecked() && status)
{
currentNode->SetActive(status);
}
// If the status is false (deactivating) deactivate all the children
// tree
if (!status)
{
currentNode->SetActive(status);
}
unsigned int counter = 0;
while(counter < currentNode->GetChildrenList().size())
{
this->ProcessChild(currentNode->GetChildrenList()[counter], status);
++counter;
}
}
}
}
......@@ -34,13 +34,15 @@ class QtWidgetParameterBase : public QWidget
{
Q_OBJECT
public:
QtWidgetParameterBase(QtWidgetModel*);
QtWidgetParameterBase(Parameter *, QtWidgetModel*);
virtual ~QtWidgetParameterBase();
void CreateWidget();
public slots:
void UpdateGUI();
void SetValue( int value );
void SetValue( bool v );
protected slots:
void ParameterChanged(const QString& key);
......@@ -48,6 +50,8 @@ protected slots:
protected:
QtWidgetModel* GetModel();
virtual void ProcessChild(Parameter * currentNode, bool status);
private:
QtWidgetParameterBase(const QtWidgetParameterBase&); //purposely not implemented
void operator=(const QtWidgetParameterBase&); //purposely not implemented
......@@ -57,6 +61,8 @@ private:
virtual void DoCreateWidget() = 0;
QtWidgetModel* m_Model;
Parameter* m_Param;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment