forked from len0rd/rockbox
Enabled playlist submenu for tagcache!
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10315 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
52aaa75e83
commit
4e6c79b42e
4 changed files with 103 additions and 30 deletions
|
@ -64,6 +64,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "playlist_menu.h"
|
#include "playlist_menu.h"
|
||||||
#include "playlist_catalog.h"
|
#include "playlist_catalog.h"
|
||||||
|
#include "tagtree.h"
|
||||||
|
|
||||||
static int context;
|
static int context;
|
||||||
static char* selected_file = NULL;
|
static char* selected_file = NULL;
|
||||||
|
@ -174,26 +175,33 @@ static bool add_to_playlist(int position, bool queue)
|
||||||
if (new_playlist)
|
if (new_playlist)
|
||||||
playlist_create(NULL, NULL);
|
playlist_create(NULL, NULL);
|
||||||
|
|
||||||
if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
|
if (context == CONTEXT_ID3DB)
|
||||||
playlist_insert_track(NULL, selected_file, position, queue);
|
|
||||||
else if (selected_file_attr & ATTR_DIRECTORY)
|
|
||||||
{
|
{
|
||||||
bool recurse = false;
|
tagtree_insert_selection_playlist(position, queue);
|
||||||
|
|
||||||
if (global_settings.recursive_dir_insert != RECURSE_ASK)
|
|
||||||
recurse = (bool)global_settings.recursive_dir_insert;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Ask if user wants to recurse directory */
|
|
||||||
recurse = (gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES);
|
|
||||||
}
|
|
||||||
|
|
||||||
playlist_insert_directory(NULL, selected_file, position, queue,
|
|
||||||
recurse);
|
|
||||||
}
|
}
|
||||||
else if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
|
else
|
||||||
playlist_insert_playlist(NULL, selected_file, position, queue);
|
{
|
||||||
|
if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
|
||||||
|
playlist_insert_track(NULL, selected_file, position, queue);
|
||||||
|
else if (selected_file_attr & ATTR_DIRECTORY)
|
||||||
|
{
|
||||||
|
bool recurse = false;
|
||||||
|
|
||||||
|
if (global_settings.recursive_dir_insert != RECURSE_ASK)
|
||||||
|
recurse = (bool)global_settings.recursive_dir_insert;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Ask if user wants to recurse directory */
|
||||||
|
recurse = (gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES);
|
||||||
|
}
|
||||||
|
|
||||||
|
playlist_insert_directory(NULL, selected_file, position, queue,
|
||||||
|
recurse);
|
||||||
|
}
|
||||||
|
else if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
|
||||||
|
playlist_insert_playlist(NULL, selected_file, position, queue);
|
||||||
|
}
|
||||||
|
|
||||||
if (new_playlist && (playlist_amount() > 0))
|
if (new_playlist && (playlist_amount() > 0))
|
||||||
{
|
{
|
||||||
/* nothing is currently playing so begin playing what we just
|
/* nothing is currently playing so begin playing what we just
|
||||||
|
@ -842,8 +850,7 @@ int onplay(char* file, int attr, int from)
|
||||||
|
|
||||||
if (context == CONTEXT_WPS ||
|
if (context == CONTEXT_WPS ||
|
||||||
context == CONTEXT_TREE ||
|
context == CONTEXT_TREE ||
|
||||||
((context == CONTEXT_ID3DB) &&
|
(context == CONTEXT_ID3DB))
|
||||||
(attr & TREE_ATTR_MASK) == TREE_ATTR_MPA))
|
|
||||||
{
|
{
|
||||||
items[i].desc = ID2P(LANG_PLAYLIST);
|
items[i].desc = ID2P(LANG_PLAYLIST);
|
||||||
items[i].function = playlist_options;
|
items[i].function = playlist_options;
|
||||||
|
|
|
@ -81,6 +81,8 @@ static const char *strp;
|
||||||
static int current_offset;
|
static int current_offset;
|
||||||
static int current_entry_count;
|
static int current_entry_count;
|
||||||
|
|
||||||
|
static struct tree_context *tc;
|
||||||
|
|
||||||
static int get_token_str(char *buf, int size)
|
static int get_token_str(char *buf, int size)
|
||||||
{
|
{
|
||||||
/* Find the start. */
|
/* Find the start. */
|
||||||
|
@ -745,6 +747,7 @@ static int load_root(struct tree_context *c)
|
||||||
struct tagentry *dptr = (struct tagentry *)c->dircache;
|
struct tagentry *dptr = (struct tagentry *)c->dircache;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
tc = c;
|
||||||
c->currtable = root;
|
c->currtable = root;
|
||||||
for (i = 0; i < si_count; i++)
|
for (i = 0; i < si_count; i++)
|
||||||
{
|
{
|
||||||
|
@ -924,23 +927,17 @@ int tagtree_get_filename(struct tree_context* c, char *buf, int buflen)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tagtree_play_folder(struct tree_context* c)
|
bool insert_all_playlist(struct tree_context *c, int position, bool queue)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
|
|
||||||
if (playlist_create(NULL, NULL) < 0)
|
|
||||||
{
|
|
||||||
logf("Failed creating playlist\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cpu_boost(true);
|
cpu_boost(true);
|
||||||
if (!tagcache_search(&tcs, tag_filename))
|
if (!tagcache_search(&tcs, tag_filename))
|
||||||
{
|
{
|
||||||
gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY));
|
gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY));
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i < c->filesindir; i++)
|
for (i=0; i < c->filesindir; i++)
|
||||||
|
@ -954,11 +951,77 @@ static int tagtree_play_folder(struct tree_context* c)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist_insert_track(NULL, buf, PLAYLIST_INSERT, false);
|
playlist_insert_track(NULL, buf, position, queue);
|
||||||
}
|
}
|
||||||
tagcache_search_finish(&tcs);
|
tagcache_search_finish(&tcs);
|
||||||
cpu_boost(false);
|
cpu_boost(false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tagtree_insert_selection_playlist(int position, bool queue)
|
||||||
|
{
|
||||||
|
struct tagentry *dptr;
|
||||||
|
int dirlevel = tc->dirlevel;
|
||||||
|
|
||||||
|
dptr = tagtree_get_entry(tc, tc->selected_item);
|
||||||
|
|
||||||
|
/* We need to set the table to allsubentries. */
|
||||||
|
if (dptr->newtable == navibrowse)
|
||||||
|
{
|
||||||
|
tagtree_enter(tc);
|
||||||
|
tagtree_load(tc);
|
||||||
|
dptr = tagtree_get_entry(tc, tc->selected_item);
|
||||||
|
}
|
||||||
|
else if (dptr->newtable != allsubentries)
|
||||||
|
{
|
||||||
|
logf("unsupported table: %d", dptr->newtable);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now the current table should be allsubentries. */
|
||||||
|
if (dptr->newtable != playtrack)
|
||||||
|
{
|
||||||
|
tagtree_enter(tc);
|
||||||
|
tagtree_load(tc);
|
||||||
|
dptr = tagtree_get_entry(tc, tc->selected_item);
|
||||||
|
|
||||||
|
/* And now the newtable should be playtrack. */
|
||||||
|
if (dptr->newtable != playtrack)
|
||||||
|
{
|
||||||
|
logf("newtable: %d !!", dptr->newtable);
|
||||||
|
tc->dirlevel = dirlevel;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tc->filesindir <= 0)
|
||||||
|
gui_syncsplash(HZ, true, str(LANG_END_PLAYLIST_PLAYER));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logf("insert_all_playlist");
|
||||||
|
insert_all_playlist(tc, position, queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finally return the dirlevel to its original value. */
|
||||||
|
while (tc->dirlevel > dirlevel)
|
||||||
|
tagtree_exit(tc);
|
||||||
|
tagtree_load(tc);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tagtree_play_folder(struct tree_context* c)
|
||||||
|
{
|
||||||
|
if (playlist_create(NULL, NULL) < 0)
|
||||||
|
{
|
||||||
|
logf("Failed creating playlist\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!insert_all_playlist(c, PLAYLIST_INSERT, false))
|
||||||
|
return -2;
|
||||||
|
|
||||||
if (global_settings.playlist_shuffle)
|
if (global_settings.playlist_shuffle)
|
||||||
c->selected_item = playlist_shuffle(current_tick, c->selected_item);
|
c->selected_item = playlist_shuffle(current_tick, c->selected_item);
|
||||||
if (!global_settings.play_selected)
|
if (!global_settings.play_selected)
|
||||||
|
|
|
@ -37,6 +37,7 @@ int tagtree_enter(struct tree_context* c);
|
||||||
void tagtree_exit(struct tree_context* c);
|
void tagtree_exit(struct tree_context* c);
|
||||||
int tagtree_load(struct tree_context* c);
|
int tagtree_load(struct tree_context* c);
|
||||||
struct tagentry* tagtree_get_entry(struct tree_context *c, int id);
|
struct tagentry* tagtree_get_entry(struct tree_context *c, int id);
|
||||||
|
bool tagtree_insert_selection_playlist(int position, bool queue);
|
||||||
int tagtree_get_attr(struct tree_context* c);
|
int tagtree_get_attr(struct tree_context* c);
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
const unsigned char* tagtree_get_icon(struct tree_context* c);
|
const unsigned char* tagtree_get_icon(struct tree_context* c);
|
||||||
|
|
|
@ -782,6 +782,8 @@ static bool dirbrowse(void)
|
||||||
attr = TREE_ATTR_MPA;
|
attr = TREE_ATTR_MPA;
|
||||||
tagtree_get_filename(&tc, buf, sizeof(buf));
|
tagtree_get_filename(&tc, buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
attr = ATTR_DIRECTORY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue