summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Kukla <roolku@rockbox.org>2007-10-30 10:02:57 +0000
committerRobert Kukla <roolku@rockbox.org>2007-10-30 10:02:57 +0000
commitc436657571f668299d1848b4227e01bda7434f7f (patch)
treef4c889a2d59c616a9860cc380a1c1b4c2f98e854
parente9001ae514128ae2a243a11408d230c15ab6b2b8 (diff)
downloadrockbox-c436657571f668299d1848b4227e01bda7434f7f.zip
rockbox-c436657571f668299d1848b4227e01bda7434f7f.tar.gz
rockbox-c436657571f668299d1848b4227e01bda7434f7f.tar.bz2
rockbox-c436657571f668299d1848b4227e01bda7434f7f.tar.xz
some improvements to FS#8008 - see tracker entry for details
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15371 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/tagcache.h7
-rw-r--r--apps/tagnavi.config6
-rw-r--r--apps/tagtree.c80
3 files changed, 45 insertions, 48 deletions
diff --git a/apps/tagcache.h b/apps/tagcache.h
index a33e79b..39f0c61f 100644
--- a/apps/tagcache.h
+++ b/apps/tagcache.h
@@ -109,10 +109,9 @@ struct tagcache_stat {
// const char *uimessage; /* Pending error message. Implement soon. */
};
-enum source_type {source_constant, source_input,
- source_current_path, /* has different handling to _id3
- so it has to be seperate */
- source_current_id3 /* dont add items after this.
+enum source_type {source_constant,
+ source_runtime,
+ source_current_path /* dont add items after this.
it is used as an index
into id3_to_search_mapping */
};
diff --git a/apps/tagnavi.config b/apps/tagnavi.config
index 4facdd2..def3c12 100644
--- a/apps/tagnavi.config
+++ b/apps/tagnavi.config
@@ -141,9 +141,11 @@
# Define the "same as current" sub menu
%menu_start "same" "Same as current"
+"Directory" -> title ? filename ^ "#directory#"
+"Title" -> title = "fmt_title" ? title = "#title#"
"Artist" -> album ? artist = "#artist#" -> title = "fmt_title"
-"Album" -> title = "fmt_title" ? album = "#album#"
-"Directory" -> filename ? filename ~ "#directory#"
+"Album" -> title = "fmt_title" ? album = "#album#" & albumartist = "#albumartist#"
+"Composer" -> title = "fmt_title" ? composer = "#composer#"
# Define the runtime sub menu
%menu_start "runtime" "Play history"
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 94bf726..c0d9f0f 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -51,12 +51,14 @@
static int tagtree_play_folder(struct tree_context* c);
-#define SEARCHSTR_SIZE 128
-static char searchstring[SEARCHSTR_SIZE];
+#define SEARCHSTR_SIZE 256
+
static const struct id3_to_search_mapping {
char *string;
size_t id3_offset;
} id3_to_search_mapping[] = {
+ { "", 0 }, /* offset n/a */
+ { "#directory#", 0 }, /* offset n/a */
{ "#title#", offsetof(struct mp3entry, title) },
{ "#artist#", offsetof(struct mp3entry, artist) },
{ "#album#", offsetof(struct mp3entry, album) },
@@ -288,7 +290,8 @@ static int get_clause(int *condition)
static bool read_clause(struct tagcache_search_clause *clause)
{
- char buf[256];
+ char buf[SEARCHSTR_SIZE];
+ unsigned int i;
if (get_tag(&clause->tag) <= 0)
return false;
@@ -298,33 +301,24 @@ static bool read_clause(struct tagcache_search_clause *clause)
if (get_token_str(buf, sizeof buf) < 0)
return false;
-
- clause->str = buffer_alloc(strlen(buf)+1);
- strcpy(clause->str, buf);
-
- logf("got clause: %d/%d [%s]", clause->tag, clause->type, clause->str);
-
- if (*(clause->str) == '\0')
- clause->source = source_input;
- else if (!strcasecmp(clause->str, "#directory#"))
- clause->source = source_current_path;
- else
+
+ for (i=0; i<ARRAYLEN(id3_to_search_mapping); i++)
{
- unsigned int i;
- bool found = false;
- for (i=0; !found && i<ARRAYLEN(id3_to_search_mapping); i++)
- {
- if (!strcasecmp(clause->str, id3_to_search_mapping[i].string))
- {
- found = true;
- break;
- }
- }
- if (found)
- clause->source = source_current_id3+i;
- else
- clause->source = source_constant;
+ if (!strcasecmp(buf, id3_to_search_mapping[i].string))
+ break;
}
+
+ if (i<ARRAYLEN(id3_to_search_mapping)) /* runtime search operand found */
+ {
+ clause->source = source_runtime+i;
+ clause->str = buffer_alloc(SEARCHSTR_SIZE);
+ }
+ else
+ {
+ clause->source = source_constant;
+ clause->str = buffer_alloc(strlen(buf)+1);
+ strcpy(clause->str, buf);
+ }
if (tagcache_is_numeric_tag(clause->tag))
{
@@ -333,6 +327,8 @@ static bool read_clause(struct tagcache_search_clause *clause)
}
else
clause->numeric = false;
+
+ logf("got clause: %d/%d [%s]", clause->tag, clause->type, clause->str);
return true;
}
@@ -1419,14 +1415,17 @@ int tagtree_enter(struct tree_context* c)
{
for (j = 0; j < csi->clause_count[i]; j++)
{
- *searchstring='\0';
+ char* searchstring;
source = csi->clause[i][j]->source;
if (source == source_constant)
continue;
-
+
+ searchstring=csi->clause[i][j]->str;
+ *searchstring = '\0';
+
id3 = audio_current_track();
-
+
if (source == source_current_path && id3)
{
char *e;
@@ -1435,11 +1434,11 @@ int tagtree_enter(struct tree_context* c)
if (e)
*e = '\0';
}
-
- if (source >= source_current_id3 && id3)
+ else if (source > source_runtime && id3)
{
- int i = source-source_current_id3;
- int offset = id3_to_search_mapping[i].id3_offset;
+
+ int k = source-source_runtime;
+ int offset = id3_to_search_mapping[k].id3_offset;
char **src = (char**)((char*)id3 + offset);
if (*src)
{
@@ -1447,8 +1446,7 @@ int tagtree_enter(struct tree_context* c)
searchstring[SEARCHSTR_SIZE-1] = '\0';
}
}
-
- if((source == source_input) || (*searchstring=='\0'))
+ else
{
rc = kbd_input(searchstring, SEARCHSTR_SIZE);
if (rc == -1 || !searchstring[0])
@@ -1456,18 +1454,16 @@ int tagtree_enter(struct tree_context* c)
tagtree_exit(c);
return 0;
}
+ if (csi->clause[i][j]->numeric)
+ csi->clause[i][j]->numeric_data = atoi(searchstring);
}
- if (csi->clause[i][j]->numeric)
- csi->clause[i][j]->numeric_data = atoi(searchstring);
- /* existing bug: only one dynamic string per clause! */
- csi->clause[i][j]->str = searchstring;
}
}
}
c->currtable = newextra;
-
+
break;
case navibrowse: