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