mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Accept FS#8008 - allows the current artist or album to be used in databse searches (use the #artist# or #album# keywords in tagnavi.config)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15354 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bae8f4c316
commit
4d18aa3546
3 changed files with 55 additions and 13 deletions
|
@ -109,12 +109,18 @@ struct tagcache_stat {
|
||||||
// const char *uimessage; /* Pending error message. Implement soon. */
|
// const char *uimessage; /* Pending error message. Implement soon. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum source_type {source_constant, source_input,
|
||||||
|
source_current_artist, source_current_album};
|
||||||
|
|
||||||
|
#define SOURCE_CURRENT_ARTIST "#artist#"
|
||||||
|
#define SOURCE_CURRENT_ALBUM "#album#"
|
||||||
|
|
||||||
struct tagcache_search_clause
|
struct tagcache_search_clause
|
||||||
{
|
{
|
||||||
int tag;
|
int tag;
|
||||||
int type;
|
int type;
|
||||||
bool numeric;
|
bool numeric;
|
||||||
bool input;
|
int source;
|
||||||
long numeric_data;
|
long numeric_data;
|
||||||
char *str;
|
char *str;
|
||||||
};
|
};
|
||||||
|
|
|
@ -139,6 +139,11 @@
|
||||||
"User Rating" -> title = "fmt_rating" ? rating > ""
|
"User Rating" -> title = "fmt_rating" ? rating > ""
|
||||||
"Comment" -> album ? comment ~ "" -> title = "fmt_title"
|
"Comment" -> album ? comment ~ "" -> title = "fmt_title"
|
||||||
|
|
||||||
|
# Define the "same as current" sub menu
|
||||||
|
%menu_start "same" "Same as current"
|
||||||
|
"Artist" -> album ? artist = "#artist#" -> title = "fmt_title"
|
||||||
|
"Album" -> title = "fmt_title" ? album = "#album#"
|
||||||
|
|
||||||
# Define the runtime sub menu
|
# Define the runtime sub menu
|
||||||
%menu_start "runtime" "Play history"
|
%menu_start "runtime" "Play history"
|
||||||
"Most played (Plays|Score)" -> title = "fmt_mostplayed" ? playcount > "0"
|
"Most played (Plays|Score)" -> title = "fmt_mostplayed" ? playcount > "0"
|
||||||
|
@ -166,6 +171,7 @@
|
||||||
"Recently Added" -> album ? entryage < "4" & commitid > "0" -> title = "fmt_title"
|
"Recently Added" -> album ? entryage < "4" & commitid > "0" -> title = "fmt_title"
|
||||||
"A to Z..." ==> "a2z"
|
"A to Z..." ==> "a2z"
|
||||||
"History..." ==> "runtime"
|
"History..." ==> "runtime"
|
||||||
|
"Same as current..." ==> "same"
|
||||||
"Search..." ==> "search"
|
"Search..." ==> "search"
|
||||||
"Custom view..." ==> "custom"
|
"Custom view..." ==> "custom"
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,8 @@
|
||||||
|
|
||||||
static int tagtree_play_folder(struct tree_context* c);
|
static int tagtree_play_folder(struct tree_context* c);
|
||||||
|
|
||||||
static char searchstring[128];
|
#define SEARCHSTR_SIZE 128
|
||||||
|
static char searchstring[SEARCHSTR_SIZE];
|
||||||
|
|
||||||
enum variables {
|
enum variables {
|
||||||
var_sorttype = 100,
|
var_sorttype = 100,
|
||||||
|
@ -293,9 +294,13 @@ static bool read_clause(struct tagcache_search_clause *clause)
|
||||||
logf("got clause: %d/%d [%s]", clause->tag, clause->type, clause->str);
|
logf("got clause: %d/%d [%s]", clause->tag, clause->type, clause->str);
|
||||||
|
|
||||||
if (*(clause->str) == '\0')
|
if (*(clause->str) == '\0')
|
||||||
clause->input = true;
|
clause->source = source_input;
|
||||||
|
else if (!strcasecmp(clause->str, SOURCE_CURRENT_ALBUM))
|
||||||
|
clause->source = source_current_album;
|
||||||
|
else if (!strcasecmp(clause->str, SOURCE_CURRENT_ARTIST))
|
||||||
|
clause->source = source_current_artist;
|
||||||
else
|
else
|
||||||
clause->input = false;
|
clause->source = source_constant;
|
||||||
|
|
||||||
if (tagcache_is_numeric_tag(clause->tag))
|
if (tagcache_is_numeric_tag(clause->tag))
|
||||||
{
|
{
|
||||||
|
@ -1345,8 +1350,10 @@ int tagtree_enter(struct tree_context* c)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
struct tagentry *dptr;
|
struct tagentry *dptr;
|
||||||
|
struct mp3entry *id3;
|
||||||
int newextra;
|
int newextra;
|
||||||
int seek;
|
int seek;
|
||||||
|
int source;
|
||||||
|
|
||||||
dptr = tagtree_get_entry(c, c->selected_item);
|
dptr = tagtree_get_entry(c, c->selected_item);
|
||||||
|
|
||||||
|
@ -1388,20 +1395,43 @@ int tagtree_enter(struct tree_context* c)
|
||||||
{
|
{
|
||||||
for (j = 0; j < csi->clause_count[i]; j++)
|
for (j = 0; j < csi->clause_count[i]; j++)
|
||||||
{
|
{
|
||||||
if (!csi->clause[i][j]->input)
|
*searchstring='\0';
|
||||||
|
source = csi->clause[i][j]->source;
|
||||||
|
|
||||||
|
if (source == source_constant)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rc = kbd_input(searchstring, sizeof(searchstring));
|
id3 = audio_current_track();
|
||||||
if (rc == -1 || !searchstring[0])
|
|
||||||
|
if ((source == source_current_artist) &&
|
||||||
|
(id3) && (id3->artist))
|
||||||
{
|
{
|
||||||
tagtree_exit(c);
|
strncpy(searchstring, id3->artist, SEARCHSTR_SIZE);
|
||||||
return 0;
|
searchstring[SEARCHSTR_SIZE-1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((source == source_current_album) &&
|
||||||
|
(id3) && (id3->album))
|
||||||
|
{
|
||||||
|
strncpy(searchstring, id3->album, SEARCHSTR_SIZE);
|
||||||
|
searchstring[SEARCHSTR_SIZE-1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if((source == source_input) || (*searchstring=='\0'))
|
||||||
|
{
|
||||||
|
rc = kbd_input(searchstring, SEARCHSTR_SIZE);
|
||||||
|
if (rc == -1 || !searchstring[0])
|
||||||
|
{
|
||||||
|
tagtree_exit(c);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (csi->clause[i][j]->numeric)
|
if (csi->clause[i][j]->numeric)
|
||||||
csi->clause[i][j]->numeric_data = atoi(searchstring);
|
csi->clause[i][j]->numeric_data = atoi(searchstring);
|
||||||
else
|
|
||||||
csi->clause[i][j]->str = searchstring;
|
/* existing bug: only one dynamic string per clause! */
|
||||||
|
csi->clause[i][j]->str = searchstring;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue