tagnavi make track submenu
add some faster options to the track menu add a shortcut for basename formatting sort basename results filename - by sorted filename title - just title no formatting untagged items are unsorted as well title mm:ss - title and duration Change-Id: I90aea95051f6231580ef7f1fc08cd2d0d69601fb
This commit is contained in:
parent
b5d93a6605
commit
1c26f565bf
4 changed files with 90 additions and 70 deletions
|
@ -1934,17 +1934,10 @@ static int pf_tcs_retrieve_track_title(int string_index, int disc_num, int track
|
|||
if (rb->strcmp(UNTAGGED, tcs.result) == 0)
|
||||
{
|
||||
/* show filename instead of <untaggged> */
|
||||
if (!rb->tagcache_retrieve(&tcs, tcs.idx_id, tag_filename,
|
||||
if (!rb->tagcache_retrieve(&tcs, tcs.idx_id, tag_virt_basename,
|
||||
file_name, MAX_PATH))
|
||||
return 0;
|
||||
track_title = file_name;
|
||||
if (track_title)
|
||||
{
|
||||
/* if filename remove the '/' */
|
||||
track_title = rb->strrchr(track_title, PATH_SEPCH);
|
||||
if (track_title)
|
||||
track_title++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!track_title)
|
||||
|
|
|
@ -930,9 +930,17 @@ static bool open_files(struct tagcache_search *tcs, int tag)
|
|||
static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,)
|
||||
struct index_entry *idx, int tag, char *buf, long bufsz)
|
||||
{
|
||||
bool success = false;
|
||||
bool is_basename = false;
|
||||
struct tagfile_entry tfe;
|
||||
long seek;
|
||||
|
||||
if (tag == tag_virt_basename)
|
||||
{
|
||||
tag = tag_filename;
|
||||
is_basename = true;
|
||||
}
|
||||
|
||||
if (TAGCACHE_IS_NUMERIC(tag))
|
||||
goto failure;
|
||||
|
||||
|
@ -950,7 +958,7 @@ static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,)
|
|||
if (tag == tag_filename && (idx->flag & FLAG_DIRCACHE))
|
||||
{
|
||||
if (dircache_get_fileref_path(&tcrc_dcfrefs[idx_id], buf, bufsz) >= 0)
|
||||
return true;
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_DIRCACHE */
|
||||
|
@ -959,13 +967,12 @@ static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,)
|
|||
struct tagfile_entry *ep =
|
||||
(struct tagfile_entry *)&tcramcache.hdr->tags[tag][seek];
|
||||
strmemccpy(buf, ep->tag_data, bufsz);
|
||||
|
||||
return true;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_TC_RAMCACHE */
|
||||
|
||||
if (open_files(tcs, tag))
|
||||
if (!success && open_files(tcs, tag))
|
||||
{
|
||||
lseek(tcs->idxfd[tag], seek, SEEK_SET);
|
||||
switch (ecread_tagfile_entry_and_tag(tcs->idxfd[tag], &tfe, buf, bufsz))
|
||||
|
@ -984,10 +991,22 @@ static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,)
|
|||
break;
|
||||
case e_SUCCESS_LEN_ZERO:
|
||||
case e_SUCCESS:
|
||||
return true;
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (is_basename)
|
||||
{
|
||||
char* basename = strrchr(buf, '/');
|
||||
if (basename != NULL)
|
||||
memmove(buf, basename + 1, strlen(basename)); /* includes NULL */
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
failure:
|
||||
str_setlen(buf, 0);
|
||||
return false;
|
||||
|
@ -1284,7 +1303,7 @@ static bool check_clauses(struct tagcache_search *tcs,
|
|||
if (clause->tag == tag_filename
|
||||
|| clause->tag == tag_virt_basename)
|
||||
{
|
||||
retrieve(tcs, IF_DIRCACHE(tcs->idx_id,) idx, tag_filename,
|
||||
retrieve(tcs, IF_DIRCACHE(tcs->idx_id,) idx, clause->tag,
|
||||
buf, bufsz);
|
||||
}
|
||||
else
|
||||
|
@ -1316,7 +1335,13 @@ static bool check_clauses(struct tagcache_search *tcs,
|
|||
case e_SUCCESS_LEN_ZERO: /* Check if entry has been deleted. */
|
||||
return false;
|
||||
case e_SUCCESS:
|
||||
break;
|
||||
if (clause->tag == tag_virt_basename)
|
||||
{
|
||||
char *basename = strrchr(str, '/');
|
||||
if (basename)
|
||||
str = basename + 1;
|
||||
}
|
||||
break;
|
||||
case e_ENTRY_SIZEMISMATCH:
|
||||
logf("read error #15");
|
||||
return false;
|
||||
|
@ -1333,13 +1358,6 @@ static bool check_clauses(struct tagcache_search *tcs,
|
|||
}
|
||||
}
|
||||
|
||||
if (clause->tag == tag_virt_basename)
|
||||
{
|
||||
char *basename = strrchr(str, '/');
|
||||
if (basename)
|
||||
str = basename + 1;
|
||||
}
|
||||
|
||||
if (!check_against_clause(seek, str, clause))
|
||||
{
|
||||
/* Clause failed -- try finding a logical-or clause */
|
||||
|
@ -1709,7 +1727,7 @@ bool tagcache_search_add_clause(struct tagcache_search *tcs,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool get_next(struct tagcache_search *tcs)
|
||||
static bool get_next(struct tagcache_search *tcs, bool is_numeric)
|
||||
{
|
||||
/* WARNING pointers into buf are used in outside functions */
|
||||
static char buf[TAGCACHE_BUFSZ];
|
||||
|
@ -1719,11 +1737,6 @@ static bool get_next(struct tagcache_search *tcs)
|
|||
long flag = 0;
|
||||
#endif
|
||||
|
||||
if (!tcs->valid || !tc_stat.ready)
|
||||
return false;
|
||||
|
||||
bool is_numeric = TAGCACHE_IS_NUMERIC(tcs->type);
|
||||
|
||||
if (tcs->idxfd[tcs->type] < 0 && !is_numeric
|
||||
#ifdef HAVE_TC_RAMCACHE
|
||||
&& !tcs->ramsearch
|
||||
|
@ -1849,9 +1862,6 @@ static bool get_next(struct tagcache_search *tcs)
|
|||
tcs->valid = false;
|
||||
logf("read error #4");
|
||||
return false;
|
||||
default:
|
||||
logf("unknown_error");
|
||||
break;;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1871,12 +1881,15 @@ static bool get_next(struct tagcache_search *tcs)
|
|||
|
||||
bool tagcache_get_next(struct tagcache_search *tcs)
|
||||
{
|
||||
while (get_next(tcs))
|
||||
if (tcs->valid && tagcache_is_usable())
|
||||
{
|
||||
if (tcs->result_len > 1)
|
||||
return true;
|
||||
bool is_numeric = TAGCACHE_IS_NUMERIC(tcs->type);
|
||||
while (get_next(tcs, is_numeric))
|
||||
{
|
||||
if (tcs->result_len > 1)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LOGF_ENABLE
|
||||
if (tcs->unique_list_count > 0)
|
||||
logf(" uniqbuf: %d used / %d avail", tcs->unique_list_count, tcs->unique_list_capacity);
|
||||
|
@ -2817,9 +2830,6 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
|||
logf("read error #8");
|
||||
close(fd);
|
||||
return -2;
|
||||
default:
|
||||
logf("unknown_error");
|
||||
break;;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3994,9 +4004,6 @@ static bool delete_entry(long idx_id)
|
|||
case e_TAG_SIZEMISMATCH:
|
||||
logf("delete_entry(): read error #3");
|
||||
goto cleanup;
|
||||
default:
|
||||
logf("unknown_error");
|
||||
break;;
|
||||
}
|
||||
|
||||
myidx.tag_seek[tag] = crc_32(buf, strlen(buf), 0xffffffff);
|
||||
|
@ -4519,10 +4526,6 @@ static bool check_file_refs(bool auto_update)
|
|||
|
||||
switch (res)
|
||||
{
|
||||
default:
|
||||
logf("read error");
|
||||
ret = false;
|
||||
goto wend_finished;
|
||||
case e_ENTRY_SIZEMISMATCH:
|
||||
logf("size mismatch entry EOF?"); /* likely EOF */
|
||||
ret = false;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
%format "fmt_title" "%d.%02d. %s - %02d:%02d" discnum tracknum title Lm Ls ? discnum > "0"
|
||||
%format "fmt_title" "%02d. %s - %02d:%02d" tracknum title Lm Ls ? tracknum > "0"
|
||||
%format "fmt_title" "%s - %02d:%02d" title Lm Ls
|
||||
%format "fmt_alphanum_title" "%s - %02d:%02d (%s)" basename Lm Ls filename ? title == "<Untagged>"
|
||||
%format "fmt_alphanum_title" "%s - %02d:%02d" title Lm Ls
|
||||
%format "fmt_mostplayed" "%2d|%3d %s (%s)" playcount autoscore title canonicalartist %sort = "inverse" %limit = "100"
|
||||
%format "fmt_lastplayed" "%06d%s - %s" lastplayed canonicalartist title %sort = "inverse" %limit = "99" %strip = "6"
|
||||
|
@ -165,6 +164,12 @@
|
|||
"New favourites" -> canonicalartist ? playcount <= "3" & autoscore > "85" -> album -> title = "fmt_best_tracks"
|
||||
"Forgotten favourites" -> title = "fmt_forgotten" ? playcount > "3" & autoscore > "85"
|
||||
|
||||
# Define track submenu
|
||||
%menu_start "track" "Tracks by"
|
||||
"Filename" -> basename
|
||||
"Title" -> title
|
||||
"Title mm:ss" -> title = "fmt_alphanum_title"
|
||||
|
||||
#
|
||||
# === Begin of main menu
|
||||
#
|
||||
|
@ -176,7 +181,7 @@
|
|||
"Album" -> album -> title = "fmt_title"
|
||||
"Genre" -> genre -> canonicalartist -> album -> title = "fmt_title"
|
||||
"Composer" -> composer -> album -> title = "fmt_title"
|
||||
"Track" -> title = "fmt_alphanum_title"
|
||||
"Track" ==> "track"
|
||||
"Year" -> year ? year > "0" -> canonicalartist -> album -> title = "fmt_title"
|
||||
"User Rating" -> rating -> title = "fmt_title"
|
||||
"Recently Added" -> album ? entryage < "4" & commitid > "0" -> title = "fmt_title"
|
||||
|
|
|
@ -1328,7 +1328,7 @@ static int format_str(struct tagcache_search *tcs, struct display_format *fmt,
|
|||
int buf_pos = 0;
|
||||
int i;
|
||||
|
||||
memset(buf, 0, buf_size);
|
||||
/* memset(buf, 0, buf_size); probably uneeded */
|
||||
for (i = 0; fmt->formatstr[i] != '\0'; i++)
|
||||
{
|
||||
if (fmt->formatstr[i] == '%')
|
||||
|
@ -1375,21 +1375,13 @@ static int format_str(struct tagcache_search *tcs, struct display_format *fmt,
|
|||
int tag = fmt->tags[parpos];
|
||||
|
||||
if (!tagcache_retrieve(tcs, tcs->idx_id,
|
||||
(tag == tag_virt_basename ?
|
||||
tag_filename : tag),
|
||||
tmpbuf, sizeof tmpbuf))
|
||||
tag, tmpbuf, sizeof tmpbuf))
|
||||
{
|
||||
logf("retrieve failed");
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (tag == tag_virt_basename
|
||||
&& (result = strrchr(tmpbuf, '/')) != NULL)
|
||||
{
|
||||
result++;
|
||||
}
|
||||
else
|
||||
result = tmpbuf;
|
||||
result = tmpbuf;
|
||||
}
|
||||
buf_pos +=
|
||||
snprintf(&buf[buf_pos], space_left, fmtbuf, result);
|
||||
|
@ -1424,6 +1416,19 @@ static struct tagentry* get_entries(struct tree_context *tc)
|
|||
return core_get_data(tc->cache.entries_handle);
|
||||
}
|
||||
|
||||
static void tcs_get_basename(struct tagcache_search *tcs, bool is_basename)
|
||||
{
|
||||
if (is_basename)
|
||||
{
|
||||
char* basename = strrchr(tcs->result, '/');
|
||||
if (basename != NULL)
|
||||
{
|
||||
tcs->result = basename + 1;
|
||||
tcs->result_len = strlen(tcs->result) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int retrieve_entries(struct tree_context *c, int offset, bool init)
|
||||
{
|
||||
struct tagcache_search tcs;
|
||||
|
@ -1436,6 +1441,7 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
|
|||
int tag;
|
||||
bool sort = false;
|
||||
bool sort_inverse;
|
||||
bool is_basename = false;
|
||||
int sort_limit;
|
||||
int strip;
|
||||
|
||||
|
@ -1463,13 +1469,19 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
|
|||
if (tag == menu_reload)
|
||||
return RELOAD_TAGTREE;
|
||||
|
||||
if (tag == tag_virt_basename) /* basename shortcut */
|
||||
{
|
||||
is_basename = true;
|
||||
tag = tag_filename;
|
||||
}
|
||||
|
||||
if (!tagcache_search(&tcs, tag))
|
||||
return -1;
|
||||
|
||||
/* Prevent duplicate entries in the search list. */
|
||||
tagcache_search_set_uniqbuf(&tcs, uniqbuf, UNIQBUF_SIZE);
|
||||
|
||||
if (level || csi->clause_count[0] || TAGCACHE_IS_NUMERIC(tag))
|
||||
if (level || is_basename|| csi->clause_count[0] || TAGCACHE_IS_NUMERIC(tag))
|
||||
sort = true;
|
||||
|
||||
for (i = 0; i < level; i++)
|
||||
|
@ -1589,10 +1601,10 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
|
|||
if (strcmp(tcs.result, UNTAGGED) == 0)
|
||||
{
|
||||
if (tag == tag_title && tcs.type == tag_title && tcs.filter_count <= 1)
|
||||
{ /* Fallback to filename */
|
||||
{ /* Fallback to basename */
|
||||
char *lastname = dptr->name;
|
||||
dptr->name = core_get_data(c->cache.name_buffer_handle)+namebufused;
|
||||
if (tagcache_retrieve(&tcs, tcs.idx_id, tag_filename, dptr->name,
|
||||
if (tagcache_retrieve(&tcs, tcs.idx_id, tag_virt_basename, dptr->name,
|
||||
c->cache.name_buffer_size - namebufused))
|
||||
{
|
||||
namebufused += strlen(dptr->name)+1;
|
||||
|
@ -1614,26 +1626,31 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
|
|||
{
|
||||
int ret = format_str(&tcs, fmt, dptr->name,
|
||||
c->cache.name_buffer_size - namebufused);
|
||||
if (ret == -4) /* buffer full */
|
||||
if (ret >= 0)
|
||||
{
|
||||
logf("chunk mode #2: %d", current_entry_count);
|
||||
c->dirfull = true;
|
||||
sort = false;
|
||||
break ;
|
||||
namebufused += strlen(dptr->name)+1; /* include NULL */
|
||||
}
|
||||
else if (ret < 0)
|
||||
else
|
||||
{
|
||||
dptr->name[0] = '\0';
|
||||
if (ret == -4) /* buffer full */
|
||||
{
|
||||
logf("chunk mode #2: %d", current_entry_count);
|
||||
c->dirfull = true;
|
||||
sort = false;
|
||||
break ;
|
||||
}
|
||||
|
||||
logf("format_str() failed");
|
||||
tagcache_search_finish(&tcs);
|
||||
tree_unlock_cache(c);
|
||||
core_unpin(tagtree_handle);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
namebufused += strlen(dptr->name)+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tcs_get_basename(&tcs, is_basename);
|
||||
namebufused += tcs.result_len;
|
||||
if (namebufused < c->cache.name_buffer_size)
|
||||
strcpy(dptr->name, tcs.result);
|
||||
|
@ -1647,8 +1664,10 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init)
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tcs_get_basename(&tcs, is_basename);
|
||||
dptr->name = tcs.result;
|
||||
|
||||
}
|
||||
entry_skip_formatter:
|
||||
dptr++;
|
||||
current_entry_count++;
|
||||
|
|
Loading…
Reference in a new issue