[vlc-devel] commit: playlist_search: enable all items if the search string is empty ( Rémi Duraffort )

git version control git at videolan.org
Tue Feb 10 10:35:10 CET 2009


vlc | branch: 0.9-bugfix | Rémi Duraffort <ivoire at videolan.org> | Mon Feb  9 15:41:00 2009 +0100| [294078a9893b1ae2dc340208410d731b9bfad698] | committer: Rémi Duraffort 

playlist_search: enable all items if the search string is empty
(and remove an unused argument).

Signed-off-by: Rémi Duraffort <ivoire at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=294078a9893b1ae2dc340208410d731b9bfad698
---

 src/playlist/search.c |   37 +++++++++++++++++++++++++++++++------
 1 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/src/playlist/search.c b/src/playlist/search.c
index fd3fef4..720f481 100644
--- a/src/playlist/search.c
+++ b/src/playlist/search.c
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * search.c : Search functions
  *****************************************************************************
- * Copyright (C) 1999-2004 the VideoLAN team
+ * Copyright (C) 1999-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Clément Stenac <zorglub at videolan.org>
@@ -126,9 +126,30 @@ playlist_item_t * playlist_ItemGetByInputId( playlist_t *p_playlist,
  * Live search handling
  ***************************************************************************/
 
-static bool playlist_LiveSearchUpdateInternal( playlist_t *p_playlist,
-                                                     playlist_item_t *p_root,
-                                                     const char *psz_string )
+/**
+ * Enable all items in the playlist
+ * @param p_root: the current root item
+ */
+static void playlist_LiveSearchClean( playlist_item_t *p_root )
+{
+    for( int i = 0; i < p_root->i_children; i++ )
+    {
+        playlist_item_t *p_item = p_root->pp_children[i];
+        if( p_item->i_children >= 0 )
+            playlist_LiveSearchClean( p_item );
+        p_item->i_flags &= ~PLAYLIST_DBL_FLAG;
+    }
+}
+
+
+/**
+ * Enable/Disable items in the playlist according to the search argument
+ * @param p_root: the current root item
+ * @param psz_string: the string to search
+ * @return true if an item match
+ */
+static bool playlist_LiveSearchUpdateInternal( playlist_item_t *p_root,
+                                               const char *psz_string )
 {
    int i;
    bool b_match = false;
@@ -137,7 +158,7 @@ static bool playlist_LiveSearchUpdateInternal( playlist_t *p_playlist,
         playlist_item_t *p_item = p_root->pp_children[i];
         if( p_item->i_children > -1 )
         {
-            if( playlist_LiveSearchUpdateInternal( p_playlist, p_item, psz_string ) ||
+            if( playlist_LiveSearchUpdateInternal( p_item, psz_string ) ||
                 strcasestr( p_item->p_input->psz_name, psz_string ) )
             {
                 p_item->i_flags &= ~PLAYLIST_DBL_FLAG;
@@ -171,7 +192,11 @@ int playlist_LiveSearchUpdate( playlist_t *p_playlist, playlist_item_t *p_root,
 {
     PL_ASSERT_LOCKED;
     p_playlist->b_reset_currently_playing = true;
-    playlist_LiveSearchUpdateInternal( p_playlist, p_root, psz_string );
+    if( *psz_string )
+        playlist_LiveSearchUpdateInternal( p_root, psz_string );
+    else
+        playlist_LiveSearchClean( p_root );
     vlc_object_signal_unlocked( p_playlist );
     return VLC_SUCCESS;
 }
+




More information about the vlc-devel mailing list