The source project of this merge request has been removed.
Enable locale-aware index on the artist list
Ported code of PR#1229 from GitHub. This almost works, except for one blocker: the artist list should be sorted lexicographically in the form (index_of(artist_name), artist_name)
using locale.strcoll
. I attempted to hack SelectionList.__sort_items
, but it never worked.
# One of my attempts...
def __sort_items(self, model, itera, iterb, data):
"""
Sort model
"""
if not self.__updating:
return False
a_index = model.get_value(itera, 0)
b_index = model.get_value(iterb, 0)
# Static vs static
if a_index < 0 and b_index < 0:
return a_index < b_index
# Static entries always on top
elif b_index < 0:
return True
# Static entries always on top
if a_index < 0:
return False
# String comparaison for non static
else:
if self.__is_artists:
a = Lp().artists.get_sortname(a_index)
b = Lp().artists.get_sortname(b_index)
else:
a = model.get_value(itera, 1)
b = model.get_value(iterb, 1)
ia = index_of(a).upper()
ib = index_of(b).upper()
if strcoll(ia, ib) < 0: return -1
elif strcoll(ia, ib) == 0: return strcoll(a, b)
else: return 1
Can you give me some hints on how to solve this problem? Thanks.
Edited by Cédric Bellegarde