Commit d3f18b52 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

qt4: preferences_widget: Use inheritance instead of switch.

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 8d4f298b
......@@ -162,43 +162,6 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
return p_control;
}
void ConfigControl::doApply( intf_thread_t *p_intf )
{
switch( getType() )
{
case CONFIG_ITEM_INTEGER:
case CONFIG_ITEM_BOOL:
{
VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(this);
assert( vicc );
config_PutInt( p_intf, vicc->getName(), vicc->getValue() );
break;
}
case CONFIG_ITEM_FLOAT:
{
VFloatConfigControl *vfcc =
qobject_cast<VFloatConfigControl *>(this);
assert( vfcc );
config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() );
break;
}
case CONFIG_ITEM_STRING:
{
VStringConfigControl *vscc =
qobject_cast<VStringConfigControl *>(this);
assert( vscc );
config_PutPsz( p_intf, vscc->getName(), qtu( vscc->getValue() ) );
break;
}
case CONFIG_ITEM_KEY:
{
KeySelectorControl *ksc = qobject_cast<KeySelectorControl *>(this);
assert( ksc );
ksc->doApply();
}
}
}
/*******************************************************
* Simple widgets
*******************************************************/
......@@ -241,6 +204,12 @@ void InterfacePreviewWidget::setPreview( enum_style e_style )
* String-based controls
*************************************************************************/
void
VStringConfigControl::doApply( intf_thread_t *p_intf )
{
config_PutPsz( p_intf, getName(), qtu( getValue() ) );
}
/*********** String **************/
StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
......@@ -844,6 +813,12 @@ void ModuleListConfigControl::onUpdate()
* Integer-based controls
*************************************************************************/
void
VIntConfigControl::doApply( intf_thread_t *p_intf )
{
config_PutInt( p_intf, getName(), getValue() );
}
/*********** Integer **************/
IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
......@@ -1123,6 +1098,12 @@ int BoolConfigControl::getValue() const
* Float-based controls
*************************************************************************/
void
VFloatConfigControl::doApply( intf_thread_t *p_intf )
{
config_PutFloat( p_intf, getName(), getValue() );
}
/*********** Float **************/
FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
......@@ -1416,7 +1397,7 @@ void KeySelectorControl::setTheKey()
Qt::UserRole, shortcutValue->getValue() );
}
void KeySelectorControl::doApply()
void KeySelectorControl::doApply( intf_thread_t* )
{
QTreeWidgetItem *it;
for( int i = 0; i < table->topLevelItemCount() ; i++ )
......
......@@ -101,7 +101,7 @@ public:
static ConfigControl * createControl( vlc_object_t*,
module_config_t*,QWidget*,
QGridLayout *, int& );
void doApply( intf_thread_t *);
virtual void doApply( intf_thread_t *) = 0;
protected:
vlc_object_t *p_this;
module_config_t *p_item;
......@@ -127,6 +127,7 @@ public:
ConfigControl(a,b) {};
virtual int getValue() const = 0;
virtual int getType() const { return CONFIG_ITEM_INTEGER; }
virtual void doApply( intf_thread_t *);
};
class IntegerConfigControl : public VIntConfigControl
......@@ -223,6 +224,7 @@ public:
ConfigControl(a,b) {};
virtual float getValue() const = 0;
virtual int getType() const { return CONFIG_ITEM_FLOAT; }
virtual void doApply( intf_thread_t *);
};
class FloatConfigControl : public VFloatConfigControl
......@@ -270,6 +272,7 @@ public:
ConfigControl(a,b) {};
virtual QString getValue() const = 0;
virtual int getType() const { return CONFIG_ITEM_STRING; }
virtual void doApply( intf_thread_t *);
};
class StringConfigControl : public VStringConfigControl
......@@ -454,7 +457,7 @@ public:
virtual int getType() const { return CONFIG_ITEM_KEY; }
virtual void hide() { table->hide(); if( label ) label->hide(); }
virtual void show() { table->show(); if( label ) label->show(); }
void doApply();
virtual void doApply( intf_thread_t *);
private:
void finish();
QLabel *label;
......
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