Browse by year (now numeric tags are fully supported too).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10750 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Miika Pekkarinen 2006-08-25 21:13:49 +00:00
parent 231adb4f77
commit 93bbd44ccc
3 changed files with 61 additions and 29 deletions

View File

@ -636,8 +636,12 @@ static bool add_uniqbuf(struct tagcache_search *tcs, long id)
int i;
/* If uniq buffer is not defined we must return true for search to work. */
if (tcs->unique_list == NULL || !tagcache_is_unique_tag(tcs->type))
if (tcs->unique_list == NULL
|| (!tagcache_is_unique_tag(tcs->type)
&& !tagcache_is_numeric_tag(tcs->type)))
{
return true;
}
for (i = 0; i < tcs->unique_list_count; i++)
{
@ -681,7 +685,9 @@ static bool build_lookup_list(struct tagcache_search *tcs)
{
if (hdr->indices[i].tag_seek[tcs->filter_tag[j]] !=
tcs->filter_seek[j])
{
break ;
}
}
if (j < tcs->filter_count)
@ -809,6 +815,8 @@ static bool build_lookup_list(struct tagcache_search *tcs)
tcs->seek_list[tcs->seek_list_count] = entry.tag_seek[tcs->type];
tcs->seek_flags[tcs->seek_list_count] = entry.flag;
tcs->seek_list_count++;
yield();
}
return tcs->seek_list_count > 0;
@ -897,17 +905,13 @@ bool tagcache_search(struct tagcache_search *tcs, int tag)
else
#endif
{
if (tagcache_is_numeric_tag(tcs->type))
if (!tagcache_is_numeric_tag(tcs->type))
{
tcs->valid = true;
tcs->initialized = true;
return true;
tcs->idxfd[tcs->type] = open_tag_fd(&tag_hdr, tcs->type, false);
if (tcs->idxfd[tcs->type] < 0)
return false;
}
tcs->idxfd[tcs->type] = open_tag_fd(&tag_hdr, tcs->type, false);
if (tcs->idxfd[tcs->type] < 0)
return false;
/* Always open as R/W so we can pass tcs to functions that modify data also
* without failing. */
tcs->masterfd = open_master_fd(&master_hdr, true);
@ -1019,25 +1023,26 @@ static bool get_next(struct tagcache_search *tcs)
)
return false;
/* Searching not supported for numeric tags yet. */
if (tagcache_is_numeric_tag(tcs->type))
return false;
/* Relative fetch. */
if (tcs->filter_count > 0 || tcs->clause_count > 0)
if (tcs->filter_count > 0 || tcs->clause_count > 0
|| tagcache_is_numeric_tag(tcs->type))
{
/* Check for end of list. */
if (tcs->seek_list_count == 0)
{
/* Try to fetch more. */
if (!build_lookup_list(tcs))
{
tcs->valid = false;
return false;
}
}
tcs->seek_list_count--;
/* Seek stream to the correct position and continue to direct fetch. */
if (!tcs->ramsearch || !TAG_FILENAME_RAM(tcs))
if ((!tcs->ramsearch || !TAG_FILENAME_RAM(tcs))
&& !tagcache_is_numeric_tag(tcs->type))
{
if (!open_files(tcs))
return false;
@ -1048,6 +1053,16 @@ static bool get_next(struct tagcache_search *tcs)
tcs->position = tcs->seek_list[tcs->seek_list_count];
}
if (tagcache_is_numeric_tag(tcs->type))
{
logf("r:%d", tcs->position);
snprintf(buf, sizeof(buf), "%d", tcs->position);
tcs->result_seek = tcs->position;
tcs->result = buf;
tcs->result_len = strlen(buf) + 1;
return true;
}
/* Direct fetch. */
#ifdef HAVE_TC_RAMCACHE
if (tcs->ramsearch && TAG_FILENAME_RAM(tcs))

View File

@ -3,15 +3,14 @@
"Genres" genre : artist : album : title = "%02d. %s" tracknum title
"Composers" composer : album : title = "%02d. %s" tracknum title
"Tracks" title
"Year" year ? year > "1000" & year < "2008" : artist : album : title = "%02d. %s" tracknum title
"Search by artist" artist ? artist ~ "" : album : title = "%02d. %s" tracknum title
"Search by album" album ? album ~ "" : title = "%02d. %s" tracknum title
"Search by title" title ? title ~ ""
"Search by filename" filename ? filename ~ ""
"Search by year" artist ? year = "" : album : title = "%02d. %s" tracknum title
"Search by score" title = "(%3d) %s" autoscore title ? autoscore > ""
"Most played tracks" title = "(%d) %s" playcount title ? playcount > "1"
"Most played tracks" title = "(%2d) %s" playcount title ? playcount > "1"
"Never played tracks" artist ? playcount == "0" : album : title = "%02d. %s" tracknum title
"Best tracks" title ? autoscore > "60" & playcount > "1"
"Example 1" artist ? year >= "2000" & artist ^ "a" : album : title
"Example 2" genre ? genre ~ "metal" : artist ? year >= "2000" : album ? year >= "2000" : title
"Best tracks" artist ? playcount > "1" & autoscore > "85" : album : title = "%02d. %s (%3d)" tracknum title autoscore
"List played tracks" title = "(%3d/%d) %s" autoscore playcount title ? playcount > "0"

View File

@ -546,7 +546,7 @@ int retrieve_entries(struct tree_context *c, struct tagcache_search *tcs,
int namebufused = 0;
int total_count = 0;
int special_entry_count = 0;
int extra = c->currextra;
int level = c->currextra;
int tag;
bool sort = false;
@ -564,10 +564,10 @@ int retrieve_entries(struct tree_context *c, struct tagcache_search *tcs,
if (c->currtable == allsubentries)
{
tag = tag_title;
extra--;
level--;
}
else
tag = csi->tagorder[extra];
tag = csi->tagorder[level];
if (!tagcache_search(tcs, tag))
return -1;
@ -575,13 +575,30 @@ int retrieve_entries(struct tree_context *c, struct tagcache_search *tcs,
/* Prevent duplicate entries in the search list. */
tagcache_search_set_uniqbuf(tcs, uniqbuf, UNIQBUF_SIZE);
if (extra || csi->clause_count[0])
if (level || csi->clause_count[0] || tagcache_is_numeric_tag(tag))
sort = true;
for (i = 0; i < extra; i++)
tagcache_search_add_filter(tcs, csi->tagorder[i], csi->result_seek[i]);
for (i = 0; i <= extra; i++)
for (i = 0; i < level; i++)
{
if (tagcache_is_numeric_tag(csi->tagorder[i]))
{
static struct tagcache_search_clause cc;
memset(&cc, 0, sizeof(struct tagcache_search_clause));
cc.tag = csi->tagorder[i];
cc.type = clause_is;
cc.numeric = true;
cc.numeric_data = csi->result_seek[i];
tagcache_search_add_clause(tcs, &cc);
}
else
{
tagcache_search_add_filter(tcs, csi->tagorder[i],
csi->result_seek[i]);
}
}
for (i = 0; i <= level; i++)
{
int j;
@ -609,7 +626,7 @@ int retrieve_entries(struct tree_context *c, struct tagcache_search *tcs,
while (tagcache_get_next(tcs))
{
struct display_format *fmt = &csi->format[extra];
struct display_format *fmt = &csi->format[level];
if (total_count++ < offset)
continue;
@ -619,7 +636,8 @@ int retrieve_entries(struct tree_context *c, struct tagcache_search *tcs,
if (tag == tag_title || tag == tag_filename)
dptr->newtable = playtrack;
if (!tcs->ramsearch || fmt->valid)
if (!tcs->ramsearch || fmt->valid
|| tagcache_is_numeric_tag(tag))
{
char buf[MAX_PATH];
int buf_pos = 0;