Commit 68f3a56d authored by Frédéric Larue's avatar Frédéric Larue
Browse files

SetData() function added to UIParamChoice and UIParamList.

parent d89db52b
......@@ -64,6 +64,17 @@ void UIParamChoice::SetValue( const QString& value )
}
void UIParamChoice::SetData( int d )
{
for( auto b=m_ButtonDataMapping.begin(); b!=m_ButtonDataMapping.end(); ++b )
if( b.value() == d )
{
b.key()->setChecked( true );
break;
}
}
void UIParamChoice::changeCurrentChoice( bool toggled )
{
if( toggled )
......
......@@ -32,6 +32,8 @@ public:
void SetValue( const QString& value );
inline QString Value() const { return m_CurrentChoice->text(); }
void SetData( int d );
inline int Data() const { return m_ButtonDataMapping[m_CurrentChoice]; }
inline const QWidget* Widget() const { return m_Widget; }
......
......@@ -44,6 +44,17 @@ void UIParamList::SetValue( const QString& value )
}
void UIParamList::SetData( int d )
{
for( int i=0; i<Widget()->count(); ++i )
if( Widget()->itemData(i).value<int>() == d )
{
Widget()->setCurrentIndex( i );
break;
}
}
void UIParamList::triggerValueChanged( int index )
{
emit valueChanged( Widget()->itemText(index) );
......
......@@ -27,8 +27,10 @@ public:
const QList<int>& data = QList<int>() );
void SetValue( const QString& value );
inline QString Value() const { return ((QComboBox*)m_Widget)->currentText(); }
inline int Data() const { return ((QComboBox*)m_Widget)->itemData( ((QComboBox*)m_Widget)->currentIndex() ).value<int>(); }
inline QString Value() const { return Widget()->currentText(); }
void SetData( int d );
inline int Data() const { return Widget()->itemData( Widget()->currentIndex() ).value<int>(); }
inline const QComboBox* Widget() const { return (QComboBox*) m_Widget; }
inline QComboBox* Widget() { return (QComboBox*) m_Widget; }
......
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