Commit c2fe37f6 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Preferences. Introduction of a checkBoxListItem struct to handle (key,...

Qt4 - Preferences. Introduction of a checkBoxListItem struct to handle (key, value for CheckBoxes) in order to implement completely ModuleList autogeneration. Modify the functions needed to generate the correct String Configuration. Complete Preferences should be functionnal now.

parent c40effe2
...@@ -490,10 +490,10 @@ ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this, ...@@ -490,10 +490,10 @@ ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
finish( bycat ); finish( bycat );
int boxline = 0; int boxline = 0;
for( QVector<QCheckBox*>::iterator it = modules.begin(); for( QVector<checkBoxListItem*>::iterator it = modules.begin();
it != modules.end(); it++ ) it != modules.end(); it++ )
{ {
layoutGroupBox->addWidget( *it, boxline++, 0 ); layoutGroupBox->addWidget( (*it)->checkBox, boxline++, 0 );
} }
layoutGroupBox->addWidget( text, boxline, 0 ); layoutGroupBox->addWidget( text, boxline, 0 );
...@@ -507,6 +507,8 @@ ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this, ...@@ -507,6 +507,8 @@ ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
{ {
l->addWidget( groupBox, line, 0, 1, -1 ); l->addWidget( groupBox, line, 0, 1, -1 );
} }
text->setToolTip( formatTooltip( qfu( p_item->psz_longtext) ) );
} }
#if 0 #if 0
ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this, ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
...@@ -521,7 +523,7 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this, ...@@ -521,7 +523,7 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
ModuleListConfigControl::~ModuleListConfigControl() ModuleListConfigControl::~ModuleListConfigControl()
{ {
for( QVector<QCheckBox*>::iterator it = modules.begin(); for( QVector<checkBoxListItem*>::iterator it = modules.begin();
it != modules.end(); it++ ) it != modules.end(); it++ )
{ {
delete *it; delete *it;
...@@ -530,6 +532,25 @@ ModuleListConfigControl::~ModuleListConfigControl() ...@@ -530,6 +532,25 @@ ModuleListConfigControl::~ModuleListConfigControl()
delete text; delete text;
} }
#define CHECKBOX_LISTS \
{ \
QCheckBox *cb = new QCheckBox( qfu( p_parser->psz_longname ) );\
checkBoxListItem *cbl = new checkBoxListItem; \
\
CONNECT( cb, stateChanged( int ), this, onUpdate( int ) );\
cb->setToolTip( formatTooltip( qfu(p_parser->psz_longname)) );\
cbl->checkBox = cb; \
\
int i = -1; \
while( p_parser->pp_shortcuts[++i] != NULL); \
i--; \
\
cbl->psz_module = strdup( i>=0?p_parser->pp_shortcuts[i] \
: p_parser->psz_object_name ); \
modules.push_back( cbl ); \
}
void ModuleListConfigControl::finish( bool bycat ) void ModuleListConfigControl::finish( bool bycat )
{ {
vlc_list_t *p_list; vlc_list_t *p_list;
...@@ -552,22 +573,13 @@ void ModuleListConfigControl::finish( bool bycat ) ...@@ -552,22 +573,13 @@ void ModuleListConfigControl::finish( bool bycat )
if( p_config->i_type == CONFIG_SUBCATEGORY && if( p_config->i_type == CONFIG_SUBCATEGORY &&
p_config->value.i == p_item->min.i ) p_config->value.i == p_item->min.i )
{ {
QCheckBox *cb = CHECKBOX_LISTS;
new QCheckBox( qfu( p_parser->psz_object_name ) );
CONNECT( cb, stateChanged( int ), this, onUpdate( int ) );
cb->setToolTip(
formatTooltip( qfu(p_parser->psz_longname)) );
modules.push_back( cb );
} }
} }
} }
else if( !strcmp( p_parser->psz_capability, p_item->psz_type ) ) else if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
{ {
QCheckBox *cb = CHECKBOX_LISTS;
new QCheckBox( qfu( p_parser->psz_object_name ) );
CONNECT( cb, stateChanged( int ), this, onUpdate( int ) );
cb->setToolTip( formatTooltip(qfu(p_parser->psz_longname)) );
modules.push_back( cb );
} }
} }
vlc_list_release( p_list ); vlc_list_release( p_list );
...@@ -575,6 +587,7 @@ void ModuleListConfigControl::finish( bool bycat ) ...@@ -575,6 +587,7 @@ void ModuleListConfigControl::finish( bool bycat )
if( groupBox ) if( groupBox )
groupBox->setToolTip( formatTooltip(qfu(p_item->psz_longtext)) ); groupBox->setToolTip( formatTooltip(qfu(p_item->psz_longtext)) );
} }
#undef CHECKBOX_LISTS
QString ModuleListConfigControl::getValue() QString ModuleListConfigControl::getValue()
{ {
...@@ -583,20 +596,20 @@ QString ModuleListConfigControl::getValue() ...@@ -583,20 +596,20 @@ QString ModuleListConfigControl::getValue()
void ModuleListConfigControl::hide() void ModuleListConfigControl::hide()
{ {
for( QVector<QCheckBox*>::iterator it = modules.begin(); for( QVector<checkBoxListItem*>::iterator it = modules.begin();
it != modules.end(); it++ ) it != modules.end(); it++ )
{ {
(*it)->hide(); (*it)->checkBox->hide();
} }
groupBox->hide(); groupBox->hide();
} }
void ModuleListConfigControl::show() void ModuleListConfigControl::show()
{ {
for( QVector<QCheckBox*>::iterator it = modules.begin(); for( QVector<checkBoxListItem*>::iterator it = modules.begin();
it != modules.end(); it++ ) it != modules.end(); it++ )
{ {
(*it)->show(); (*it)->checkBox->show();
} }
groupBox->show(); groupBox->show();
} }
...@@ -607,19 +620,19 @@ void ModuleListConfigControl::onUpdate( int value ) ...@@ -607,19 +620,19 @@ void ModuleListConfigControl::onUpdate( int value )
text->clear(); text->clear();
bool first = true; bool first = true;
for( QVector<QCheckBox*>::iterator it = modules.begin(); for( QVector<checkBoxListItem*>::iterator it = modules.begin();
it != modules.end(); it++ ) it != modules.end(); it++ )
{ {
if( (*it)->isChecked() ) if( (*it)->checkBox->isChecked() )
{ {
if( first ) if( first )
{ {
text->setText( text->text() + (*it)->text() ); text->setText( text->text() + (*it)->psz_module );
first = false; first = false;
} }
else else
{ {
text->setText( text->text() + ":" + (*it)->text() ); text->setText( text->text() + ":" + (*it)->psz_module );
} }
} }
} }
......
...@@ -326,6 +326,11 @@ private: ...@@ -326,6 +326,11 @@ private:
QComboBox *combo; QComboBox *combo;
}; };
struct checkBoxListItem {
QCheckBox *checkBox;
char *psz_module;
};
class ModuleListConfigControl : public VStringConfigControl class ModuleListConfigControl : public VStringConfigControl
{ {
Q_OBJECT; Q_OBJECT;
...@@ -342,7 +347,7 @@ public slots: ...@@ -342,7 +347,7 @@ public slots:
void onUpdate( int value ); void onUpdate( int value );
private: private:
void finish( bool ); void finish( bool );
QVector<QCheckBox*> modules; QVector<checkBoxListItem*> modules;
QGroupBox *groupBox; QGroupBox *groupBox;
QLineEdit *text; QLineEdit *text;
}; };
......
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