summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2008-10-10 21:19:56 +0000
committerNils Wallménius <nils@rockbox.org>2008-10-10 21:19:56 +0000
commitda01219ca2a6f36b9743d50dc14a4aef009a3b5a (patch)
treebe55460933b0a8d0587caea37df330f2b606fe8a /apps
parentbea3abb5c376df9c812e83bc873910046ad34149 (diff)
downloadrockbox-da01219ca2a6f36b9743d50dc14a4aef009a3b5a.tar.gz
rockbox-da01219ca2a6f36b9743d50dc14a4aef009a3b5a.tar.bz2
rockbox-da01219ca2a6f36b9743d50dc14a4aef009a3b5a.zip
Search In Playlist
* Add a title to the list of search results. * Fix drawing of the statusbar. * Avoid splashing in every iteration of the search loop if no new hits, gives about 10x speedup on h300 when searching for a string that gives 30 hits in a playlist of 3000 tracks. * Boost cpu when searching, ~doubles the search speed. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18764 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang14
-rw-r--r--apps/playlist_viewer.c41
2 files changed, 40 insertions, 15 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 32cf24ae27..955a4572fa 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -12095,3 +12095,17 @@
recording_swcodec: "Mono mode"
</voice>
</phrase>
+<phrase>
+ id: LANG_SEARCH_RESULTS
+ desc: in sound_settings
+ user:
+ <source>
+ *: "Search Results"
+ </source>
+ <dest>
+ *: "Search Results"
+ </dest>
+ <voice>
+ *: "Search Results"
+ </voice>
+</phrase>
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index f2f7dfd5d1..2acc02abe4 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -782,48 +782,60 @@ bool search_playlist(void)
char search_str[32] = "";
bool ret = false, exit = false;
int i, playlist_count;
- int found_indicies[MAX_PLAYLIST_ENTRIES],found_indicies_count = 0;
+ int found_indicies[MAX_PLAYLIST_ENTRIES];
+ int found_indicies_count = 0, last_found_count = -1;
int button;
struct gui_synclist playlist_lists;
struct playlist_track_info track;
if (!playlist_viewer_init(&viewer, 0, false))
return ret;
- if (kbd_input(search_str,sizeof(search_str)) == -1)
+ if (kbd_input(search_str, sizeof(search_str)) == -1)
return ret;
lcd_clear_display();
playlist_count = playlist_amount_ex(viewer.playlist);
- for (i=0;(i<playlist_count)&&(found_indicies_count<MAX_PLAYLIST_ENTRIES);i++)
+
+ cpu_boost(true);
+
+ for (i=0; (i<playlist_count)&&(found_indicies_count<MAX_PLAYLIST_ENTRIES); i++)
{
- splashf(0, str(LANG_PLAYLIST_SEARCH_MSG), found_indicies_count,
- str(LANG_OFF_ABORT));
- if (action_userabort(TIMEOUT_NOBLOCK))
+ if (found_indicies_count != last_found_count)
{
- if (!found_indicies_count)
- return ret;
- break;
+ splashf(0, str(LANG_PLAYLIST_SEARCH_MSG), found_indicies_count,
+ str(LANG_OFF_ABORT));
+ last_found_count = found_indicies_count;
}
- playlist_get_track_info(viewer.playlist,i,&track);
+
+ if (action_userabort(TIMEOUT_NOBLOCK))
+ break;
+
+ playlist_get_track_info(viewer.playlist, i, &track);
+
if (strcasestr(track.filename,search_str))
- {
found_indicies[found_indicies_count++] = track.index;
- }
+
yield();
}
+
+ cpu_boost(false);
+
if (!found_indicies_count)
{
return ret;
}
backlight_on();
+
gui_synclist_init(&playlist_lists, playlist_search_callback_name,
found_indicies, false, 1, NULL);
+ gui_synclist_set_title(&playlist_lists, str(LANG_SEARCH_RESULTS), NOICON);
gui_synclist_set_icon_callback(&playlist_lists, NULL);
gui_synclist_set_nb_items(&playlist_lists, found_indicies_count);
gui_synclist_select_item(&playlist_lists, 0);
gui_synclist_draw(&playlist_lists);
while (!exit)
{
- button = get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
+ gui_syncstatusbar_draw(&statusbars, false);
+ button = get_action(CONTEXT_LIST, HZ/4);
if (gui_synclist_do_button(&playlist_lists, &button, LIST_WRAP_UNLESS_HELD))
continue;
switch (button)
@@ -838,8 +850,7 @@ bool search_playlist(void)
,0);
exit = 1;
break;
- case ACTION_NONE:
- break;
+
default:
if(default_event_handler(button) == SYS_USB_CONNECTED)
{