Commit 2350e1ff authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Some bug fix in the UIParamChildren class.

- the triggerParamUpdate() signal is now triggered only if the selected object of the combo box changed, and not if the content of the combo box changed.
- behaviour added that makes it possible to hide a UIParamChildren when it represents an empty list of items.
parent 42e780a3
......@@ -18,6 +18,7 @@ UIParamChildren::UIParamChildren( const QString& id,
const QStringList& typeFilter )
: UIParam(id,name,description)
{
m_HiddenIfEmpty = false;
m_TypeFilters = typeFilter;
m_Widget = new QComboBox();
Widget()->addItem( QString(), QVariant::fromValue<void*>(0) );
......@@ -76,5 +77,16 @@ void UIParamChildren::Update( GenericUIData *d )
Widget()->addItem( QString(), QVariant::fromValue<void*>(0) );
Update( d->GetChildren(), current, currentNewIndex, true );
if( m_HiddenIfEmpty )
{
if( IsVisible() && Count() == 0 )
SetHidden();
else if( IsHidden() && Count() != 0 )
SetVisible();
}
Widget()->setCurrentIndex( currentNewIndex );
if( current != Value() )
emit triggerParameterUpdate();
}
......@@ -19,6 +19,7 @@ class GenericUIData;
class UIParamChildren : public UIParam
{
QStringList m_TypeFilters;
bool m_HiddenIfEmpty;
void Update( const QList<GenericUIData*>& dataList, GenericUIData *current, int &currentNewIndex, bool recursive );
......@@ -30,7 +31,7 @@ public:
void SetValue( const QString& value );
inline GenericUIData* Value() const { return (GenericUIData*) Widget()->currentData().value<void*>(); }
unsigned int Count() const { return Widget()->count() - 1; }
unsigned int Count() const { return std::max( Widget()->count()-1, 0 ); }
inline const QComboBox* Widget() const { return (QComboBox*) m_Widget; }
inline QComboBox* Widget() { return (QComboBox*) m_Widget; }
......@@ -39,12 +40,15 @@ public:
void Update( GenericUIData *d );
inline void ConnectModificationSignal();
inline bool IsHiddenIfEmpty() const { return m_HiddenIfEmpty; }
inline void SetHiddenIfEmpty( bool hidden ) { m_HiddenIfEmpty = hidden; }
};
inline void UIParamChildren::ConnectModificationSignal()
{
QObject::connect( Widget(), SIGNAL(currentIndexChanged(int)), this, SLOT(triggerParameterUpdate()) );
//QObject::connect( Widget(), SIGNAL(currentIndexChanged(int)), this, SLOT(triggerParameterUpdate()) );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment