Commit da803b04 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: implement message object/module filter in the dialog

parent 9e0d891f
......@@ -95,7 +95,13 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
vlc_atomic_set( &this->verbosity, verbosity );
ui.verbosityBox->setValue( verbosity );
ui.vbobjectsEdit->setText(config_GetPsz( p_intf, "verbose-objects"));
char *objs = var_InheritString( p_intf, "verbose-objects" );
if( objs != NULL )
{
ui.vbobjectsEdit->setText( qfu(objs) );
free( objs );
}
updateConfig();
ui.vbobjectsEdit->setToolTip( "verbose-objects usage: \n"
"--verbose-objects=+printthatobject,-dontprintthatone\n"
"(keyword 'all' to applies to all objects)");
......@@ -139,37 +145,42 @@ void MessagesDialog::changeVerbosity( int verbosity )
void MessagesDialog::updateConfig()
{
config_PutPsz(p_intf, "verbose-objects", qtu(ui.vbobjectsEdit->text()));
//vbobjectsEdit->setText("vbEdit changed!");
if( !ui.vbobjectsEdit->text().isEmpty() )
const QString& objects = ui.vbobjectsEdit->text();
/* FIXME: config item should be part of Qt4 module */
config_PutPsz(p_intf, "verbose-objects", qtu(objects));
QStringList filterOut, filterIn;
/* If a filter is set, disable by default */
/* If no filters are set, enable */
filterDefault = objects.isEmpty();
foreach( const QString& elem, objects.split(QChar(',')) )
{
/* if user sets filter, go with the idea that user just wants that to be shown,
so disable all by default and enable those that user wants */
msg_DisableObjectPrinting( p_intf, "all");
char * psz_verbose_objects = strdup(qtu(ui.vbobjectsEdit->text()));
char * psz_object, * iter = psz_verbose_objects;
while( (psz_object = strsep( &iter, "," )) )
{
switch( psz_object[0] )
QString object = elem;
bool add = true;
if( elem.startsWith(QChar('-')) )
{
printf("%s\n", psz_object+1);
case '+': msg_EnableObjectPrinting(p_intf, psz_object+1); break;
case '-': msg_DisableObjectPrinting(p_intf, psz_object+1); break;
/* user can but just 'lua,playlist' on filter */
default: msg_EnableObjectPrinting(p_intf, psz_object); break;
}
}
free( psz_verbose_objects );
add = false;
object.remove( 0, 1 );
}
else if( elem.startsWith(QChar('+')) )
object.remove( 0, 1 );
if( object.compare(qfu("all"), Qt::CaseInsensitive) == 0 )
filterDefault = add;
else
{
msg_EnableObjectPrinting( p_intf, "all");
(add ? &filterIn : &filterOut)->append( object );
}
filter = filterDefault ? filterOut : filterIn;
filter.removeDuplicates();
}
void MessagesDialog::sinkMessage( MsgEvent *msg )
void MessagesDialog::sinkMessage( const MsgEvent *msg )
{
if( (filter.contains(msg->module) || filter.contains(msg->object_type))
== filterDefault )
return;
QTextEdit *messages = ui.messages;
/* Only scroll if the viewport is at the end.
Don't bug user by auto-changing/loosing viewport on insert(). */
......
......@@ -51,11 +51,14 @@ private:
msg_cb_data_t *cbData;
static void sinkMessage( msg_cb_data_t *, msg_item_t *, unsigned );
void customEvent( QEvent * );
void sinkMessage( MsgEvent * );
void sinkMessage( const MsgEvent * );
vlc_atomic_t verbosity;
static void MsgCallback( msg_cb_data_t *, const msg_item_t * );
QStringList filter;
bool filterDefault;
private slots:
bool save();
void updateConfig();
......
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