[vlc-commits] Qt4: implement message object/module filter in the dialog
Rémi Denis-Courmont
git at videolan.org
Fri Aug 19 23:00:12 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Aug 19 20:36:23 2011 +0300| [da803b049d1925c1855948cb0139b77c0b6cb8d0] | committer: Rémi Denis-Courmont
Qt4: implement message object/module filter in the dialog
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=da803b049d1925c1855948cb0139b77c0b6cb8d0
---
modules/gui/qt4/dialogs/messages.cpp | 61 ++++++++++++++++++++--------------
modules/gui/qt4/dialogs/messages.hpp | 5 ++-
2 files changed, 40 insertions(+), 26 deletions(-)
diff --git a/modules/gui/qt4/dialogs/messages.cpp b/modules/gui/qt4/dialogs/messages.cpp
index a64594e..92cc6af 100644
--- a/modules/gui/qt4/dialogs/messages.cpp
+++ b/modules/gui/qt4/dialogs/messages.cpp
@@ -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, "," )) )
+ QString object = elem;
+ bool add = true;
+
+ if( elem.startsWith(QChar('-')) )
{
- switch( psz_object[0] )
- {
- 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;
- }
+ add = false;
+ object.remove( 0, 1 );
}
- free( psz_verbose_objects );
- }
- else
- {
- msg_EnableObjectPrinting( p_intf, "all");
+ else if( elem.startsWith(QChar('+')) )
+ object.remove( 0, 1 );
+
+ if( object.compare(qfu("all"), Qt::CaseInsensitive) == 0 )
+ filterDefault = add;
+ else
+ (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(). */
diff --git a/modules/gui/qt4/dialogs/messages.hpp b/modules/gui/qt4/dialogs/messages.hpp
index bc360ab..81930e7 100644
--- a/modules/gui/qt4/dialogs/messages.hpp
+++ b/modules/gui/qt4/dialogs/messages.hpp
@@ -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();
More information about the vlc-commits
mailing list