[vlc-commits] Qt4: use config_Get(Int|Psz)Choices()
Rémi Denis-Courmont
git at videolan.org
Tue Aug 14 23:59:42 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 15 00:59:12 2012 +0300| [fb1eda2e5c2ef8258ea3b89a55792be2fda5c361] | committer: Rémi Denis-Courmont
Qt4: use config_Get(Int|Psz)Choices()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fb1eda2e5c2ef8258ea3b89a55792be2fda5c361
---
modules/gui/qt4/components/extended_panels.cpp | 42 ++++++---
modules/gui/qt4/components/preferences_widgets.cpp | 92 +++++++++-----------
2 files changed, 71 insertions(+), 63 deletions(-)
diff --git a/modules/gui/qt4/components/extended_panels.cpp b/modules/gui/qt4/components/extended_panels.cpp
index 7bc8998..9f9e7eb 100644
--- a/modules/gui/qt4/components/extended_panels.cpp
+++ b/modules/gui/qt4/components/extended_panels.cpp
@@ -440,23 +440,41 @@ void ExtVideo::initComboBoxItems( QObject *widget )
QString option = OptionFromWidgetName( widget );
module_config_t *p_item = config_FindConfig( VLC_OBJECT( p_intf ),
qtu( option ) );
- if( p_item )
+ if( p_item == NULL )
{
- int i_type = p_item->i_type;
- for( int i_index = 0; i_index < p_item->i_list; i_index++ )
+ msg_Err( p_intf, "Couldn't find option \"%s\".", qtu( option ) );
+ return;
+ }
+
+ if( p_item->i_type == CONFIG_ITEM_INTEGER
+ || p_item->i_type == CONFIG_ITEM_BOOL )
+ {
+ int64_t *values;
+ char **texts;
+ ssize_t count = config_GetIntChoices( VLC_OBJECT( p_intf ),
+ qtu( option ), &values, &texts );
+ for( ssize_t i = 0; i < count; i++ )
{
- if( i_type == CONFIG_ITEM_INTEGER
- || i_type == CONFIG_ITEM_BOOL )
- combobox->addItem( qtr( p_item->ppsz_list_text[i_index] ),
- p_item->pi_list[i_index] );
- else if( i_type == CONFIG_ITEM_STRING )
- combobox->addItem( qtr( p_item->ppsz_list_text[i_index] ),
- p_item->ppsz_list[i_index] );
+ combobox->addItem( qtr( texts[i] ), values[i] );
+ free( texts[i] );
}
+ free( texts );
+ free( values );
}
- else
+ else if( p_item->i_type == CONFIG_ITEM_STRING )
{
- msg_Err( p_intf, "Couldn't find option \"%s\".", qtu( option ) );
+ char **values;
+ char **texts;
+ ssize_t count = config_GetPszChoices( VLC_OBJECT( p_intf ),
+ qtu( option ), &values, &texts );
+ for( ssize_t i = 0; i < count; i++ )
+ {
+ combobox->addItem( qtr( texts[i] ), values[i] );
+ free( texts[i] );
+ free( values[i] );
+ }
+ free( texts );
+ free( values );
}
}
diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp
index a098be2..0bce9e7 100644
--- a/modules/gui/qt4/components/preferences_widgets.cpp
+++ b/modules/gui/qt4/components/preferences_widgets.cpp
@@ -469,33 +469,19 @@ void StringListConfigControl::finish(module_config_t *p_module_config )
if(!p_module_config) return;
- if( p_module_config->pf_update_list )
- {
- vlc_value_t val;
- val.psz_string = strdup(p_module_config->value.psz);
-
- p_module_config->pf_update_list(p_this, p_item->psz_name, val, val, NULL);
- free( val.psz_string );
- }
-
- for( int i_index = 0; i_index < p_module_config->i_list; i_index++ )
+ char **values, **texts;
+ ssize_t count = config_GetPszChoices( p_this, p_item->psz_name,
+ &values, &texts );
+ for( ssize_t i = 0; i < count; i++ )
{
- if( !p_module_config->ppsz_list[i_index] )
- {
- combo->addItem( "", QVariant(""));
- if( !p_item->value.psz )
- combo->setCurrentIndex( combo->count() - 1 );
- continue;
- }
- combo->addItem( qfu((p_module_config->ppsz_list_text &&
- p_module_config->ppsz_list_text[i_index])?
- _(p_module_config->ppsz_list_text[i_index]) :
- p_module_config->ppsz_list[i_index] ),
- QVariant( qfu(p_module_config->ppsz_list[i_index] )) );
- if( p_item->value.psz && !strcmp( p_module_config->value.psz,
- p_module_config->ppsz_list[i_index] ) )
+ combo->addItem( qfu(texts[i]), QVariant( qfu(values[i])) );
+ if( !strcmp( p_item->value.psz ? p_item->value.psz : "", values[i] ) )
combo->setCurrentIndex( combo->count() - 1 );
+ free( texts[i] );
+ free( values[i] );
}
+ free( texts );
+ free( values );
if( p_module_config->psz_longtext )
{
@@ -518,39 +504,43 @@ void setfillVLCConfigCombo( const char *configname, intf_thread_t *p_intf,
{
module_config_t *p_config =
config_FindConfig( VLC_OBJECT(p_intf), configname );
- if( p_config )
- {
- QVariant def;
- bool string = (p_config->i_type & 0xF0) == CONFIG_ITEM_STRING;
-
- if( string )
- def = QVariant( qfu(p_config->value.psz) );
- else
- def = QVariant( qlonglong( p_config->value.i ) );
+ if( p_config == NULL )
+ return;
- if(p_config->pf_update_list)
+ if( (p_config->i_type & 0xF0) == CONFIG_ITEM_STRING )
+ {
+ char **values, **texts;
+ ssize_t count = config_GetPszChoices(VLC_OBJECT(p_intf),
+ configname, &values, &texts);
+ for( ssize_t i = 0; i < count; i++ )
{
- vlc_value_t val;
- val.i_int = p_config->value.i;
- p_config->pf_update_list(VLC_OBJECT(p_intf), configname, val, val, NULL);
+ combo->addItem( qtr(texts[i]), QVariant(qfu(values[i])) );
+ if( !strcmp(p_config->value.psz, values[i]) )
+ combo->setCurrentIndex( i );
+ free( texts[i] );
+ free( values[i] );
}
-
- for ( int i_index = 0; i_index < p_config->i_list; i_index++ )
+ free( texts );
+ free( values );
+ }
+ else
+ {
+ int64_t *values;
+ char **texts;
+ ssize_t count = config_GetIntChoices(VLC_OBJECT(p_intf), configname,
+ &values, &texts);
+ for( ssize_t i = 0; i < count; i++ )
{
- QVariant value;
-
- if( string )
- value = QVariant( qfu(p_config->ppsz_list[i_index]) );
- else
- value =QVariant( p_config->pi_list[i_index] );
- combo->addItem( qtr(p_config->ppsz_list_text[i_index]), value );
- if( def == value )
- combo->setCurrentIndex( i_index );
+ combo->addItem( qtr(texts[i]), QVariant(qlonglong(values[i])) );
+ if( p_config->value.i == values[i] )
+ combo->setCurrentIndex( i );
+ free( texts[i] );
}
-
- if( p_config->psz_longtext )
- combo->setToolTip( qfu( p_config->psz_longtext ) );
+ free( texts );
}
+
+ if( p_config->psz_longtext != NULL )
+ combo->setToolTip( qfu( p_config->psz_longtext ) );
}
/********* Module **********/
More information about the vlc-commits
mailing list